Commit fe5f171b authored by Ryusuke Konishi's avatar Ryusuke Konishi

nilfs2: fix potential hang in nilfs_error on errors=remount-ro

nilfs_error() calls nilfs_detach_segment_constructor() if
errors=remount-ro option is specified, and this may lead to a hang due
to recursive locking of, for instance, nilfs->ns_segctor_sem and
others.

In this case, detaching segment constructor is not necessary because
read-only flag is set to the filesystem and further writes are
blocked.

This fixes the potential hang issue by removing the
nilfs_detach_segment_constructor() call from nilfs_error.
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 7512487e
...@@ -2875,8 +2875,15 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi) ...@@ -2875,8 +2875,15 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi)
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = sbi->s_nilfs;
int err; int err;
/* Each field of nilfs_segctor is cleared through the initialization if (NILFS_SC(sbi)) {
of super-block info */ /*
* This happens if the filesystem was remounted
* read/write after nilfs_error degenerated it into a
* read-only mount.
*/
nilfs_detach_segment_constructor(sbi);
}
sbi->s_sc_info = nilfs_segctor_new(sbi); sbi->s_sc_info = nilfs_segctor_new(sbi);
if (!sbi->s_sc_info) if (!sbi->s_sc_info)
return -ENOMEM; return -ENOMEM;
......
...@@ -96,9 +96,6 @@ void nilfs_error(struct super_block *sb, const char *function, ...@@ -96,9 +96,6 @@ void nilfs_error(struct super_block *sb, const char *function,
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
struct the_nilfs *nilfs = sbi->s_nilfs; struct the_nilfs *nilfs = sbi->s_nilfs;
if (!nilfs_test_opt(sbi, ERRORS_CONT))
nilfs_detach_segment_constructor(sbi);
down_write(&nilfs->ns_sem); down_write(&nilfs->ns_sem);
if (!(nilfs->ns_mount_state & NILFS_ERROR_FS)) { if (!(nilfs->ns_mount_state & NILFS_ERROR_FS)) {
nilfs->ns_mount_state |= NILFS_ERROR_FS; nilfs->ns_mount_state |= NILFS_ERROR_FS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment