aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorPeng Tao <tao.peng@primarydata.com>2014-09-05 12:53:22 -0400
committerTom Haynes <loghyr@primarydata.com>2015-02-03 14:06:41 -0500
commitf40eb5d044e2eea3f866eeeeb45ca30753773cda (patch)
tree595cdf1e1ca1b915a7585002c4642431d372c517 /fs/nfs
parent4579d6b897ee1b2557517fd536fb17eeb13481ad (diff)
nfs41: make a helper function to send layoutreturn
It allows to specify different iomode to return. Signed-off-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Tom Haynes <Thomas.Haynes@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/pnfs.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 1b544c1a746c..1b9720992608 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -845,6 +845,38 @@ static void pnfs_clear_layoutcommit(struct inode *inode,
845 } 845 }
846} 846}
847 847
848static int
849pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
850 enum pnfs_iomode iomode)
851{
852 struct inode *ino = lo->plh_inode;
853 struct nfs4_layoutreturn *lrp;
854 int status = 0;
855
856 lrp = kzalloc(sizeof(*lrp), GFP_KERNEL);
857 if (unlikely(lrp == NULL)) {
858 status = -ENOMEM;
859 spin_lock(&ino->i_lock);
860 lo->plh_block_lgets--;
861 spin_unlock(&ino->i_lock);
862 pnfs_put_layout_hdr(lo);
863 goto out;
864 }
865
866 lrp->args.stateid = stateid;
867 lrp->args.layout_type = NFS_SERVER(ino)->pnfs_curr_ld->id;
868 lrp->args.inode = ino;
869 lrp->args.iomode = iomode;
870 lrp->args.layout = lo;
871 lrp->clp = NFS_SERVER(ino)->nfs_client;
872 lrp->cred = lo->plh_lc_cred;
873
874 status = nfs4_proc_layoutreturn(lrp);
875out:
876 dprintk("<-- %s status: %d\n", __func__, status);
877 return status;
878}
879
848/* 880/*
849 * Initiates a LAYOUTRETURN(FILE), and removes the pnfs_layout_hdr 881 * Initiates a LAYOUTRETURN(FILE), and removes the pnfs_layout_hdr
850 * when the layout segment list is empty. 882 * when the layout segment list is empty.
@@ -859,7 +891,6 @@ _pnfs_return_layout(struct inode *ino)
859 struct pnfs_layout_hdr *lo = NULL; 891 struct pnfs_layout_hdr *lo = NULL;
860 struct nfs_inode *nfsi = NFS_I(ino); 892 struct nfs_inode *nfsi = NFS_I(ino);
861 LIST_HEAD(tmp_list); 893 LIST_HEAD(tmp_list);
862 struct nfs4_layoutreturn *lrp;
863 nfs4_stateid stateid; 894 nfs4_stateid stateid;
864 int status = 0, empty; 895 int status = 0, empty;
865 896
@@ -901,25 +932,7 @@ _pnfs_return_layout(struct inode *ino)
901 spin_unlock(&ino->i_lock); 932 spin_unlock(&ino->i_lock);
902 pnfs_free_lseg_list(&tmp_list); 933 pnfs_free_lseg_list(&tmp_list);
903 934
904 lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); 935 status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY);
905 if (unlikely(lrp == NULL)) {
906 status = -ENOMEM;
907 spin_lock(&ino->i_lock);
908 lo->plh_block_lgets--;
909 spin_unlock(&ino->i_lock);
910 pnfs_put_layout_hdr(lo);
911 goto out;
912 }
913
914 lrp->args.stateid = stateid;
915 lrp->args.layout_type = NFS_SERVER(ino)->pnfs_curr_ld->id;
916 lrp->args.inode = ino;
917 lrp->args.iomode = IOMODE_ANY;
918 lrp->args.layout = lo;
919 lrp->clp = NFS_SERVER(ino)->nfs_client;
920 lrp->cred = lo->plh_lc_cred;
921
922 status = nfs4_proc_layoutreturn(lrp);
923out: 936out:
924 dprintk("<-- %s status: %d\n", __func__, status); 937 dprintk("<-- %s status: %d\n", __func__, status);
925 return status; 938 return status;