[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150721084813.GD6533@quack.suse.cz>
Date: Tue, 21 Jul 2015 10:48:13 +0200
From: Jan Kara <jack@...e.cz>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Al Viro <viro@...iv.linux.org.uk>,
Dave Chinner <david@...morbit.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Jan Kara <jack@...e.cz>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] change thaw_super() to re-acquire s_writers.lock_map
On Mon 20-07-15 19:01:09, Oleg Nesterov wrote:
> Change thaw_super() to re-acquire the "write" locks we are going to
> release. This way s_op->unfreeze_fs(sb) is called with these locks
> held as it seen by lockdep, and this matches the reality. This adds
> another trivial helper, sb_freeze_acquire().
>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Ah, I was confused for a moment why this doesn't trigger a lockdep warning
because of lock inversion between s_umount and freeze protection but you
use trylock in sb_freeze_acquire(). So things are fine.
You can add:
Reviewed-by: Jan Kara <jack@...e.com>
Honza
> ---
> fs/super.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index e7ea9f1..b4db3ee 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1263,6 +1263,14 @@ static void sb_freeze_release(struct super_block *sb)
> rwsem_release(sb->s_writers.lock_map + level, 1, _THIS_IP_);
> }
>
> +static void sb_freeze_acquire(struct super_block *sb)
> +{
> + int level;
> +
> + for (level = 0; level < SB_FREEZE_LEVELS; ++level)
> + rwsem_acquire(sb->s_writers.lock_map + level, 0, 1, _THIS_IP_);
> +}
> +
> /**
> * freeze_super - lock the filesystem and force it into a consistent state
> * @sb: the super to lock
> @@ -1386,16 +1394,20 @@ int thaw_super(struct super_block *sb)
> if (sb->s_flags & MS_RDONLY)
> goto out;
>
> + sb_freeze_acquire(sb);
> +
> if (sb->s_op->unfreeze_fs) {
> error = sb->s_op->unfreeze_fs(sb);
> if (error) {
> printk(KERN_ERR
> "VFS:Filesystem thaw failed\n");
> + sb_freeze_release(sb);
> up_write(&sb->s_umount);
> return error;
> }
> }
>
> + sb_freeze_release(sb);
> out:
> sb->s_writers.frozen = SB_UNFROZEN;
> smp_wmb();
> --
> 1.5.5.1
>
--
Jan Kara <jack@...e.cz>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists