diff options
author | Fred Isaman <fred.isaman@gmail.com> | 2016-09-21 05:14:28 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@hammerspace.com> | 2018-05-31 15:03:11 -0400 |
commit | 587f03deb69bdbf2c8f5f06c5cdcebb42196faff (patch) | |
tree | 00f0fd392ec7c9b4361b04d92380d58699762e30 | |
parent | f86c3ac50276b6b9d6246e0fcb4781c4eaeb04eb (diff) |
pnfs: refactor send_layoutget
Pull out the alloc/init part for eventual reuse by OPEN.
Signed-off-by: Fred Isaman <fred.isaman@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r-- | fs/nfs/pnfs.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index ee723aa153a3..2c955c389ecf 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -915,18 +915,12 @@ pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo) | |||
915 | test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); | 915 | test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags); |
916 | } | 916 | } |
917 | 917 | ||
918 | /* | 918 | static struct nfs4_layoutget * |
919 | * Get layout from server. | 919 | pnfs_alloc_init_layoutget_args(struct pnfs_layout_hdr *lo, |
920 | * for now, assume that whole file layouts are requested. | ||
921 | * arg->offset: 0 | ||
922 | * arg->length: all ones | ||
923 | */ | ||
924 | static struct pnfs_layout_segment * | ||
925 | send_layoutget(struct pnfs_layout_hdr *lo, | ||
926 | struct nfs_open_context *ctx, | 920 | struct nfs_open_context *ctx, |
927 | nfs4_stateid *stateid, | 921 | nfs4_stateid *stateid, |
928 | const struct pnfs_layout_range *range, | 922 | const struct pnfs_layout_range *range, |
929 | long *timeout, gfp_t gfp_flags) | 923 | gfp_t gfp_flags) |
930 | { | 924 | { |
931 | struct inode *ino = lo->plh_inode; | 925 | struct inode *ino = lo->plh_inode; |
932 | struct nfs_server *server = NFS_SERVER(ino); | 926 | struct nfs_server *server = NFS_SERVER(ino); |
@@ -935,14 +929,9 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
935 | 929 | ||
936 | dprintk("--> %s\n", __func__); | 930 | dprintk("--> %s\n", __func__); |
937 | 931 | ||
938 | /* | ||
939 | * Synchronously retrieve layout information from server and | ||
940 | * store in lseg. If we race with a concurrent seqid morphing | ||
941 | * op, then re-send the LAYOUTGET. | ||
942 | */ | ||
943 | lgp = kzalloc(sizeof(*lgp), gfp_flags); | 932 | lgp = kzalloc(sizeof(*lgp), gfp_flags); |
944 | if (lgp == NULL) | 933 | if (lgp == NULL) |
945 | return ERR_PTR(-ENOMEM); | 934 | return NULL; |
946 | 935 | ||
947 | i_size = i_size_read(ino); | 936 | i_size = i_size_read(ino); |
948 | 937 | ||
@@ -963,8 +952,7 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
963 | nfs4_stateid_copy(&lgp->args.stateid, stateid); | 952 | nfs4_stateid_copy(&lgp->args.stateid, stateid); |
964 | lgp->gfp_flags = gfp_flags; | 953 | lgp->gfp_flags = gfp_flags; |
965 | lgp->cred = lo->plh_lc_cred; | 954 | lgp->cred = lo->plh_lc_cred; |
966 | 955 | return lgp; | |
967 | return nfs4_proc_layoutget(lgp, timeout, gfp_flags); | ||
968 | } | 956 | } |
969 | 957 | ||
970 | static void pnfs_clear_layoutcommit(struct inode *inode, | 958 | static void pnfs_clear_layoutcommit(struct inode *inode, |
@@ -1694,6 +1682,7 @@ pnfs_update_layout(struct inode *ino, | |||
1694 | struct nfs_client *clp = server->nfs_client; | 1682 | struct nfs_client *clp = server->nfs_client; |
1695 | struct pnfs_layout_hdr *lo = NULL; | 1683 | struct pnfs_layout_hdr *lo = NULL; |
1696 | struct pnfs_layout_segment *lseg = NULL; | 1684 | struct pnfs_layout_segment *lseg = NULL; |
1685 | struct nfs4_layoutget *lgp; | ||
1697 | nfs4_stateid stateid; | 1686 | nfs4_stateid stateid; |
1698 | long timeout = 0; | 1687 | long timeout = 0; |
1699 | unsigned long giveup = jiffies + (clp->cl_lease_time << 1); | 1688 | unsigned long giveup = jiffies + (clp->cl_lease_time << 1); |
@@ -1838,7 +1827,15 @@ lookup_again: | |||
1838 | if (arg.length != NFS4_MAX_UINT64) | 1827 | if (arg.length != NFS4_MAX_UINT64) |
1839 | arg.length = PAGE_ALIGN(arg.length); | 1828 | arg.length = PAGE_ALIGN(arg.length); |
1840 | 1829 | ||
1841 | lseg = send_layoutget(lo, ctx, &stateid, &arg, &timeout, gfp_flags); | 1830 | lgp = pnfs_alloc_init_layoutget_args(lo, ctx, &stateid, &arg, gfp_flags); |
1831 | if (!lgp) { | ||
1832 | trace_pnfs_update_layout(ino, pos, count, iomode, lo, NULL, | ||
1833 | PNFS_UPDATE_LAYOUT_NOMEM); | ||
1834 | atomic_dec(&lo->plh_outstanding); | ||
1835 | goto out_put_layout_hdr; | ||
1836 | } | ||
1837 | |||
1838 | lseg = nfs4_proc_layoutget(lgp, &timeout, gfp_flags); | ||
1842 | trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, | 1839 | trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, |
1843 | PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET); | 1840 | PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET); |
1844 | atomic_dec(&lo->plh_outstanding); | 1841 | atomic_dec(&lo->plh_outstanding); |