From: Linus Torvalds Date: Mon, 30 Mar 2009 19:29:21 +0000 (-0700) Subject: Merge branch 'reiserfs-updates' from Jeff Mahoney X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=e1c502482853f84606928f5a2f2eb6da1993cda1;p=linux-2.6-omap-h63xx.git Merge branch 'reiserfs-updates' from Jeff Mahoney * reiserfs-updates: (35 commits) reiserfs: rename [cn]_* variables reiserfs: rename p_._ variables reiserfs: rename p_s_tb to tb reiserfs: rename p_s_inode to inode reiserfs: rename p_s_bh to bh reiserfs: rename p_s_sb to sb reiserfs: strip trailing whitespace reiserfs: cleanup path functions reiserfs: factor out buffer_info initialization reiserfs: add atomic addition of selinux attributes during inode creation reiserfs: use generic readdir for operations across all xattrs reiserfs: journaled xattrs reiserfs: use generic xattr handlers reiserfs: remove i_has_xattr_dir reiserfs: make per-inode xattr locking more fine grained reiserfs: eliminate per-super xattr lock reiserfs: simplify xattr internal file lookups/opens reiserfs: Clean up xattrs when REISERFS_FS_XATTR is unset reiserfs: remove IS_PRIVATE helpers reiserfs: remove link detection code ... Fixed up conflicts manually due to: - quota name cleanups vs variable naming changes: fs/reiserfs/inode.c fs/reiserfs/namei.c fs/reiserfs/stree.c fs/reiserfs/xattr.c - exported include header cleanups include/linux/reiserfs_fs.h --- e1c502482853f84606928f5a2f2eb6da1993cda1 diff --cc fs/reiserfs/namei.c index 639d635d9d4,9d1070e741f..efd4d720718 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@@ -562,8 -559,8 +559,8 @@@ static int drop_new_inode(struct inode return 0; } - /* utility function that does setup for reiserfs_new_inode. + /* utility function that does setup for reiserfs_new_inode. -** DQUOT_INIT needs lots of credits so it's better to have it +** vfs_dq_init needs lots of credits so it's better to have it ** outside of a transaction, so we had to pull some bits of ** reiserfs_new_inode out into this func. */ diff --cc fs/reiserfs/stree.c index 73aaa33f673,e23303daa86..d036ee5b1c8 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c @@@ -1293,14 -1258,14 +1258,14 @@@ int reiserfs_delete_item(struct reiserf do_balance(&s_del_balance, NULL, NULL, M_DELETE); #ifdef REISERQUOTA_DEBUG - reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, + reiserfs_debug(sb, REISERFS_DEBUG_CODE, "reiserquota delete_item(): freeing %u, id=%u type=%c", - quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih)); + quota_cut_bytes, inode->i_uid, head2type(&s_ih)); #endif - vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes); - DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes); ++ vfs_dq_free_space_nodirty(inode, quota_cut_bytes); /* Return deleted body length */ - return n_ret_value; + return ret_value; } /* Summary Of Mechanisms For Handling Collisions Between Processes: @@@ -1727,15 -1689,15 +1689,15 @@@ int reiserfs_cut_from_item(struct reise ** unmap and invalidate it */ unmap_buffers(page, tail_pos); - REISERFS_I(p_s_inode)->i_flags &= ~i_pack_on_close_mask; + REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask; } #ifdef REISERQUOTA_DEBUG - reiserfs_debug(p_s_inode->i_sb, REISERFS_DEBUG_CODE, + reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota cut_from_item(): freeing %u id=%u type=%c", - quota_cut_bytes, p_s_inode->i_uid, '?'); + quota_cut_bytes, inode->i_uid, '?'); #endif - vfs_dq_free_space_nodirty(p_s_inode, quota_cut_bytes); - return n_ret_value; - DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes); ++ vfs_dq_free_space_nodirty(inode, quota_cut_bytes); + return ret_value; } static void truncate_directory(struct reiserfs_transaction_handle *th, @@@ -1967,18 -1927,18 +1927,18 @@@ int reiserfs_paste_into_item(struct rei #ifdef REISERQUOTA_DEBUG reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota paste_into_item(): allocating %u id=%u type=%c", - n_pasted_size, inode->i_uid, - key2type(&(p_s_key->on_disk_key))); + pasted_size, inode->i_uid, + key2type(&(key->on_disk_key))); #endif - if (vfs_dq_alloc_space_nodirty(inode, n_pasted_size)) { - pathrelse(p_s_search_path); - if (DQUOT_ALLOC_SPACE_NODIRTY(inode, pasted_size)) { ++ if (vfs_dq_alloc_space_nodirty(inode, pasted_size)) { + pathrelse(search_path); return -EDQUOT; } - init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path, - n_pasted_size); + init_tb_struct(th, &s_paste_balance, th->t_super, search_path, + pasted_size); #ifdef DISPLACE_NEW_PACKING_LOCALITIES - s_paste_balance.key = p_s_key->on_disk_key; + s_paste_balance.key = key->on_disk_key; #endif /* DQUOT_* can schedule, must check before the fix_nodes */ @@@ -2024,10 -1984,10 +1984,10 @@@ #ifdef REISERQUOTA_DEBUG reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota paste_into_item(): freeing %u id=%u type=%c", - n_pasted_size, inode->i_uid, - key2type(&(p_s_key->on_disk_key))); + pasted_size, inode->i_uid, + key2type(&(key->on_disk_key))); #endif - vfs_dq_free_space_nodirty(inode, n_pasted_size); - DQUOT_FREE_SPACE_NODIRTY(inode, pasted_size); ++ vfs_dq_free_space_nodirty(inode, pasted_size); return retval; } @@@ -2060,8 -2025,8 +2025,8 @@@ int reiserfs_insert_item(struct reiserf #endif /* We can't dirty inode here. It would be immediately written but * appropriate stat item isn't inserted yet... */ - if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) { + if (vfs_dq_alloc_space_nodirty(inode, quota_bytes)) { - pathrelse(p_s_path); + pathrelse(path); return -EDQUOT; } } @@@ -2109,9 -2073,9 +2073,9 @@@ #ifdef REISERQUOTA_DEBUG reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE, "reiserquota insert_item(): freeing %u id=%u type=%c", - quota_bytes, inode->i_uid, head2type(p_s_ih)); + quota_bytes, inode->i_uid, head2type(ih)); #endif if (inode) - DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes); + vfs_dq_free_space_nodirty(inode, quota_bytes); return retval; } diff --cc fs/reiserfs/xattr.c index ae881ccd2f0,1baafec6433..e52743e7700 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c @@@ -48,56 -53,101 +53,101 @@@ #define PRIVROOT_NAME ".reiserfs_priv" #define XAROOT_NAME "xattrs" - static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char - *prefix); - /* Returns the dentry referring to the root of the extended attribute - * directory tree. If it has already been retrieved, it is used. If it - * hasn't been created and the flags indicate creation is allowed, we - * attempt to create it. On error, we return a pointer-encoded error. - */ - static struct dentry *get_xa_root(struct super_block *sb, int flags) + /* Helpers for inode ops. We do this so that we don't have all the VFS + * overhead and also for proper i_mutex annotation. + * dir->i_mutex must be held for all of them. */ + static int xattr_create(struct inode *dir, struct dentry *dentry, int mode) { - struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root); - struct dentry *xaroot; + BUG_ON(!mutex_is_locked(&dir->i_mutex)); - DQUOT_INIT(dir); ++ vfs_dq_init(dir); + return dir->i_op->create(dir, dentry, mode, NULL); + } - /* This needs to be created at mount-time */ - if (!privroot) - return ERR_PTR(-ENODATA); + static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode) + { + BUG_ON(!mutex_is_locked(&dir->i_mutex)); - DQUOT_INIT(dir); ++ vfs_dq_init(dir); + return dir->i_op->mkdir(dir, dentry, mode); + } - mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR); - if (REISERFS_SB(sb)->xattr_root) { - xaroot = dget(REISERFS_SB(sb)->xattr_root); - goto out; - } + /* We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr + * mutation ops aren't called during rename or splace, which are the + * only other users of I_MUTEX_CHILD. It violates the ordering, but that's + * better than allocating another subclass just for this code. */ + static int xattr_unlink(struct inode *dir, struct dentry *dentry) + { + int error; + BUG_ON(!mutex_is_locked(&dir->i_mutex)); - DQUOT_INIT(dir); ++ vfs_dq_init(dir); - xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME)); - if (IS_ERR(xaroot)) { - goto out; - } else if (!xaroot->d_inode) { + mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); + error = dir->i_op->unlink(dir, dentry); + mutex_unlock(&dentry->d_inode->i_mutex); + + if (!error) + d_delete(dentry); + return error; + } + + static int xattr_rmdir(struct inode *dir, struct dentry *dentry) + { + int error; + BUG_ON(!mutex_is_locked(&dir->i_mutex)); - DQUOT_INIT(dir); ++ vfs_dq_init(dir); + + mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); + dentry_unhash(dentry); + error = dir->i_op->rmdir(dir, dentry); + if (!error) + dentry->d_inode->i_flags |= S_DEAD; + mutex_unlock(&dentry->d_inode->i_mutex); + if (!error) + d_delete(dentry); + dput(dentry); + + return error; + } + + #define xattr_may_create(flags) (!flags || flags & XATTR_CREATE) + + /* Returns and possibly creates the xattr dir. */ + static struct dentry *lookup_or_create_dir(struct dentry *parent, + const char *name, int flags) + { + struct dentry *dentry; + BUG_ON(!parent); + + dentry = lookup_one_len(name, parent, strlen(name)); + if (IS_ERR(dentry)) + return dentry; + else if (!dentry->d_inode) { int err = -ENODATA; - if (flags == 0 || flags & XATTR_CREATE) - err = privroot->d_inode->i_op->mkdir(privroot->d_inode, - xaroot, 0700); + + if (xattr_may_create(flags)) { + mutex_lock_nested(&parent->d_inode->i_mutex, + I_MUTEX_XATTR); + err = xattr_mkdir(parent->d_inode, dentry, 0700); + mutex_unlock(&parent->d_inode->i_mutex); + } + if (err) { - dput(xaroot); - xaroot = ERR_PTR(err); - goto out; + dput(dentry); + dentry = ERR_PTR(err); } } - REISERFS_SB(sb)->xattr_root = dget(xaroot); - out: - mutex_unlock(&privroot->d_inode->i_mutex); - dput(privroot); - return xaroot; + return dentry; + } + + static struct dentry *open_xa_root(struct super_block *sb, int flags) + { + struct dentry *privroot = REISERFS_SB(sb)->priv_root; + if (!privroot) + return ERR_PTR(-ENODATA); + return lookup_or_create_dir(privroot, XAROOT_NAME, flags); } - /* Opens the directory corresponding to the inode's extended attribute store. - * If flags allow, the tree to the directory may be created. If creation is - * prohibited, -ENODATA is returned. */ static struct dentry *open_xa_dir(const struct inode *inode, int flags) { struct dentry *xaroot, *xadir; diff --cc include/linux/reiserfs_fs.h index e356c99f065,e711c796e9d..2245c78d587 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h @@@ -35,33 -37,6 +35,31 @@@ * */ +/* ioctl's command */ +#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long) +/* define following flags to be the same as in ext2, so that chattr(1), + lsattr(1) will work with us. */ +#define REISERFS_IOC_GETFLAGS FS_IOC_GETFLAGS +#define REISERFS_IOC_SETFLAGS FS_IOC_SETFLAGS +#define REISERFS_IOC_GETVERSION FS_IOC_GETVERSION +#define REISERFS_IOC_SETVERSION FS_IOC_SETVERSION + +#ifdef __KERNEL__ +/* the 32 bit compat definitions with int argument */ +#define REISERFS_IOC32_UNPACK _IOW(0xCD, 1, int) +#define REISERFS_IOC32_GETFLAGS FS_IOC32_GETFLAGS +#define REISERFS_IOC32_SETFLAGS FS_IOC32_SETFLAGS +#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION +#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION + +/* Locking primitives */ +/* Right now we are still falling back to (un)lock_kernel, but eventually that + would evolve into real per-fs locks */ +#define reiserfs_write_lock( sb ) lock_kernel() +#define reiserfs_write_unlock( sb ) unlock_kernel() + - /* xattr stuff */ - #define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem) +struct fid; + /* in reading the #defines, it may help to understand that they employ the following abbreviations: @@@ -2203,6 -2210,26 +2233,6 @@@ long reiserfs_compat_ioctl(struct file unsigned int cmd, unsigned long arg); int reiserfs_unpack(struct inode *inode, struct file *filp); -/* ioctl's command */ -#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long) -/* define following flags to be the same as in ext2, so that chattr(1), - lsattr(1) will work with us. */ -#define REISERFS_IOC_GETFLAGS FS_IOC_GETFLAGS -#define REISERFS_IOC_SETFLAGS FS_IOC_SETFLAGS -#define REISERFS_IOC_GETVERSION FS_IOC_GETVERSION -#define REISERFS_IOC_SETVERSION FS_IOC_SETVERSION - -/* the 32 bit compat definitions with int argument */ -#define REISERFS_IOC32_UNPACK _IOW(0xCD, 1, int) -#define REISERFS_IOC32_GETFLAGS FS_IOC32_GETFLAGS -#define REISERFS_IOC32_SETFLAGS FS_IOC32_SETFLAGS -#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION -#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION -- -/* Locking primitives */ -/* Right now we are still falling back to (un)lock_kernel, but eventually that - would evolve into real per-fs locks */ -#define reiserfs_write_lock( sb ) lock_kernel() -#define reiserfs_write_unlock( sb ) unlock_kernel() +#endif /* __KERNEL__ */ + #endif /* _LINUX_REISER_FS_H */