[Tux3] Patch: Basic SMP locking for xcache
OGAWA Hirofumi
hirofumi at mail.parknet.co.jp
Fri Dec 26 23:15:27 PST 2008
> -static struct xattr *xcache_lookup(struct xcache *xcache, unsigned atom, int *err)
> +static struct xattr *xcache_lookup(struct xcache *xcache, unsigned atom)
> {
> if (!xcache)
> return NULL;
Maybe, return ERR_PTR(-ENOATTR); or something?
> @@ -356,46 +353,53 @@ static int xcache_update(struct inode *i
>
> struct xattr *get_xattr(struct inode *inode, char *name, unsigned len)
> {
> - int err = 0;
> - atom_t atom = find_atom(tux_sb(inode->i_sb)->atable, name, len);
> + struct inode *atable = tux_sb(inode->i_sb)->atable;
> + mutex_lock(&atable->i_mutex);
> + atom_t atom = find_atom(atable, name, len);
> if (atom == -1)
> - return NULL;
> - return xcache_lookup(tux_inode(inode)->xcache, atom, &err); // and what about the err???
mutex_unlock()
> + return ERR_PTR(-ENOATTR);
> + struct xattr *got = xcache_lookup(tux_inode(inode)->xcache, atom);
> + mutex_unlock(&atable->i_mutex);
> + return got;
> }
tux3.c:200, tux3fuse.c:566, and tux3_getxattr:595 are needed to update
to check IS_ERR();
> int set_xattr(struct inode *inode, char *name, unsigned len, void *data, unsigned size, unsigned flags)
> {
> - atom_t atom = make_atom(tux_sb(inode->i_sb)->atable, name, len);
> + struct inode *atable = tux_sb(inode->i_sb)->atable;
> + mutex_lock(&atable->i_mutex);
> + atom_t atom = make_atom(atable, name, len);
> if (atom == -1)
mutex_unlock()
> return -EINVAL;
> -/* unused */
> int del_xattr(struct inode *inode, char *name, unsigned len)
> {
> int err = 0;
> - atom_t atom = find_atom(tux_sb(inode->i_sb)->atable, name, len);
> + struct inode *atable = tux_sb(inode->i_sb)->atable;
> + mutex_lock(&atable->i_mutex);
> + atom_t atom = find_atom(atable, name, len);
> if (atom == -1)
mutex_unlock()
> return -ENOATTR;
> struct xcache *xcache = tux_inode(inode)->xcache;
> - struct xattr *xattr = xcache_lookup(xcache, atom, &err);
> - if (err)
> - return err;
> - if (!xattr)
> - return -ENOATTR;
> + struct xattr *xattr = xcache_lookup(xcache, atom);
> + if (IS_ERR(xattr))
mutex_unlock()
> + return PTR_ERR(xattr);
> int used = remove_old(xcache, xattr);
> if (used)
> - use_atom(tux_sb(inode->i_sb)->atable, atom, -used);
> + use_atom(atable, atom, -used);
> + mutex_unlock(&atable->i_mutex);
> return err;
> }
Thanks.
--
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
More information about the Tux3
mailing list