diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-12 13:42:02 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-12 13:42:02 -0400 |
commit | 6e4efd568574221840ee8dd86f176dc977c1330c (patch) | |
tree | b43afc1ae5400bbadbc122d2bfb5a69b3a26e7f8 /fs/nfs/write.c | |
parent | 87ed5eb44ad9338b1617a0e78dea81d681325298 (diff) |
NFS: Clean up nfs_read_rpcsetup and nfs_write_rpcsetup
Split them up into two parts: one which sets up the struct nfs_read/write_data,
the other which sets up the actual RPC call or pNFS call.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r-- | fs/nfs/write.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 1af4d82c4959..0aeb09b38e4b 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -845,11 +845,9 @@ EXPORT_SYMBOL_GPL(nfs_initiate_write); | |||
845 | /* | 845 | /* |
846 | * Set up the argument/result storage required for the RPC call. | 846 | * Set up the argument/result storage required for the RPC call. |
847 | */ | 847 | */ |
848 | static int nfs_write_rpcsetup(struct nfs_page *req, | 848 | static void nfs_write_rpcsetup(struct nfs_page *req, |
849 | struct nfs_write_data *data, | 849 | struct nfs_write_data *data, |
850 | const struct rpc_call_ops *call_ops, | ||
851 | unsigned int count, unsigned int offset, | 850 | unsigned int count, unsigned int offset, |
852 | struct pnfs_layout_segment *lseg, | ||
853 | int how) | 851 | int how) |
854 | { | 852 | { |
855 | struct inode *inode = req->wb_context->path.dentry->d_inode; | 853 | struct inode *inode = req->wb_context->path.dentry->d_inode; |
@@ -860,7 +858,6 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
860 | data->req = req; | 858 | data->req = req; |
861 | data->inode = inode = req->wb_context->path.dentry->d_inode; | 859 | data->inode = inode = req->wb_context->path.dentry->d_inode; |
862 | data->cred = req->wb_context->cred; | 860 | data->cred = req->wb_context->cred; |
863 | data->lseg = get_lseg(lseg); | ||
864 | 861 | ||
865 | data->args.fh = NFS_FH(inode); | 862 | data->args.fh = NFS_FH(inode); |
866 | data->args.offset = req_offset(req) + offset; | 863 | data->args.offset = req_offset(req) + offset; |
@@ -886,10 +883,22 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
886 | data->res.count = count; | 883 | data->res.count = count; |
887 | data->res.verf = &data->verf; | 884 | data->res.verf = &data->verf; |
888 | nfs_fattr_init(&data->fattr); | 885 | nfs_fattr_init(&data->fattr); |
886 | } | ||
889 | 887 | ||
890 | if (data->lseg && | 888 | static int nfs_do_write(struct nfs_write_data *data, |
891 | (pnfs_try_to_write_data(data, call_ops, how) == PNFS_ATTEMPTED)) | 889 | const struct rpc_call_ops *call_ops, |
892 | return 0; | 890 | struct pnfs_layout_segment *lseg, |
891 | int how) | ||
892 | { | ||
893 | struct inode *inode = data->args.context->path.dentry->d_inode; | ||
894 | |||
895 | if (lseg != NULL) { | ||
896 | data->lseg = get_lseg(lseg); | ||
897 | if (pnfs_try_to_write_data(data, call_ops, how) == PNFS_ATTEMPTED) | ||
898 | return 0; | ||
899 | put_lseg(data->lseg); | ||
900 | data->lseg = NULL; | ||
901 | } | ||
893 | 902 | ||
894 | return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how); | 903 | return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how); |
895 | } | 904 | } |
@@ -938,7 +947,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc) | |||
938 | data = nfs_writedata_alloc(1); | 947 | data = nfs_writedata_alloc(1); |
939 | if (!data) | 948 | if (!data) |
940 | goto out_bad; | 949 | goto out_bad; |
941 | list_add(&data->pages, &list); | 950 | list_add(&data->list, &list); |
942 | requests++; | 951 | requests++; |
943 | nbytes -= len; | 952 | nbytes -= len; |
944 | } while (nbytes != 0); | 953 | } while (nbytes != 0); |
@@ -950,15 +959,16 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc) | |||
950 | do { | 959 | do { |
951 | int ret2; | 960 | int ret2; |
952 | 961 | ||
953 | data = list_entry(list.next, struct nfs_write_data, pages); | 962 | data = list_entry(list.next, struct nfs_write_data, list); |
954 | list_del_init(&data->pages); | 963 | list_del_init(&data->list); |
955 | 964 | ||
956 | data->pagevec[0] = page; | 965 | data->pagevec[0] = page; |
957 | 966 | ||
958 | if (nbytes < wsize) | 967 | if (nbytes < wsize) |
959 | wsize = nbytes; | 968 | wsize = nbytes; |
960 | ret2 = nfs_write_rpcsetup(req, data, &nfs_write_partial_ops, | 969 | nfs_write_rpcsetup(req, data, wsize, offset, desc->pg_ioflags); |
961 | wsize, offset, lseg, desc->pg_ioflags); | 970 | ret2 = nfs_do_write(data, &nfs_write_partial_ops, lseg, |
971 | desc->pg_ioflags); | ||
962 | if (ret == 0) | 972 | if (ret == 0) |
963 | ret = ret2; | 973 | ret = ret2; |
964 | offset += wsize; | 974 | offset += wsize; |
@@ -971,8 +981,8 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc) | |||
971 | 981 | ||
972 | out_bad: | 982 | out_bad: |
973 | while (!list_empty(&list)) { | 983 | while (!list_empty(&list)) { |
974 | data = list_entry(list.next, struct nfs_write_data, pages); | 984 | data = list_entry(list.next, struct nfs_write_data, list); |
975 | list_del(&data->pages); | 985 | list_del(&data->list); |
976 | nfs_writedata_free(data); | 986 | nfs_writedata_free(data); |
977 | } | 987 | } |
978 | nfs_redirty_request(req); | 988 | nfs_redirty_request(req); |
@@ -1024,7 +1034,8 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc) | |||
1024 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; | 1034 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; |
1025 | 1035 | ||
1026 | /* Set up the argument struct */ | 1036 | /* Set up the argument struct */ |
1027 | ret = nfs_write_rpcsetup(req, data, &nfs_write_full_ops, desc->pg_count, 0, lseg, desc->pg_ioflags); | 1037 | nfs_write_rpcsetup(req, data, desc->pg_count, 0, desc->pg_ioflags); |
1038 | ret = nfs_do_write(data, &nfs_write_full_ops, lseg, desc->pg_ioflags); | ||
1028 | out: | 1039 | out: |
1029 | put_lseg(lseg); /* Cleans any gotten in ->pg_test */ | 1040 | put_lseg(lseg); /* Cleans any gotten in ->pg_test */ |
1030 | desc->pg_lseg = NULL; | 1041 | desc->pg_lseg = NULL; |