nilfs2: correct exclusion control in nilfs_remount function
nilfs_remount() changes mount state of a superblock instance. Even though nilfs accesses other superblock instances during mount or remount, the mount state was not properly protected in nilfs_remount(). Moreover, nilfs_remount() has a lock order reversal problem; nilfs_get_sb() holds: 1. bdev->bd_mount_sem 2. sb->s_umount (sget acquires) and nilfs_remount() holds: 1. sb->s_umount (locked by the caller in vfs) 2. bdev->bd_mount_sem To avoid these problems, this patch divides a semaphore protecting super block instances from nilfs->ns_sem, and applies it to the mount state protection in nilfs_remount(). With this change, bd_mount_sem use is removed from nilfs_remount() and the lock order reversal will be resolved. And the new rw-semaphore, nilfs->ns_super_sem will properly protect the mount state except the modification from nilfs_error function. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:

committad av
Al Viro

förälder
6dd4740662
incheckning
e59399d010
@@ -48,6 +48,7 @@ enum {
|
||||
* @ns_bdi: backing dev info
|
||||
* @ns_writer: back pointer to writable nilfs_sb_info
|
||||
* @ns_sem: semaphore for shared states
|
||||
* @ns_super_sem: semaphore for global operations across super block instances
|
||||
* @ns_writer_mutex: mutex protecting ns_writer attach/detach
|
||||
* @ns_writer_refcount: number of referrers on ns_writer
|
||||
* @ns_current: back pointer to current mount
|
||||
@@ -96,10 +97,15 @@ struct the_nilfs {
|
||||
struct backing_dev_info *ns_bdi;
|
||||
struct nilfs_sb_info *ns_writer;
|
||||
struct rw_semaphore ns_sem;
|
||||
struct rw_semaphore ns_super_sem;
|
||||
struct mutex ns_writer_mutex;
|
||||
atomic_t ns_writer_refcount;
|
||||
|
||||
/*
|
||||
* components protected by ns_super_sem
|
||||
*/
|
||||
struct nilfs_sb_info *ns_current;
|
||||
struct list_head ns_supers;
|
||||
|
||||
/*
|
||||
* used for
|
||||
@@ -113,7 +119,6 @@ struct the_nilfs {
|
||||
time_t ns_sbwtime[2];
|
||||
unsigned ns_sbsize;
|
||||
unsigned ns_mount_state;
|
||||
struct list_head ns_supers;
|
||||
|
||||
/*
|
||||
* Following fields are dedicated to a writable FS-instance.
|
||||
|
Referens i nytt ärende
Block a user