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 <[email protected]>

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 <[email protected]>

                                                                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 <[email protected]>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to