Re: [PATCH] [2.6] reiserfs: fix locking in reiserfs_remount

Andrew Morton
2003-08-07T15:22:50Z

Oleg Drokin <green@namesys.com> wrote:
>
> Hello!
>
> On Thu, Aug 07, 2003 at 05:24:43PM +0400, Hans Reiser wrote:
>
> > >Reiserfs needs BKL for it's journal operations. This is not "more",
> > >for some time BKL was taken in the VFS, then whoever removed that,
> > >forgot to propagate BKL down to actual fs methods that need the BKL.
> > Is it known who removed it?
>
> I think it was Andrew. At least this new emergency remount path without
> BKL was introduced by his patch without any extra attribution.

Is that the only path? It appears that way to me.

The Locking document says that ->remoutn_fs is called under lock_kernel(),
so this should be fixed at the VFS level.

fs/super.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletion(-)

diff -puN fs/super.c~remount_fs-lock_kernel fs/super.c
--- 25/fs/super.c~remount_fs-lock_kernel 2003-08-07 08:17:38.000000000 -0700
+++ 25-akpm/fs/super.c 2003-08-07 08:23:42.000000000 -0700
@@ -507,8 +507,16 @@ static void do_emergency_remount(unsigne
sb->s_count++;
spin_unlock(&sb_lock);
down_read(&sb->s_umount);
- if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY))
+ if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) {
+ /*
+ * ->remount_fs needs lock_kernel().
+ *
+ * What lock protects sb->s_flags??
+ */
+ lock_kernel();
do_remount_sb(sb, MS_RDONLY, NULL, 1);
+ unlock_kernel();
+ }
drop_super(sb);
spin_lock(&sb_lock);
}

_