From 79d7e39ee1d4b423206f6cfd2cd2eed6253d95fe Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 21 Mar 2010 19:24:23 -0400 Subject: sb_entry() has been killed a couple of years ago and resurrected on mismerge Signed-off-by: Al Viro --- include/linux/fs.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 4079ef99900..d13a6b83ad0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1314,7 +1314,6 @@ extern int send_sigurg(struct fown_struct *fown); extern struct list_head super_blocks; extern spinlock_t sb_lock; -#define sb_entry(list) list_entry((list), struct super_block, s_list) #define S_BIAS (1<<30) struct super_block { struct list_head s_list; /* Keep this first */ -- cgit v1.2.2 From b20bd1a5e78af267dc4b6e1ffed48d5d776302c5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 22 Mar 2010 08:53:19 -0400 Subject: get rid of S_BIAS use atomic_inc_not_zero(&sb->s_active) instead of playing games with checking ->s_count > S_BIAS Signed-off-by: Al Viro --- include/linux/fs.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index d13a6b83ad0..62f84d955b8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1314,7 +1314,6 @@ extern int send_sigurg(struct fown_struct *fown); extern struct list_head super_blocks; extern spinlock_t sb_lock; -#define S_BIAS (1<<30) struct super_block { struct list_head s_list; /* Keep this first */ dev_t s_dev; /* search index; _not_ kdev_t */ -- cgit v1.2.2 From 8edd64bd6089e21f47dcdebb14b598b713213ddc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 22 Mar 2010 19:56:42 -0400 Subject: get rid of restarts in sync_filesystems() At the same time we can kill s_need_restart and local mutex in there. __put_super() made public for a while; will be gone later. Signed-off-by: Al Viro --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 62f84d955b8..e1c7427802b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1332,7 +1332,6 @@ struct super_block { struct rw_semaphore s_umount; struct mutex s_lock; int s_count; - int s_need_sync; atomic_t s_active; #ifdef CONFIG_SECURITY void *s_security; @@ -1780,6 +1779,7 @@ extern int get_sb_pseudo(struct file_system_type *, char *, struct vfsmount *mnt); extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); int __put_super_and_need_restart(struct super_block *sb); +int __put_super(struct super_block *sb); void put_super(struct super_block *sb); /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ -- cgit v1.2.2 From 35cf7ba0b46dc3582a01c3860b14bff122662aa3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 22 Mar 2010 21:13:53 -0400 Subject: Bury __put_super_and_need_restart() Signed-off-by: Al Viro --- include/linux/fs.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index e1c7427802b..523086714c7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1778,9 +1778,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *, const struct super_operations *ops, unsigned long, struct vfsmount *mnt); extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); -int __put_super_and_need_restart(struct super_block *sb); -int __put_super(struct super_block *sb); -void put_super(struct super_block *sb); /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \ -- cgit v1.2.2 From 01a05b337a5b647909e1d6670f57e7202318a5fb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 23 Mar 2010 06:06:58 -0400 Subject: new helper: iterate_supers() ... and switch the simple "loop over superblocks and do something" loops to it. Signed-off-by: Al Viro --- include/linux/fs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 523086714c7..eeb04ba17b6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2324,6 +2324,7 @@ extern struct super_block *get_super(struct block_device *); extern struct super_block *get_active_super(struct block_device *bdev); extern struct super_block *user_get_super(dev_t); extern void drop_super(struct super_block *sb); +extern void iterate_supers(void (*)(struct super_block *, void *), void *); extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_close(struct inode *, struct file *); -- cgit v1.2.2 From 18e9e5104fcd9a973ffe3eed3816c87f2a1b6cd2 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 23 Mar 2010 10:34:56 -0400 Subject: Introduce freeze_super and thaw_super for the fsfreeze ioctl Currently the way we do freezing is by passing sb>s_bdev to freeze_bdev and then letting it do all the work. But freezing is more of an fs thing, and doesn't really have much to do with the bdev at all, all the work gets done with the super. In btrfs we do not populate s_bdev, since we can have multiple bdev's for one fs and setting s_bdev makes removing devices from a pool kind of tricky. This means that freezing a btrfs filesystem fails, which causes us to corrupt with things like tux-on-ice which use the fsfreeze mechanism. So instead of populating sb->s_bdev with a random bdev in our pool, I've broken the actual fs freezing stuff into freeze_super and thaw_super. These just take the super_block that we're freezing and does the appropriate work. It's basically just copy and pasted from freeze_bdev. I've then converted freeze_bdev over to use the new super helpers. I've tested this with ext4 and btrfs and verified everything continues to work the same as before. The only new gotcha is multiple calls to the fsfreeze ioctl will return EBUSY if the fs is already frozen. I thought this was a better solution than adding a freeze counter to the super_block, but if everybody hates this idea I'm open to suggestions. Thanks, Signed-off-by: Josef Bacik Signed-off-by: Al Viro --- include/linux/fs.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index eeb04ba17b6..d51256bc632 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1797,6 +1797,8 @@ extern void drop_collected_mounts(struct vfsmount *); extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, struct vfsmount *); extern int vfs_statfs(struct dentry *, struct kstatfs *); +extern int freeze_super(struct super_block *super); +extern int thaw_super(struct super_block *super); extern int current_umask(void); -- cgit v1.2.2 From bb4354538eb7b92f32cfedbad68c7be266c0b467 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 13 May 2010 17:53:14 -0700 Subject: fs: xattr_handler table should be const The entries in xattr handler table should be immutable (ie const) like other operation tables. Later patches convert common filesystems. Uncoverted filesystems will still work, but will generate a compiler warning. Signed-off-by: Stephen Hemminger Signed-off-by: Al Viro --- include/linux/fs.h | 2 +- include/linux/generic_acl.h | 4 ++-- include/linux/xattr.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index d51256bc632..6660db898c4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1336,7 +1336,7 @@ struct super_block { #ifdef CONFIG_SECURITY void *s_security; #endif - struct xattr_handler **s_xattr; + const struct xattr_handler **s_xattr; struct list_head s_inodes; /* all inodes */ struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ diff --git a/include/linux/generic_acl.h b/include/linux/generic_acl.h index ca666d18ed6..574bea4013b 100644 --- a/include/linux/generic_acl.h +++ b/include/linux/generic_acl.h @@ -5,8 +5,8 @@ struct inode; -extern struct xattr_handler generic_acl_access_handler; -extern struct xattr_handler generic_acl_default_handler; +extern const struct xattr_handler generic_acl_access_handler; +extern const struct xattr_handler generic_acl_default_handler; int generic_acl_init(struct inode *, struct inode *); int generic_acl_chmod(struct inode *); diff --git a/include/linux/xattr.h b/include/linux/xattr.h index fb9b7e6e1e2..0cfa1e9c4cc 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -37,7 +37,7 @@ struct inode; struct dentry; struct xattr_handler { - char *prefix; + const char *prefix; int flags; /* fs private flags passed back to the handlers */ size_t (*list)(struct dentry *dentry, char *list, size_t list_size, const char *name, size_t name_len, int handler_flags); -- cgit v1.2.2 From 94d09a98cdb163be12fb5c76841fa295f0bee22a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 13 May 2010 17:53:19 -0700 Subject: reiserfs: constify xattr_handler Signed-off-by: Stephen Hemminger Signed-off-by: Al Viro --- include/linux/reiserfs_acl.h | 4 ++-- include/linux/reiserfs_xattr.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h index b4448853900..3fd8c4506bb 100644 --- a/include/linux/reiserfs_acl.h +++ b/include/linux/reiserfs_acl.h @@ -53,8 +53,8 @@ int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, struct inode *dir, struct dentry *dentry, struct inode *inode); int reiserfs_cache_default_acl(struct inode *dir); -extern struct xattr_handler reiserfs_posix_acl_default_handler; -extern struct xattr_handler reiserfs_posix_acl_access_handler; +extern const struct xattr_handler reiserfs_posix_acl_default_handler; +extern const struct xattr_handler reiserfs_posix_acl_access_handler; #else diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h index 7fa02b4af83..b2cf2089769 100644 --- a/include/linux/reiserfs_xattr.h +++ b/include/linux/reiserfs_xattr.h @@ -58,9 +58,9 @@ int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *, struct inode *, const char *, const void *, size_t, int); -extern struct xattr_handler reiserfs_xattr_user_handler; -extern struct xattr_handler reiserfs_xattr_trusted_handler; -extern struct xattr_handler reiserfs_xattr_security_handler; +extern const struct xattr_handler reiserfs_xattr_user_handler; +extern const struct xattr_handler reiserfs_xattr_trusted_handler; +extern const struct xattr_handler reiserfs_xattr_security_handler; #ifdef CONFIG_REISERFS_FS_SECURITY int reiserfs_security_init(struct inode *dir, struct inode *inode, struct reiserfs_security_handle *sec); -- cgit v1.2.2 From 8018ab057480974e7f26a387bf4ce040e9a5f6f1 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 22 Mar 2010 17:32:25 +0100 Subject: sanitize vfs_fsync calling conventions Now that the last user passing a NULL file pointer is gone we can remove the redundant dentry argument and associated hacks inside vfs_fsynmc_range. The next step will be removig the dentry argument from ->fsync, but given the luck with the last round of method prototype changes I'd rather defer this until after the main merge window. Signed-off-by: Christoph Hellwig Signed-off-by: Al Viro --- include/linux/fs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 6660db898c4..f3e108314c9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2084,9 +2084,9 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping, extern int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end); -extern int vfs_fsync_range(struct file *file, struct dentry *dentry, - loff_t start, loff_t end, int datasync); -extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync); +extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, + int datasync); +extern int vfs_fsync(struct file *file, int datasync); extern int generic_write_sync(struct file *file, loff_t pos, loff_t count); extern void sync_supers(void); extern void emergency_sync(void); -- cgit v1.2.2 From 51ee049e771c14a29aaee8ecd6cbbe14db088f3a Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Tue, 27 Apr 2010 14:23:57 -0700 Subject: vfs: add lockdep annotation to s_vfs_rename_key for ecryptfs > ============================================= > [ INFO: possible recursive locking detected ] > 2.6.31-2-generic #14~rbd3 > --------------------------------------------- > firefox-3.5/4162 is trying to acquire lock: > (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > > but task is already holding lock: > (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > > other info that might help us debug this: > 3 locks held by firefox-3.5/4162: > #0: (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > #1: (&sb->s_type->i_mutex_key#11/1){+.+.+.}, at: [] lock_rename+0x6a/0xf0 > #2: (&sb->s_type->i_mutex_key#11/2){+.+.+.}, at: [] lock_rename+0x7f/0xf0 > > stack backtrace: > Pid: 4162, comm: firefox-3.5 Tainted: G C 2.6.31-2-generic #14~rbd3 > Call Trace: > [] print_deadlock_bug+0xf4/0x100 > [] validate_chain+0x4c6/0x750 > [] __lock_acquire+0x237/0x430 > [] lock_acquire+0xa5/0x150 > [] ? lock_rename+0x41/0xf0 > [] __mutex_lock_common+0x4d/0x3d0 > [] ? lock_rename+0x41/0xf0 > [] ? lock_rename+0x41/0xf0 > [] ? ecryptfs_rename+0x99/0x170 > [] mutex_lock_nested+0x46/0x60 > [] lock_rename+0x41/0xf0 > [] ecryptfs_rename+0xca/0x170 > [] vfs_rename_dir+0x13e/0x160 > [] vfs_rename+0xee/0x290 > [] ? __lookup_hash+0x102/0x160 > [] sys_renameat+0x252/0x280 > [] ? cp_new_stat+0xe4/0x100 > [] ? sysret_check+0x2e/0x69 > [] ? trace_hardirqs_on_caller+0x14d/0x190 > [] sys_rename+0x1b/0x20 > [] system_call_fastpath+0x16/0x1b The trace above is totally reproducible by doing a cross-directory rename on an ecryptfs directory. The issue seems to be that sys_renameat() does lock_rename() then calls into the filesystem; if the filesystem is ecryptfs, then ecryptfs_rename() again does lock_rename() on the lower filesystem, and lockdep can't tell that the two s_vfs_rename_mutexes are different. It seems an annotation like the following is sufficient to fix this (it does get rid of the lockdep trace in my simple tests); however I would like to make sure I'm not misunderstanding the locking, hence the CC list... Signed-off-by: Roland Dreier Cc: Tyler Hicks Cc: Dustin Kirkland Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- include/linux/fs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index f3e108314c9..9626c5fbb0e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1741,6 +1741,7 @@ struct file_system_type { struct lock_class_key s_lock_key; struct lock_class_key s_umount_key; + struct lock_class_key s_vfs_rename_key; struct lock_class_key i_lock_key; struct lock_class_key i_mutex_key; -- cgit v1.2.2 From a1bd120d13e586ea1c424048fd2c8420a442852a Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Thu, 4 Mar 2010 17:29:14 +0300 Subject: vfs: Add inode uid,gid,mode init helper Signed-off-by: Dmitry Monakhov Signed-off-by: Al Viro --- include/linux/fs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 9626c5fbb0e..8a733862a41 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1428,7 +1428,8 @@ extern void dentry_unhash(struct dentry *dentry); * VFS file helper functions. */ extern int file_permission(struct file *, int); - +extern void inode_init_owner(struct inode *inode, const struct inode *dir, + mode_t mode); /* * VFS FS_IOC_FIEMAP helper definitions. */ -- cgit v1.2.2 From 454abafe9d8beb3fe7da06131b3d81d6d352a959 Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Thu, 4 Mar 2010 17:32:18 +0300 Subject: ramfs: replace inode uid,gid,mode initialization with helper function - seems what ramfs_get_inode is only locally, make it static. [AV: the hell it is; it's used by shmem, so shmem needed conversion too and no, that function can't be made static] Signed-off-by: Dmitry Monakhov Signed-off-by: Al Viro --- include/linux/ramfs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h index 8600508c77a..e7320b5e82f 100644 --- a/include/linux/ramfs.h +++ b/include/linux/ramfs.h @@ -1,7 +1,8 @@ #ifndef _LINUX_RAMFS_H #define _LINUX_RAMFS_H -struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev); +struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, + int mode, dev_t dev); extern int ramfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt); -- cgit v1.2.2