aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/cpfile.c6
-rw-r--r--fs/nilfs2/super.c12
-rw-r--r--fs/nilfs2/the_nilfs.c1
-rw-r--r--fs/nilfs2/the_nilfs.h2
4 files changed, 12 insertions, 9 deletions
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index 300f1cdfa862..cadd36b14d07 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -864,11 +864,11 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
864 case NILFS_CHECKPOINT: 864 case NILFS_CHECKPOINT:
865 /* 865 /*
866 * Check for protecting existing snapshot mounts: 866 * Check for protecting existing snapshot mounts:
867 * bd_mount_sem is used to make this operation atomic and 867 * ns_mount_mutex is used to make this operation atomic and
868 * exclusive with a new mount job. Though it doesn't cover 868 * exclusive with a new mount job. Though it doesn't cover
869 * umount, it's enough for the purpose. 869 * umount, it's enough for the purpose.
870 */ 870 */
871 down(&nilfs->ns_bdev->bd_mount_sem); 871 mutex_lock(&nilfs->ns_mount_mutex);
872 if (nilfs_checkpoint_is_mounted(nilfs, cno, 1)) { 872 if (nilfs_checkpoint_is_mounted(nilfs, cno, 1)) {
873 /* Current implementation does not have to protect 873 /* Current implementation does not have to protect
874 plain read-only mounts since they are exclusive 874 plain read-only mounts since they are exclusive
@@ -877,7 +877,7 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
877 ret = -EBUSY; 877 ret = -EBUSY;
878 } else 878 } else
879 ret = nilfs_cpfile_clear_snapshot(cpfile, cno); 879 ret = nilfs_cpfile_clear_snapshot(cpfile, cno);
880 up(&nilfs->ns_bdev->bd_mount_sem); 880 mutex_unlock(&nilfs->ns_mount_mutex);
881 return ret; 881 return ret;
882 case NILFS_SNAPSHOT: 882 case NILFS_SNAPSHOT:
883 return nilfs_cpfile_set_snapshot(cpfile, cno); 883 return nilfs_cpfile_set_snapshot(cpfile, cno);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index f02762fa8ea0..1777a3467bd2 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -764,7 +764,7 @@ int nilfs_store_magic_and_option(struct super_block *sb,
764 * @silent: silent mode flag 764 * @silent: silent mode flag
765 * @nilfs: the_nilfs struct 765 * @nilfs: the_nilfs struct
766 * 766 *
767 * This function is called exclusively by bd_mount_mutex. 767 * This function is called exclusively by nilfs->ns_mount_mutex.
768 * So, the recovery process is protected from other simultaneous mounts. 768 * So, the recovery process is protected from other simultaneous mounts.
769 */ 769 */
770static int 770static int
@@ -1105,7 +1105,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
1105 goto failed; 1105 goto failed;
1106 } 1106 }
1107 1107
1108 down(&sd.bdev->bd_mount_sem); 1108 mutex_lock(&nilfs->ns_mount_mutex);
1109 1109
1110 if (!sd.cno) { 1110 if (!sd.cno) {
1111 /* 1111 /*
@@ -1164,7 +1164,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
1164 need_to_close = 0; 1164 need_to_close = 0;
1165 } 1165 }
1166 1166
1167 up(&sd.bdev->bd_mount_sem); 1167 mutex_unlock(&nilfs->ns_mount_mutex);
1168 put_nilfs(nilfs); 1168 put_nilfs(nilfs);
1169 if (need_to_close) 1169 if (need_to_close)
1170 close_bdev_exclusive(sd.bdev, flags); 1170 close_bdev_exclusive(sd.bdev, flags);
@@ -1172,7 +1172,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
1172 return 0; 1172 return 0;
1173 1173
1174 failed_unlock: 1174 failed_unlock:
1175 up(&sd.bdev->bd_mount_sem); 1175 mutex_unlock(&nilfs->ns_mount_mutex);
1176 put_nilfs(nilfs); 1176 put_nilfs(nilfs);
1177 failed: 1177 failed:
1178 close_bdev_exclusive(sd.bdev, flags); 1178 close_bdev_exclusive(sd.bdev, flags);
@@ -1181,14 +1181,14 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
1181 1181
1182 cancel_new: 1182 cancel_new:
1183 /* Abandoning the newly allocated superblock */ 1183 /* Abandoning the newly allocated superblock */
1184 up(&sd.bdev->bd_mount_sem); 1184 mutex_unlock(&nilfs->ns_mount_mutex);
1185 put_nilfs(nilfs); 1185 put_nilfs(nilfs);
1186 up_write(&s->s_umount); 1186 up_write(&s->s_umount);
1187 deactivate_super(s); 1187 deactivate_super(s);
1188 /* 1188 /*
1189 * deactivate_super() invokes close_bdev_exclusive(). 1189 * deactivate_super() invokes close_bdev_exclusive().
1190 * We must finish all post-cleaning before this call; 1190 * We must finish all post-cleaning before this call;
1191 * put_nilfs() and unlocking bd_mount_sem need the block device. 1191 * put_nilfs() needs the block device.
1192 */ 1192 */
1193 return err; 1193 return err;
1194} 1194}
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 06e8dfd538d6..e4e5c78bcc93 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -73,6 +73,7 @@ static struct the_nilfs *alloc_nilfs(struct block_device *bdev)
73 atomic_set(&nilfs->ns_ndirtyblks, 0); 73 atomic_set(&nilfs->ns_ndirtyblks, 0);
74 init_rwsem(&nilfs->ns_sem); 74 init_rwsem(&nilfs->ns_sem);
75 init_rwsem(&nilfs->ns_super_sem); 75 init_rwsem(&nilfs->ns_super_sem);
76 mutex_init(&nilfs->ns_mount_mutex);
76 mutex_init(&nilfs->ns_writer_mutex); 77 mutex_init(&nilfs->ns_writer_mutex);
77 INIT_LIST_HEAD(&nilfs->ns_list); 78 INIT_LIST_HEAD(&nilfs->ns_list);
78 INIT_LIST_HEAD(&nilfs->ns_supers); 79 INIT_LIST_HEAD(&nilfs->ns_supers);
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index d0cf4fb7c9ce..e8adbffc626f 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -49,6 +49,7 @@ enum {
49 * @ns_writer: back pointer to writable nilfs_sb_info 49 * @ns_writer: back pointer to writable nilfs_sb_info
50 * @ns_sem: semaphore for shared states 50 * @ns_sem: semaphore for shared states
51 * @ns_super_sem: semaphore for global operations across super block instances 51 * @ns_super_sem: semaphore for global operations across super block instances
52 * @ns_mount_mutex: mutex protecting mount process of nilfs
52 * @ns_writer_mutex: mutex protecting ns_writer attach/detach 53 * @ns_writer_mutex: mutex protecting ns_writer attach/detach
53 * @ns_writer_refcount: number of referrers on ns_writer 54 * @ns_writer_refcount: number of referrers on ns_writer
54 * @ns_current: back pointer to current mount 55 * @ns_current: back pointer to current mount
@@ -98,6 +99,7 @@ struct the_nilfs {
98 struct nilfs_sb_info *ns_writer; 99 struct nilfs_sb_info *ns_writer;
99 struct rw_semaphore ns_sem; 100 struct rw_semaphore ns_sem;
100 struct rw_semaphore ns_super_sem; 101 struct rw_semaphore ns_super_sem;
102 struct mutex ns_mount_mutex;
101 struct mutex ns_writer_mutex; 103 struct mutex ns_writer_mutex;
102 atomic_t ns_writer_refcount; 104 atomic_t ns_writer_refcount;
103 105