All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: nfsd: make destory function more elegant
@ 2022-06-02  5:56 Dongliang Mu
  2022-06-02 14:30 ` [PATCH] " Chuck Lever III
  0 siblings, 1 reply; 4+ messages in thread
From: Dongliang Mu @ 2022-06-02  5:56 UTC (permalink / raw)
  To: Chuck Lever; +Cc: Dongliang Mu, linux-nfs, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

In init_nfsd, the undo operation of create_proc_exports_entry is:

        remove_proc_entry("fs/nfs/exports", NULL);
        remove_proc_entry("fs/nfs", NULL);

This may lead to maintaince issue. Declare the undo function
destroy_proc_exports_entry based on CONFIG_PROC_FS

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 fs/nfsd/nfsctl.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 0621c2faf242..83b34ccbef5a 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void)
 	}
 	return 0;
 }
+
+static void destroy_proc_exports_entry(void)
+{
+	remove_proc_entry("fs/nfs/exports", NULL);
+	remove_proc_entry("fs/nfs", NULL);
+}
 #else /* CONFIG_PROC_FS */
 static int create_proc_exports_entry(void)
 {
 	return 0;
 }
+
+static void destroy_proc_exports_entry(void)
+{
+}
 #endif
 
 unsigned int nfsd_net_id;
@@ -1555,8 +1565,7 @@ static int __init init_nfsd(void)
 out_free_subsys:
 	unregister_pernet_subsys(&nfsd_net_ops);
 out_free_exports:
-	remove_proc_entry("fs/nfs/exports", NULL);
-	remove_proc_entry("fs/nfs", NULL);
+	destroy_proc_exports_entry();
 out_free_lockd:
 	nfsd_lockd_shutdown();
 	nfsd_drc_slab_free();
@@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void)
 	unregister_cld_notifier();
 	unregister_pernet_subsys(&nfsd_net_ops);
 	nfsd_drc_slab_free();
-	remove_proc_entry("fs/nfs/exports", NULL);
-	remove_proc_entry("fs/nfs", NULL);
+	destroy_proc_exports_entry();
 	nfsd_stat_shutdown();
 	nfsd_lockd_shutdown();
 	nfsd4_free_slabs();
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd: make destory function more elegant
  2022-06-02  5:56 [PATCH] fs: nfsd: make destory function more elegant Dongliang Mu
@ 2022-06-02 14:30 ` Chuck Lever III
  2022-06-03 13:50   ` Dongliang Mu
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever III @ 2022-06-02 14:30 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: Dongliang Mu, Linux NFS Mailing List, linux-kernel



> On Jun 2, 2022, at 1:56 AM, Dongliang Mu <dzm91@hust.edu.cn> wrote:
> 
> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> In init_nfsd, the undo operation of create_proc_exports_entry is:
> 
>        remove_proc_entry("fs/nfs/exports", NULL);
>        remove_proc_entry("fs/nfs", NULL);
> 
> This may lead to maintaince issue. Declare the undo function

"maintenance"


> destroy_proc_exports_entry based on CONFIG_PROC_FS

IIUC, the issue is that if CONFIG_PROC_FS is not set,
fs/nfsd/nfsctl.c fails to compile?


> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> fs/nfsd/nfsctl.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 0621c2faf242..83b34ccbef5a 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void)
> 	}
> 	return 0;
> }
> +
> +static void destroy_proc_exports_entry(void)
> +{
> +	remove_proc_entry("fs/nfs/exports", NULL);
> +	remove_proc_entry("fs/nfs", NULL);
> +}
> #else /* CONFIG_PROC_FS */
> static int create_proc_exports_entry(void)
> {
> 	return 0;
> }
> +
> +static void destroy_proc_exports_entry(void)
> +{
> +}
> #endif
> 
> unsigned int nfsd_net_id;
> @@ -1555,8 +1565,7 @@ static int __init init_nfsd(void)
> out_free_subsys:
> 	unregister_pernet_subsys(&nfsd_net_ops);
> out_free_exports:
> -	remove_proc_entry("fs/nfs/exports", NULL);
> -	remove_proc_entry("fs/nfs", NULL);
> +	destroy_proc_exports_entry();
> out_free_lockd:
> 	nfsd_lockd_shutdown();
> 	nfsd_drc_slab_free();
> @@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void)
> 	unregister_cld_notifier();
> 	unregister_pernet_subsys(&nfsd_net_ops);
> 	nfsd_drc_slab_free();
> -	remove_proc_entry("fs/nfs/exports", NULL);
> -	remove_proc_entry("fs/nfs", NULL);
> +	destroy_proc_exports_entry();
> 	nfsd_stat_shutdown();
> 	nfsd_lockd_shutdown();
> 	nfsd4_free_slabs();
> -- 
> 2.25.1
> 

--
Chuck Lever




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd: make destory function more elegant
  2022-06-02 14:30 ` [PATCH] " Chuck Lever III
