aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-13 15:59:19 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-15 09:12:22 -0400
commitdce81290eed64d24493989bb7a08f9e20495e184 (patch)
treeeb25c828d3343196fe31d95da2d7d743692fa71e /fs/nfs/write.c
parent493292ddc78d18ee2ad2d5c24c2b7dd6a24641d2 (diff)
NFS: Move the pnfs write code into pnfs.c
...and ensure that we recoalese to take into account differences in differences in block sizes when falling back to write through the MDS. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index c88a1ab42c39..cabe5f6611b9 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -97,7 +97,7 @@ void nfs_writedata_free(struct nfs_write_data *p)
97 mempool_free(p, nfs_wdata_mempool); 97 mempool_free(p, nfs_wdata_mempool);
98} 98}
99 99
100static void nfs_writedata_release(struct nfs_write_data *wdata) 100void nfs_writedata_release(struct nfs_write_data *wdata)
101{ 101{
102 put_lseg(wdata->lseg); 102 put_lseg(wdata->lseg);
103 put_nfs_open_context(wdata->args.context); 103 put_nfs_open_context(wdata->args.context);
@@ -887,25 +887,15 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
887 887
888static int nfs_do_write(struct nfs_write_data *data, 888static int nfs_do_write(struct nfs_write_data *data,
889 const struct rpc_call_ops *call_ops, 889 const struct rpc_call_ops *call_ops,
890 struct pnfs_layout_segment *lseg,
891 int how) 890 int how)
892{ 891{
893 struct inode *inode = data->args.context->path.dentry->d_inode; 892 struct inode *inode = data->args.context->path.dentry->d_inode;
894 893
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 }
902
903 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how); 894 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
904} 895}
905 896
906static int nfs_do_multiple_writes(struct list_head *head, 897static int nfs_do_multiple_writes(struct list_head *head,
907 const struct rpc_call_ops *call_ops, 898 const struct rpc_call_ops *call_ops,
908 struct pnfs_layout_segment *lseg,
909 int how) 899 int how)
910{ 900{
911 struct nfs_write_data *data; 901 struct nfs_write_data *data;
@@ -917,7 +907,7 @@ static int nfs_do_multiple_writes(struct list_head *head,
917 data = list_entry(head->next, struct nfs_write_data, list); 907 data = list_entry(head->next, struct nfs_write_data, list);
918 list_del_init(&data->list); 908 list_del_init(&data->list);
919 909
920 ret2 = nfs_do_write(data, call_ops, lseg, how); 910 ret2 = nfs_do_write(data, call_ops, how);
921 if (ret == 0) 911 if (ret == 0)
922 ret = ret2; 912 ret = ret2;
923 } 913 }
@@ -1037,23 +1027,24 @@ out:
1037 return ret; 1027 return ret;
1038} 1028}
1039 1029
1040int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc) 1030int nfs_generic_flush(struct nfs_pageio_descriptor *desc, struct list_head *head)
1031{
1032 if (desc->pg_bsize < PAGE_CACHE_SIZE)
1033 return nfs_flush_multi(desc, head);
1034 return nfs_flush_one(desc, head);
1035}
1036
1037static int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
1041{ 1038{
1042 LIST_HEAD(head); 1039 LIST_HEAD(head);
1043 int ret; 1040 int ret;
1044 1041
1045 if (desc->pg_bsize < PAGE_CACHE_SIZE) 1042 ret = nfs_generic_flush(desc, &head);
1046 ret = nfs_flush_multi(desc, &head);
1047 else
1048 ret = nfs_flush_one(desc, &head);
1049 if (ret == 0) 1043 if (ret == 0)
1050 ret = nfs_do_multiple_writes(&head, desc->pg_rpc_callops, 1044 ret = nfs_do_multiple_writes(&head, desc->pg_rpc_callops,
1051 desc->pg_lseg, desc->pg_ioflags); 1045 desc->pg_ioflags);
1052 put_lseg(desc->pg_lseg);
1053 desc->pg_lseg = NULL;
1054 return ret; 1046 return ret;
1055} 1047}
1056EXPORT_SYMBOL_GPL(nfs_generic_pg_writepages);
1057 1048
1058static const struct nfs_pageio_ops nfs_pageio_write_ops = { 1049static const struct nfs_pageio_ops nfs_pageio_write_ops = {
1059 .pg_test = nfs_generic_pg_test, 1050 .pg_test = nfs_generic_pg_test,
@@ -1068,6 +1059,12 @@ void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
1068} 1059}
1069EXPORT_SYMBOL_GPL(nfs_pageio_init_write_mds); 1060EXPORT_SYMBOL_GPL(nfs_pageio_init_write_mds);
1070 1061
1062void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
1063{
1064 pgio->pg_ops = &nfs_pageio_write_ops;
1065 pgio->pg_bsize = NFS_SERVER(pgio->pg_inode)->wsize;
1066}
1067
1071static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, 1068static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
1072 struct inode *inode, int ioflags) 1069 struct inode *inode, int ioflags)
1073{ 1070{