提交 aa7dfb89 编写于 作者: R Ryusuke Konishi 提交者: Al Viro

nilfs2: get rid of bd_mount_sem use from nilfs

This will remove every bd_mount_sem use in nilfs.

The intended exclusion control was replaced by the previous patch
("nilfs2: correct exclusion control in nilfs_remount function") for
nilfs_remount(), and this patch will replace remains with a new mutex
that this inserts in nilfs object.
Signed-off-by: NRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 e59399d0
...@@ -864,11 +864,11 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode) ...@@ -864,11 +864,11 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
case NILFS_CHECKPOINT: case NILFS_CHECKPOINT:
/* /*
* Check for protecting existing snapshot mounts: * Check for protecting existing snapshot mounts:
* bd_mount_sem is used to make this operation atomic and * ns_mount_mutex is used to make this operation atomic and
* exclusive with a new mount job. Though it doesn't cover * exclusive with a new mount job. Though it doesn't cover
* umount, it's enough for the purpose. * umount, it's enough for the purpose.
*/ */
down(&nilfs->ns_bdev->bd_mount_sem); mutex_lock(&nilfs->ns_mount_mutex);
if (nilfs_checkpoint_is_mounted(nilfs, cno, 1)) { if (nilfs_checkpoint_is_mounted(nilfs, cno, 1)) {
/* Current implementation does not have to protect /* Current implementation does not have to protect
plain read-only mounts since they are exclusive 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,7 +877,7 @@ int nilfs_cpfile_change_cpmode(struct inode *cpfile, __u64 cno, int mode)
ret = -EBUSY; ret = -EBUSY;
} else } else
ret = nilfs_cpfile_clear_snapshot(cpfile, cno); ret = nilfs_cpfile_clear_snapshot(cpfile, cno);
up(&nilfs->ns_bdev->bd_mount_sem); mutex_unlock(&nilfs->ns_mount_mutex);
return ret; return ret;
case NILFS_SNAPSHOT: case NILFS_SNAPSHOT:
return nilfs_cpfile_set_snapshot(cpfile, cno); return nilfs_cpfile_set_snapshot(cpfile, cno);
......
...@@ -764,7 +764,7 @@ int nilfs_store_magic_and_option(struct super_block *sb, ...@@ -764,7 +764,7 @@ int nilfs_store_magic_and_option(struct super_block *sb,
* @silent: silent mode flag * @silent: silent mode flag
* @nilfs: the_nilfs struct * @nilfs: the_nilfs struct
* *
* This function is called exclusively by bd_mount_mutex. * This function is called exclusively by nilfs->ns_mount_mutex.
* So, the recovery process is protected from other simultaneous mounts. * So, the recovery process is protected from other simultaneous mounts.
*/ */
static int static int
...@@ -1105,7 +1105,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -1105,7 +1105,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
goto failed; goto failed;
} }
down(&sd.bdev->bd_mount_sem); mutex_lock(&nilfs->ns_mount_mutex);
if (!sd.cno) { if (!sd.cno) {
/* /*
...@@ -1164,7 +1164,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -1164,7 +1164,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
need_to_close = 0; need_to_close = 0;
} }
up(&sd.bdev->bd_mount_sem); mutex_unlock(&nilfs->ns_mount_mutex);
put_nilfs(nilfs); put_nilfs(nilfs);
if (need_to_close) if (need_to_close)
close_bdev_exclusive(sd.bdev, flags); close_bdev_exclusive(sd.bdev, flags);
...@@ -1172,7 +1172,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -1172,7 +1172,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
return 0; return 0;
failed_unlock: failed_unlock:
up(&sd.bdev->bd_mount_sem); mutex_unlock(&nilfs->ns_mount_mutex);
put_nilfs(nilfs); put_nilfs(nilfs);
failed: failed:
close_bdev_exclusive(sd.bdev, flags); close_bdev_exclusive(sd.bdev, flags);
...@@ -1181,14 +1181,14 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -1181,14 +1181,14 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
cancel_new: cancel_new:
/* Abandoning the newly allocated superblock */ /* Abandoning the newly allocated superblock */
up(&sd.bdev->bd_mount_sem); mutex_unlock(&nilfs->ns_mount_mutex);
put_nilfs(nilfs); put_nilfs(nilfs);
up_write(&s->s_umount); up_write(&s->s_umount);
deactivate_super(s); deactivate_super(s);
/* /*
* deactivate_super() invokes close_bdev_exclusive(). * deactivate_super() invokes close_bdev_exclusive().
* We must finish all post-cleaning before this call; * We must finish all post-cleaning before this call;
* put_nilfs() and unlocking bd_mount_sem need the block device. * put_nilfs() needs the block device.
*/ */
return err; return err;
} }
......
...@@ -73,6 +73,7 @@ static struct the_nilfs *alloc_nilfs(struct block_device *bdev) ...@@ -73,6 +73,7 @@ static struct the_nilfs *alloc_nilfs(struct block_device *bdev)
atomic_set(&nilfs->ns_ndirtyblks, 0); atomic_set(&nilfs->ns_ndirtyblks, 0);
init_rwsem(&nilfs->ns_sem); init_rwsem(&nilfs->ns_sem);
init_rwsem(&nilfs->ns_super_sem); init_rwsem(&nilfs->ns_super_sem);
mutex_init(&nilfs->ns_mount_mutex);
mutex_init(&nilfs->ns_writer_mutex); mutex_init(&nilfs->ns_writer_mutex);
INIT_LIST_HEAD(&nilfs->ns_list); INIT_LIST_HEAD(&nilfs->ns_list);
INIT_LIST_HEAD(&nilfs->ns_supers); INIT_LIST_HEAD(&nilfs->ns_supers);
......
...@@ -49,6 +49,7 @@ enum { ...@@ -49,6 +49,7 @@ enum {
* @ns_writer: back pointer to writable nilfs_sb_info * @ns_writer: back pointer to writable nilfs_sb_info
* @ns_sem: semaphore for shared states * @ns_sem: semaphore for shared states
* @ns_super_sem: semaphore for global operations across super block instances * @ns_super_sem: semaphore for global operations across super block instances
* @ns_mount_mutex: mutex protecting mount process of nilfs
* @ns_writer_mutex: mutex protecting ns_writer attach/detach * @ns_writer_mutex: mutex protecting ns_writer attach/detach
* @ns_writer_refcount: number of referrers on ns_writer * @ns_writer_refcount: number of referrers on ns_writer
* @ns_current: back pointer to current mount * @ns_current: back pointer to current mount
...@@ -98,6 +99,7 @@ struct the_nilfs { ...@@ -98,6 +99,7 @@ struct the_nilfs {
struct nilfs_sb_info *ns_writer; struct nilfs_sb_info *ns_writer;
struct rw_semaphore ns_sem; struct rw_semaphore ns_sem;
struct rw_semaphore ns_super_sem; struct rw_semaphore ns_super_sem;
struct mutex ns_mount_mutex;
struct mutex ns_writer_mutex; struct mutex ns_writer_mutex;
atomic_t ns_writer_refcount; atomic_t ns_writer_refcount;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册