On 9/15/22 8:42 PM, Jia Zhu wrote:

> @@ -502,12 +493,19 @@ int erofs_fscache_register_fs(struct super_block *sb)
>       volume = fscache_acquire_volume(name, NULL, NULL, 0);
>       if (IS_ERR_OR_NULL(volume)) {
>               erofs_err(sb, "failed to register volume for %s", name);
> -             ret = volume ? PTR_ERR(volume) : -EOPNOTSUPP;
> -             volume = NULL;
> +             kfree(name);
> +             return volume ? PTR_ERR(volume) : -EOPNOTSUPP;
>       }
>  
>       sbi->volume = volume;
>       kfree(name);
> +
> +     fscache = erofs_fscache_register_cookie(sb, sbi->opt.fsid, true);
> +     /* acquired volume will be relinquished in kill_sb() */
> +     if (IS_ERR(fscache))
> +             return PTR_ERR(fscache);
> +
> +     sbi->s_fscache = fscache;
>       return ret;

The local variable "ret" is not used in this case.


> @@ -889,7 +885,6 @@ static void erofs_kill_sb(struct super_block *sb)
>  
>       erofs_free_dev_context(sbi->devs);
>       fs_put_dax(sbi->dax_dev, NULL);
> -     erofs_fscache_unregister_cookie(&sbi->s_fscache);
>       erofs_fscache_unregister_fs(sb);
>       kfree(sbi->opt.fsid);
>       kfree(sbi);
> @@ -909,7 +904,8 @@ static void erofs_put_super(struct super_block *sb)
>       iput(sbi->managed_cache);
>       sbi->managed_cache = NULL;
>  #endif
> -     erofs_fscache_unregister_cookie(&sbi->s_fscache);
> +     erofs_fscache_unregister_fs(sb);

> +     sbi->s_fscache = NULL;

This line is not needed since we already call
erofs_fscache_unregister_fs() here.


With these fixed:
Reviewed-by: Jingbo Xu <[email protected]>

-- 
Thanks,
Jingbo

Reply via email to