[PATCH] Revert bd_mount_mutex back to a semaphore
authorDavid Chinner <dgc@sgi.com>
Thu, 11 Jan 2007 07:15:41 +0000 (23:15 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Fri, 12 Jan 2007 02:18:21 +0000 (18:18 -0800)
Revert bd_mount_mutex back to a semaphore so that xfs_freeze -f /mnt/newtest;
xfs_freeze -u /mnt/newtest works safely and doesn't produce lockdep warnings.

(XFS unlocks the semaphore from a different task, by design.  The mutex
code warns about this)

Signed-off-by: Dave Chinner <dgc@sgi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/block_dev.c
fs/buffer.c
fs/gfs2/ops_fstype.c
fs/super.c
include/linux/fs.h

index 1715d6b5f411a2d6db22c9a38de9cab971e40bf6..8b18e43b82fe8e156bab431070a882ea5cb9a5bf 100644 (file)
@@ -411,7 +411,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
        {
                memset(bdev, 0, sizeof(*bdev));
                mutex_init(&bdev->bd_mutex);
-               mutex_init(&bdev->bd_mount_mutex);
+               sema_init(&bdev->bd_mount_sem, 1);
                INIT_LIST_HEAD(&bdev->bd_inodes);
                INIT_LIST_HEAD(&bdev->bd_list);
 #ifdef CONFIG_SYSFS
index 263f88e4dffb8bcd617742374d0934d316be948f..3b116078b4c399211875623092de6eec139d4c15 100644 (file)
@@ -180,7 +180,7 @@ int fsync_bdev(struct block_device *bdev)
  * freeze_bdev  --  lock a filesystem and force it into a consistent state
  * @bdev:      blockdevice to lock
  *
- * This takes the block device bd_mount_mutex to make sure no new mounts
+ * This takes the block device bd_mount_sem to make sure no new mounts
  * happen on bdev until thaw_bdev() is called.
  * If a superblock is found on this device, we take the s_umount semaphore
  * on it to make sure nobody unmounts until the snapshot creation is done.
@@ -189,7 +189,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
 {
        struct super_block *sb;
 
-       mutex_lock(&bdev->bd_mount_mutex);
+       down(&bdev->bd_mount_sem);
        sb = get_super(bdev);
        if (sb && !(sb->s_flags & MS_RDONLY)) {
                sb->s_frozen = SB_FREEZE_WRITE;
@@ -231,7 +231,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
                drop_super(sb);
        }
 
-       mutex_unlock(&bdev->bd_mount_mutex);
+       up(&bdev->bd_mount_sem);
 }
 EXPORT_SYMBOL(thaw_bdev);
 
index d14e139d267478395cf9b91ca31114c02fe4ba53..ee80b8a5e7bc1ddfa0bb3136ae4f38240ef3ec8e 100644 (file)
@@ -867,9 +867,9 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
                error = -EBUSY;
                goto error;
        }
-       mutex_lock(&sb->s_bdev->bd_mount_mutex);
+       down(&sb->s_bdev->bd_mount_sem);
        new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev);
-       mutex_unlock(&sb->s_bdev->bd_mount_mutex);
+       up(&sb->s_bdev->bd_mount_sem);
        if (IS_ERR(new)) {
                error = PTR_ERR(new);
                goto error;
index f961e03079974a374cdf7476107924e0c2a5ebc0..3e7458c2bb76c6d46b44a57718cb3b30a9d317fe 100644 (file)
@@ -753,9 +753,9 @@ int get_sb_bdev(struct file_system_type *fs_type,
         * will protect the lockfs code from trying to start a snapshot
         * while we are mounting
         */
-       mutex_lock(&bdev->bd_mount_mutex);
+       down(&bdev->bd_mount_sem);
        s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
-       mutex_unlock(&bdev->bd_mount_mutex);
+       up(&bdev->bd_mount_sem);
        if (IS_ERR(s))
                goto error_s;
 
index 14a337cc3464083b9c0bb8bae7118bbd2a48d984..1410e5330c8daafb1a9e781dca9c56c5e1c4a0e5 100644 (file)
@@ -459,7 +459,7 @@ struct block_device {
        struct inode *          bd_inode;       /* will die */
        int                     bd_openers;
        struct mutex            bd_mutex;       /* open/close mutex */
-       struct mutex            bd_mount_mutex; /* mount mutex */
+       struct semaphore        bd_mount_sem;
        struct list_head        bd_inodes;
        void *                  bd_holder;
        int                     bd_holders;