diff options
author | Fred Isaman <iisaman@netapp.com> | 2011-06-13 18:54:53 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-06-15 11:24:30 -0400 |
commit | a2e1d4f2e5ed83850de92a491ef225824cb457bd (patch) | |
tree | a97ec1b7e83b254e9b7179425e848d72cd6c3db3 /fs/nfs | |
parent | cec765cf5891c7fc3d905832b481bfb6fd55825d (diff) |
nfs4.1: fix several problems with _pnfs_return_layout
_pnfs_return_layout had the following problems:
- it did not call pnfs_free_lseg_list on all paths
- it unintentionally did a forgetful return when there was no outstanding io
- it raced with concurrent LAYOUTGETS
Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 8 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 289c539bd6b3..5879b23e0c99 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -5706,6 +5706,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) | |||
5706 | { | 5706 | { |
5707 | struct nfs4_layoutreturn *lrp = calldata; | 5707 | struct nfs4_layoutreturn *lrp = calldata; |
5708 | struct nfs_server *server; | 5708 | struct nfs_server *server; |
5709 | struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; | ||
5709 | 5710 | ||
5710 | dprintk("--> %s\n", __func__); | 5711 | dprintk("--> %s\n", __func__); |
5711 | 5712 | ||
@@ -5717,16 +5718,15 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) | |||
5717 | nfs_restart_rpc(task, lrp->clp); | 5718 | nfs_restart_rpc(task, lrp->clp); |
5718 | return; | 5719 | return; |
5719 | } | 5720 | } |
5721 | spin_lock(&lo->plh_inode->i_lock); | ||
5720 | if (task->tk_status == 0) { | 5722 | if (task->tk_status == 0) { |
5721 | struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; | ||
5722 | |||
5723 | if (lrp->res.lrs_present) { | 5723 | if (lrp->res.lrs_present) { |
5724 | spin_lock(&lo->plh_inode->i_lock); | ||
5725 | pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); | 5724 | pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); |
5726 | spin_unlock(&lo->plh_inode->i_lock); | ||
5727 | } else | 5725 | } else |
5728 | BUG_ON(!list_empty(&lo->plh_segs)); | 5726 | BUG_ON(!list_empty(&lo->plh_segs)); |
5729 | } | 5727 | } |
5728 | lo->plh_block_lgets--; | ||
5729 | spin_unlock(&lo->plh_inode->i_lock); | ||
5730 | dprintk("<-- %s\n", __func__); | 5730 | dprintk("<-- %s\n", __func__); |
5731 | } | 5731 | } |
5732 | 5732 | ||
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 8c1309d852a6..25de6b27bdf4 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -634,12 +634,14 @@ _pnfs_return_layout(struct inode *ino) | |||
634 | 634 | ||
635 | spin_lock(&ino->i_lock); | 635 | spin_lock(&ino->i_lock); |
636 | lo = nfsi->layout; | 636 | lo = nfsi->layout; |
637 | if (!lo || !mark_matching_lsegs_invalid(lo, &tmp_list, NULL)) { | 637 | if (!lo) { |
638 | spin_unlock(&ino->i_lock); | 638 | spin_unlock(&ino->i_lock); |
639 | dprintk("%s: no layout segments to return\n", __func__); | 639 | dprintk("%s: no layout to return\n", __func__); |
640 | goto out; | 640 | return status; |
641 | } | 641 | } |
642 | stateid = nfsi->layout->plh_stateid; | 642 | stateid = nfsi->layout->plh_stateid; |
643 | mark_matching_lsegs_invalid(lo, &tmp_list, NULL); | ||
644 | lo->plh_block_lgets++; | ||
643 | /* Reference matched in nfs4_layoutreturn_release */ | 645 | /* Reference matched in nfs4_layoutreturn_release */ |
644 | get_layout_hdr(lo); | 646 | get_layout_hdr(lo); |
645 | spin_unlock(&ino->i_lock); | 647 | spin_unlock(&ino->i_lock); |