@ 2022-06-03 13:50   ` Dongliang Mu
  2022-06-03 14:02     ` Chuck Lever III
  0 siblings, 1 reply; 4+ messages in thread
From: Dongliang Mu @ 2022-06-03 13:50 UTC (permalink / raw)
  To: Chuck Lever III; +Cc: Dongliang Mu, Linux NFS Mailing List, linux-kernel

On Thu, Jun 2, 2022 at 10:30 PM Chuck Lever III <chuck.lever@oracle.com> wrote:
>
>
>
> > On Jun 2, 2022, at 1:56 AM, Dongliang Mu <dzm91@hust.edu.cn> wrote:
> >
> > From: Dongliang Mu <mudongliangabcd@gmail.com>
> >
> > In init_nfsd, the undo operation of create_proc_exports_entry is:
> >
> >        remove_proc_entry("fs/nfs/exports", NULL);
> >        remove_proc_entry("fs/nfs", NULL);
> >
> > This may lead to maintaince issue. Declare the undo function
>
> "maintenance"

Sorry for the typo.

>
>
> > destroy_proc_exports_entry based on CONFIG_PROC_FS
>
> IIUC, the issue is that if CONFIG_PROC_FS is not set,
> fs/nfsd/nfsctl.c fails to compile?

The answer is no. There is no bug in the code.

At first, I thought this might cause the miscompilation or bug. But
actually the code is fine.

Because remove_proc_entry is defined as an empty function if
CONFIG_PROC_FS is not set,

>
>
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > ---
> > fs/nfsd/nfsctl.c | 16 ++++++++++++----
> > 1 file changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> > index 0621c2faf242..83b34ccbef5a 100644
> > --- a/fs/nfsd/nfsctl.c
> > +++ b/fs/nfsd/nfsctl.c
> > @@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void)
> >       }
> >       return 0;
> > }
> > +
> > +static void destroy_proc_exports_entry(void)
> > +{
> > +     remove_proc_entry("fs/nfs/exports", NULL);
> > +     remove_proc_entry("fs/nfs", NULL);
> > +}
> > #else /* CONFIG_PROC_FS */
> > static int create_proc_exports_entry(void)
> > {
> >       return 0;
> > }
> > +
> > +static void destroy_proc_exports_entry(void)
> > +{
> > +}
> > #endif
> >
> > unsigned int nfsd_net_id;
> > @@ -1555,8 +1565,7 @@ static int __init init_nfsd(void)
> > out_free_subsys:
> >       unregister_pernet_subsys(&nfsd_net_ops);
> > out_free_exports:
> > -     remove_proc_entry("fs/nfs/exports", NULL);
> > -     remove_proc_entry("fs/nfs", NULL);
> > +     destroy_proc_exports_entry();
> > out_free_lockd:
> >       nfsd_lockd_shutdown();
> >       nfsd_drc_slab_free();
> > @@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void)
> >       unregister_cld_notifier();
> >       unregister_pernet_subsys(&nfsd_net_ops);
> >       nfsd_drc_slab_free();
> > -     remove_proc_entry("fs/nfs/exports", NULL);
> > -     remove_proc_entry("fs/nfs", NULL);
> > +     destroy_proc_exports_entry();
> >       nfsd_stat_shutdown();
> >       nfsd_lockd_shutdown();
> >       nfsd4_free_slabs();
> > --
> > 2.25.1
> >
>
> --
> Chuck Lever
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd: make destory function more elegant
  2022-06-03 13:50   ` Dongliang Mu
@ 2022-06-03 14:02     ` Chuck Lever III
  0 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever III @ 2022-06-03 14:02 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: Dongliang Mu, Linux NFS Mailing List, linux-kernel



