[RHEL7,COMMIT] nfs: skip bdi_unregister() if inodes are leaked.

Submitted by Konstantin Khorenko on Aug. 6, 2019, 9:35 a.m.

Details

Message ID 201908060935.x769ZjD2004115@finist-ce7.sw.ru
State New
Series "nfs: skip bdi_unregister() if inodes are leaked."
Headers show

Commit Message

Konstantin Khorenko Aug. 6, 2019, 9:35 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.7
------>
commit 160e886e8adc095ac9f01420f66962732ee9683d
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Tue Aug 6 12:35:45 2019 +0300

    nfs: skip bdi_unregister() if inodes are leaked.
    
    https://jira.sw.ru/browse/PSBM-95177
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/nfs/super.c | 3 +++
 fs/super.c     | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 64b52b7188c9..f9c0a02c25af 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2711,6 +2711,9 @@  void nfs_put_super(struct super_block *s)
 {
 	struct nfs_server *server = NFS_SB(s);
 
+	if (!list_empty(&s->s_inodes))
+		pr_err("nfs_put_super: busy inodes skip bdi_unregister\n");
+
 	bdi_unregister(&server->backing_dev_info);
 }
 EXPORT_SYMBOL_GPL(nfs_put_super);
diff --git a/fs/super.c b/fs/super.c
index f131d14587ca..e5551b8462a8 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1046,7 +1046,8 @@  void kill_anon_super(struct super_block *sb)
 {
 	dev_t dev = sb->s_dev;
 	generic_shutdown_super(sb);
-	free_anon_bdev(dev);
+	if (!list_empty(&sb->s_inodes))
+		free_anon_bdev(dev);
 }
 
 EXPORT_SYMBOL(kill_anon_super);

Comments

Evgenii Shatokhin Sept. 29, 2019, 10:51 a.m.
On 06.08.2019 12:35, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-957.21.3.vz7.106.7
> ------>
> commit 160e886e8adc095ac9f01420f66962732ee9683d
> Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Date:   Tue Aug 6 12:35:45 2019 +0300
> 
>      nfs: skip bdi_unregister() if inodes are leaked.
>      
>      https://jira.sw.ru/browse/PSBM-95177
>      Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>   fs/nfs/super.c | 3 +++
>   fs/super.c     | 3 ++-
>   2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 64b52b7188c9..f9c0a02c25af 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -2711,6 +2711,9 @@ void nfs_put_super(struct super_block *s)
>   {
>   	struct nfs_server *server = NFS_SB(s);
>   
> +	if (!list_empty(&s->s_inodes))
> +		pr_err("nfs_put_super: busy inodes skip bdi_unregister\n");
> +
>   	bdi_unregister(&server->backing_dev_info);
>   }

Looks like bdi_unregister() will still be called even if the list 
s->s_inodes is not empty. Shouldn't it be like this:

  +	if (!list_empty(&s->s_inodes)) {
  +		pr_err("nfs_put_super: busy inodes skip bdi_unregister\n");
  +              return;
  +      }
  +
    	bdi_unregister(&server->backing_dev_info);

?

>   EXPORT_SYMBOL_GPL(nfs_put_super);
> diff --git a/fs/super.c b/fs/super.c
> index f131d14587ca..e5551b8462a8 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1046,7 +1046,8 @@ void kill_anon_super(struct super_block *sb)
>   {
>   	dev_t dev = sb->s_dev;
>   	generic_shutdown_super(sb);
> -	free_anon_bdev(dev);
> +	if (!list_empty(&sb->s_inodes))
> +		free_anon_bdev(dev);
>   }
>   
>   EXPORT_SYMBOL(kill_anon_super);
> 
> _______________________________________________
> Devel mailing list
> Devel@openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
> .
>
Evgenii Shatokhin Sept. 29, 2019, 12:22 p.m.
On 06.08.2019 12:35, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-957.21.3.vz7.106.7
> ------>
> commit 160e886e8adc095ac9f01420f66962732ee9683d
> Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Date:   Tue Aug 6 12:35:45 2019 +0300
> 
>      nfs: skip bdi_unregister() if inodes are leaked.
>      
>      https://jira.sw.ru/browse/PSBM-95177
>      Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>   fs/nfs/super.c | 3 +++
>   fs/super.c     | 3 ++-
>   2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 64b52b7188c9..f9c0a02c25af 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -2711,6 +2711,9 @@ void nfs_put_super(struct super_block *s)
>   {
>   	struct nfs_server *server = NFS_SB(s);
>   
> +	if (!list_empty(&s->s_inodes))
> +		pr_err("nfs_put_super: busy inodes skip bdi_unregister\n");
> +
>   	bdi_unregister(&server->backing_dev_info);
>   }
>   EXPORT_SYMBOL_GPL(nfs_put_super);
> diff --git a/fs/super.c b/fs/super.c
> index f131d14587ca..e5551b8462a8 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1046,7 +1046,8 @@ void kill_anon_super(struct super_block *sb)
>   {
>   	dev_t dev = sb->s_dev;
>   	generic_shutdown_super(sb);
> -	free_anon_bdev(dev);
> +	if (!list_empty(&sb->s_inodes))
> +		free_anon_bdev(dev);
>   }

I do not understand this part. free_anon_bdev(dev) will be called here 
only if there are leaked inodes (!list_empty(&sb->s_inodes) is true).

Perhaps, the intention was to call free_anon_bdev(dev) only if there are 
*no* leaked inodes instead? Or?

>   
>   EXPORT_SYMBOL(kill_anon_super);
> 
> _______________________________________________
> Devel mailing list
> Devel@openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
> .
>