NFSD: forget_delegations should use list_for_each_entry_safe
Subsystems (2)
PATCH 1/1 NFSD: forget_delegations should use list_for_each_entry_safe
From: Bryan Schumaker <[email protected]>
Otherwise the for loop could try to use a file recently removed from the file_hashtbl list and oops.
--- fs/nfsd/nfs4state.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c +5 -4
@@ -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; }
Signature · 1 line
1.7.8
Quoted 39 lines · On Wed, Dec 14, 2011 at 2:39 PM, <[email protected]> wrote:
From: Bryan Schumaker <[email protected]>
Otherwise the for loop could try to use a file recently removed from the
file_hashtbllist and oops.Signed-off-by Bryan Schumaker <[email protected]>---
fs/nfsd/nfs4state.c | 9 +++++----1 files changed, 5 insertions(+), 4 deletions(-)fs/nfsd/nfs4state.c +5
-5@@ -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; } --
Quoted 2 lines
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)
Quoted 39 lines · Casey Bodley
Quoted 38 lines · On Wed, Dec 14, 2011 at 2:39 PM, <[email protected]> wrote:
From: Bryan Schumaker <[email protected]>
Otherwise the for loop could try to use a file recently removed from the
file_hashtbllist and oops.Signed-off-by Bryan Schumaker <[email protected]>--- fs/nfsd/nfs4state.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)fs/nfsd/nfs4state.c +5
-4@@ -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; }
Quoted 7 lines
Quoted 3 lines
--
1.7.8Confirmed to fix the oops I was getting with fault injection. (tested without the previous patch, NFSD: Only reinitilize the
recall_lrulist under the recall lock)
Thanks for testing!
- Bryan
Quoted 39 lines · Casey Bodley
Quoted 38 lines · On Wed, Dec 14, 2011 at 2:39 PM, <[email protected]> wrote:
From: Bryan Schumaker <[email protected]>
Otherwise the for loop could try to use a file recently removed from the
file_hashtbllist and oops.Signed-off-by Bryan Schumaker <[email protected]>---
fs/nfsd/nfs4state.c | 9 +++++----1 files changed, 5 insertions(+), 4 deletions(-)fs/nfsd/nfs4state.c +5
-4@@ -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; }
Quoted 7 lines
Quoted 3 lines
--
1.7.8Confirmed to fix the oops I was getting with fault injection. (tested without the previous patch, NFSD: Only reinitilize the
recall_lrulist under the recall lock)
Ah-hah. Thanks Bryan, and Casey--committed.
--b.