> On Jun 3, 2022, at 9:50 AM, Dongliang Mu <mudongliangabcd@gmail.com> wrote:
> 
> On Thu, Jun 2, 2022 at 10:30 PM Chuck Lever III <chuck.lever@oracle.com> wrote:
>> 
>> 
>> 
>>> On Jun 2, 2022, at 1:56 AM, Dongliang Mu <dzm91@hust.edu.cn> wrote:
>>> 
>>> From: Dongliang Mu <mudongliangabcd@gmail.com>
>>> 
>>> In init_nfsd, the undo operation of create_proc_exports_entry is:
>>> 
>>>       remove_proc_entry("fs/nfs/exports", NULL);
>>>       remove_proc_entry("fs/nfs", NULL);
>>> 
>>> This may lead to maintaince issue. Declare the undo function
>> 
>> "maintenance"
> 
> Sorry for the typo.
> 
>> 
>> 
>>> destroy_proc_exports_entry based on CONFIG_PROC_FS
>> 
>> IIUC, the issue is that if CONFIG_PROC_FS is not set,
>> fs/nfsd/nfsctl.c fails to compile?
> 
> The answer is no. There is no bug in the code.
> 
> At first, I thought this might cause the miscompilation or bug. But
> actually the code is fine.
> 
> Because remove_proc_entry is defined as an empty function if
> CONFIG_PROC_FS is not set,

Code inspection does suggest there could be a problem,
but I'm glad there isn't one. I can drop this one.


>>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>>> ---
>>> fs/nfsd/nfsctl.c | 16 ++++++++++++----
>>> 1 file changed, 12 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
>>> index 0621c2faf242..83b34ccbef5a 100644
>>> --- a/fs/nfsd/nfsctl.c
>>> +++ b/fs/nfsd/nfsctl.c
>>> @@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void)
>>>      }
>>>      return 0;
>>> }
>>> +
>>> +static void destroy_proc_exports_entry(void)
>>> +{
>>> +     remove_proc_entry("fs/nfs/exports", NULL);
>>> +     remove_proc_entry("fs/nfs", NULL);
>>> +}
>>> #else /* CONFIG_PROC_FS */
>>> static int create_proc_exports_entry(void)
>>> {
>>>      return 0;
>>> }
>>> +
>>> +static void destroy_proc_exports_entry(void)
>>> +{
>>> +}
>>> #endif
>>> 
>>> unsigned int nfsd_net_id;
>>> @@ -1555,8 +1565,7 @@ static int __init init_nfsd(void)
>>> out_free_subsys:
>>>      unregister_pernet_subsys(&nfsd_net_ops);
>>> out_free_exports:
>>> -     remove_proc_entry("fs/nfs/exports", NULL);
>>> -     remove_proc_entry("fs/nfs", NULL);
>>> +     destroy_proc_exports_entry();
>>> out_free_lockd:
>>>      nfsd_lockd_shutdown();
>>>      nfsd_drc_slab_free();
>>> @@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void)
>>>      unregister_cld_notifier();
>>>      unregister_pernet_subsys(&nfsd_net_ops);
>>>      nfsd_drc_slab_free();
>>> -     remove_proc_entry("fs/nfs/exports", NULL);
>>> -     remove_proc_entry("fs/nfs", NULL);
>>> +     destroy_proc_exports_entry();
>>>      nfsd_stat_shutdown();
>>>      nfsd_lockd_shutdown();
>>>      nfsd4_free_slabs();
>>> --
>>> 2.25.1
>>> 
>> 
>> --
>> Chuck Lever

--
Chuck Lever




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-03 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  5:56 [PATCH] fs: nfsd: make destory function more elegant Dongliang Mu
2022-06-02 14:30 ` [PATCH] " Chuck Lever III
2022-06-03 13:50   ` Dongliang Mu
2022-06-03 14:02     ` Chuck Lever III

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.