linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe
@ 2011-12-14 19:39 bjschuma
  2011-12-14 20:50 ` Casey Bodley
  0 siblings, 1 reply; 4+ messages in thread
From: bjschuma @ 2011-12-14 19:39 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs, cbodley, Bryan Schumaker

From: Bryan Schumaker <bjschuma@netapp.com>

Otherwise the for loop could try to use a file recently removed from the
file_hashtbl list and oops.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
 fs/nfsd/nfs4state.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 19ca9b5..7355fe4 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4505,18 +4505,19 @@ void nfsd_forget_openowners(u64 num)
 int nfsd_process_n_delegations(u64 num, void (*deleg_func)(struct nfs4_delegation *))
 {
 	int i, count = 0;
-	struct nfs4_file *fp;
-	struct nfs4_delegation *dp, *next;
+	struct nfs4_file *fp, *fnext;
+	struct nfs4_delegation *dp, *dnext;
 
 	for (i = 0; i < FILE_HASH_SIZE; i++) {
-		list_for_each_entry(fp, &file_hashtbl[i], fi_hash) {
-			list_for_each_entry_safe(dp, next, &fp->fi_delegations, dl_perfile) {
+		list_for_each_entry_safe(fp, fnext, &file_hashtbl[i], fi_hash) {
+			list_for_each_entry_safe(dp, dnext, &fp->fi_delegations, dl_perfile) {
 				deleg_func(dp);
 				if (++count == num)
 					return count;
 			}
 		}
 	}
+
 	return count;
 }
 
-- 
1.7.8


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

* Re: [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe
  2011-12-14 19:39 [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe bjschuma
@ 2011-12-14 20:50 ` Casey Bodley
  2011-12-14 21:11   ` Bryan Schumaker
  2011-12-14 22:38   ` J. Bruce Fields
  0 siblings, 2 replies; 4+ messages in thread
From: Casey Bodley @ 2011-12-14 20:50 UTC (permalink / raw)
  To: bjschuma; +Cc: bfields, linux-nfs

