diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-09-20 17:31:43 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-09-28 16:03:14 -0400 |
commit | 9c6263819f25254f2ed48f076b50096dd5893dfb (patch) | |
tree | d95527cbeba0d44973f286602a35ff2c21c811bd /fs/nfs/pnfs.c | |
parent | 6622c3ea059b2fed49924b74db41d1e0f065fbd3 (diff) |
NFSv4.1: Clean up the removal of pnfs_layout_hdr from the server list
Move the code into pnfs_free_layout_hdr(), and add checks to
get_layout_by_fh_locked to ensure that they don't reference a layout
that is being freed.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r-- | fs/nfs/pnfs.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 08663146f5f..11cc0ad6b40 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -207,7 +207,16 @@ pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags) | |||
207 | static void | 207 | static void |
208 | pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo) | 208 | pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo) |
209 | { | 209 | { |
210 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld; | 210 | struct nfs_server *server = NFS_SERVER(lo->plh_inode); |
211 | struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; | ||
212 | |||
213 | if (!list_empty(&lo->plh_layouts)) { | ||
214 | struct nfs_client *clp = server->nfs_client; | ||
215 | |||
216 | spin_lock(&clp->cl_lock); | ||
217 | list_del_init(&lo->plh_layouts); | ||
218 | spin_unlock(&clp->cl_lock); | ||
219 | } | ||
211 | put_rpccred(lo->plh_lc_cred); | 220 | put_rpccred(lo->plh_lc_cred); |
212 | return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo); | 221 | return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo); |
213 | } | 222 | } |
@@ -217,7 +226,6 @@ pnfs_detach_layout_hdr(struct pnfs_layout_hdr *lo) | |||
217 | { | 226 | { |
218 | struct nfs_inode *nfsi = NFS_I(lo->plh_inode); | 227 | struct nfs_inode *nfsi = NFS_I(lo->plh_inode); |
219 | dprintk("%s: freeing layout cache %p\n", __func__, lo); | 228 | dprintk("%s: freeing layout cache %p\n", __func__, lo); |
220 | BUG_ON(!list_empty(&lo->plh_layouts)); | ||
221 | nfsi->layout = NULL; | 229 | nfsi->layout = NULL; |
222 | /* Reset MDS Threshold I/O counters */ | 230 | /* Reset MDS Threshold I/O counters */ |
223 | nfsi->write_io = 0; | 231 | nfsi->write_io = 0; |
@@ -480,22 +488,10 @@ void | |||
480 | pnfs_free_lseg_list(struct list_head *free_me) | 488 | pnfs_free_lseg_list(struct list_head *free_me) |
481 | { | 489 | { |
482 | struct pnfs_layout_segment *lseg, *tmp; | 490 | struct pnfs_layout_segment *lseg, *tmp; |
483 | struct pnfs_layout_hdr *lo; | ||
484 | 491 | ||
485 | if (list_empty(free_me)) | 492 | if (list_empty(free_me)) |
486 | return; | 493 | return; |
487 | 494 | ||
488 | lo = list_first_entry(free_me, struct pnfs_layout_segment, | ||
489 | pls_list)->pls_layout; | ||
490 | |||
491 | if (test_bit(NFS_LAYOUT_DESTROYED, &lo->plh_flags)) { | ||
492 | struct nfs_client *clp; | ||
493 | |||
494 | clp = NFS_SERVER(lo->plh_inode)->nfs_client; | ||
495 | spin_lock(&clp->cl_lock); | ||
496 | list_del_init(&lo->plh_layouts); | ||
497 | spin_unlock(&clp->cl_lock); | ||
498 | } | ||
499 | list_for_each_entry_safe(lseg, tmp, free_me, pls_list) { | 495 | list_for_each_entry_safe(lseg, tmp, free_me, pls_list) { |
500 | list_del(&lseg->pls_list); | 496 | list_del(&lseg->pls_list); |
501 | free_lseg(lseg); | 497 | free_lseg(lseg); |
@@ -1148,11 +1144,6 @@ pnfs_update_layout(struct inode *ino, | |||
1148 | arg.length = PAGE_CACHE_ALIGN(arg.length); | 1144 | arg.length = PAGE_CACHE_ALIGN(arg.length); |
1149 | 1145 | ||
1150 | lseg = send_layoutget(lo, ctx, &arg, gfp_flags); | 1146 | lseg = send_layoutget(lo, ctx, &arg, gfp_flags); |
1151 | if (!lseg && first) { | ||
1152 | spin_lock(&clp->cl_lock); | ||
1153 | list_del_init(&lo->plh_layouts); | ||
1154 | spin_unlock(&clp->cl_lock); | ||
1155 | } | ||
1156 | atomic_dec(&lo->plh_outstanding); | 1147 | atomic_dec(&lo->plh_outstanding); |
1157 | out_put_layout_hdr: | 1148 | out_put_layout_hdr: |
1158 | pnfs_put_layout_hdr(lo); | 1149 | pnfs_put_layout_hdr(lo); |