On Wed, Dec 14, 2011 at 2:39 PM,  <bjschuma@netapp.com> wrote:
> From: Bryan Schumaker <bjschuma@netapp.com>
>
> Otherwise the for loop could try to use a file recently removed from the
> file_hashtbl list and oops.
>
> Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
> ---
>  fs/nfsd/nfs4state.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 19ca9b5..7355fe4 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4505,18 +4505,19 @@ void nfsd_forget_openowners(u64 num)
>  int nfsd_process_n_delegations(u64 num, void (*deleg_func)(struct nfs4_delegation *))
>  {
>        int i, count = 0;
> -       struct nfs4_file *fp;
> -       struct nfs4_delegation *dp, *next;
> +       struct nfs4_file *fp, *fnext;
> +       struct nfs4_delegation *dp, *dnext;
>
>        for (i = 0; i < FILE_HASH_SIZE; i++) {
> -               list_for_each_entry(fp, &file_hashtbl[i], fi_hash) {
> -                       list_for_each_entry_safe(dp, next, &fp->fi_delegations, dl_perfile) {
> +               list_for_each_entry_safe(fp, fnext, &file_hashtbl[i], fi_hash) {
> +                       list_for_each_entry_safe(dp, dnext, &fp->fi_delegations, dl_perfile) {
>                                deleg_func(dp);
>                                if (++count == num)
>                                        return count;
>                        }
>                }
>        }
> +
>        return count;
>  }
>
> --
> 1.7.8
>

Confirmed to fix the oops I was getting with fault injection. (tested
without the previous patch, NFSD: Only reinitilize the recall_lru list
under the recall lock)

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

* Re: [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe
  2011-12-14 20:50 ` Casey Bodley
@ 2011-12-14 21:11   ` Bryan Schumaker
  2011-12-14 22:38   ` J. Bruce Fields
  1 sibling, 0 replies; 4+ messages in thread
From: Bryan Schumaker @ 2011-12-14 21:11 UTC (permalink / raw)
  To: Casey Bodley; +Cc: bfields, linux-nfs

On Wed Dec 14 15:50:53 2011, Casey Bodley wrote:
> On Wed, Dec 14, 2011 at 2:39 PM,  <bjschuma@netapp.com> wrote:
>> From: Bryan Schumaker <bjschuma@netapp.com>
>>
>> Otherwise the for loop could try to use a file recently removed from the
>> file_hashtbl list and oops.
>>
>> Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
>> ---
>>  fs/nfsd/nfs4state.c |    9 +++++----
>>  1 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
>> index 19ca9b5..7355fe4 100644
>> --- a/fs/nfsd/nfs4state.c
>> +++ b/fs/nfsd/nfs4state.c
>> @@ -4505,18 +4505,19 @@ void nfsd_forget_openowners(u64 num)
>>  int nfsd_process_n_delegations(u64 num, void (*deleg_func)(struct nfs4_delegation *))
>>  {
>>        int i, count = 0;
>> -       struct nfs4_file *fp;
>> -       struct nfs4_delegation *dp, *next;
>> +       struct nfs4_file *fp, *fnext;
>> +       struct nfs4_delegation *dp, *dnext;
>>
>>        for (i = 0; i < FILE_HASH_SIZE; i++) {
>> -               list_for_each_entry(fp, &file_hashtbl[i], fi_hash) {
>> -                       list_for_each_entry_safe(dp, next, &fp->fi_delegations, dl_perfile) {
>> +               list_for_each_entry_safe(fp, fnext, &file_hashtbl[i], fi_hash) {
>> +                       list_for_each_entry_safe(dp, dnext, &fp->fi_delegations, dl_perfile) {
>>                                deleg_func(dp);
>>                                if (++count == num)
>>                                        return count;
>>                        }
>>                }
>>        }
>> +
>>        return count;
>>  }
>>
>> --
>> 1.7.8
>>
>
> Confirmed to fix the oops I was getting with fault injection. (tested
> without the previous patch, NFSD: Only reinitilize the recall_lru list
> under the recall lock)

Thanks for testing!

- Bryan

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

* Re: [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe
  2011-12-14 20:50 ` Casey Bodley
  2011-12-14 21:11   ` Bryan Schumaker
@ 2011-12-14 22:38   ` J. Bruce Fields
  1 sibling, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2011-12-14 22:38 UTC (permalink / raw)
  To: Casey Bodley; +Cc: bjschuma, linux-nfs

On Wed, Dec 14, 2011 at 03:50:53PM -0500, Casey Bodley wrote:
> On Wed, Dec 14, 2011 at 2:39 PM,  <bjschuma@netapp.com> wrote:
> > From: Bryan Schumaker <bjschuma@netapp.com>
> >
> > Otherwise the for loop could try to use a file recently removed from the
> > file_hashtbl list and oops.
> >
> > Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
> > ---
> >  fs/nfsd/nfs4state.c |    9 +++++----
> >  1 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index 19ca9b5..7355fe4 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -4505,18 +4505,19 @@ void nfsd_forget_openowners(u64 num)
> >  int nfsd_process_n_delegations(u64 num, void (*deleg_func)(struct nfs4_delegation *))
> >  {
> >        int i, count = 0;
> > -       struct nfs4_file *fp;
> > -       struct nfs4_delegation *dp, *next;
> > +       struct nfs4_file *fp, *fnext;
> > +       struct nfs4_delegation *dp, *dnext;
> >
> >        for (i = 0; i < FILE_HASH_SIZE; i++) {
> > -               list_for_each_entry(fp, &file_hashtbl[i], fi_hash) {
> > -                       list_for_each_entry_safe(dp, next, &fp->fi_delegations, dl_perfile) {
> > +               list_for_each_entry_safe(fp, fnext, &file_hashtbl[i], fi_hash) {
> > +                       list_for_each_entry_safe(dp, dnext, &fp->fi_delegations, dl_perfile) {
> >                                deleg_func(dp);
> >                                if (++count == num)
> >                                        return count;
> >                        }
> >                }
> >        }
> > +
> >        return count;
> >  }
> >
> > --
> > 1.7.8
> >
> 
> Confirmed to fix the oops I was getting with fault injection. (tested
> without the previous patch, NFSD: Only reinitilize the recall_lru list
> under the recall lock)

Ah-hah.  Thanks Bryan, and Casey--committed.

--b.

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

end of thread, other threads:[~2011-12-14 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-14 19:39 [PATCH] NFSD: forget_delegations should use list_for_each_entry_safe bjschuma
2011-12-14 20:50 ` Casey Bodley
2011-12-14 21:11   ` Bryan Schumaker
2011-12-14 22:38   ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).