aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2011-03-03 10:13:45 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-03-11 15:38:44 -0500
commit0382b74409c6b9ef12c952b50bb44f557a361a43 (patch)
tree0eebc04006a3b70fb6605c42ee89cdc0ccd8b1cf
parent44b83799a922a153957c65ccfc985a8c902958c8 (diff)
NFSv4.1: implement generic pnfs layer write switch
Signed-off-by: Andy Adamson <andros@citi.umich.edu> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Dean Hildebrand <dhildeb@us.ibm.com> Signed-off-by: Fred Isaman <iisaman@citi.umich.edu> Signed-off-by: J. Bruce Fields <bfields@fieldses.org> Signed-off-by: Mike Sager <sager@netapp.com> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com> Signed-off-by: Tao Guo <guotao@nrchpc.ac.cn> Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4filelayout.c7
-rw-r--r--fs/nfs/pnfs.c24
-rw-r--r--fs/nfs/pnfs.h10
-rw-r--r--fs/nfs/write.c4
-rw-r--r--include/linux/nfs_iostat.h1
-rw-r--r--include/linux/nfs_xdr.h1
6 files changed, 47 insertions, 0 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 0040a5ee6208..9d21bfeec88f 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -238,6 +238,12 @@ filelayout_read_pagelist(struct nfs_read_data *data)
238 return PNFS_ATTEMPTED; 238 return PNFS_ATTEMPTED;
239} 239}
240 240
241static enum pnfs_try_status
242filelayout_write_pagelist(struct nfs_write_data *data, int sync)
243{
244 return PNFS_NOT_ATTEMPTED;
245}
246
241/* 247/*
242 * filelayout_check_layout() 248 * filelayout_check_layout()
243 * 249 *
@@ -455,6 +461,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
455 .free_lseg = filelayout_free_lseg, 461 .free_lseg = filelayout_free_lseg,
456 .pg_test = filelayout_pg_test, 462 .pg_test = filelayout_pg_test,
457 .read_pagelist = filelayout_read_pagelist, 463 .read_pagelist = filelayout_read_pagelist,
464 .write_pagelist = filelayout_write_pagelist,
458}; 465};
459 466
460static int __init nfs4filelayout_init(void) 467static int __init nfs4filelayout_init(void)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5f205d31d96c..f38813a0a295 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -895,6 +895,30 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)
895 pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL; 895 pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL;
896} 896}
897 897
898enum pnfs_try_status
899pnfs_try_to_write_data(struct nfs_write_data *wdata,
900 const struct rpc_call_ops *call_ops, int how)
901{
902 struct inode *inode = wdata->inode;
903 enum pnfs_try_status trypnfs;
904 struct nfs_server *nfss = NFS_SERVER(inode);
905
906 wdata->mds_ops = call_ops;
907
908 dprintk("%s: Writing ino:%lu %u@%llu (how %d)\n", __func__,
909 inode->i_ino, wdata->args.count, wdata->args.offset, how);
910
911 trypnfs = nfss->pnfs_curr_ld->write_pagelist(wdata, how);
912 if (trypnfs == PNFS_NOT_ATTEMPTED) {
913 put_lseg(wdata->lseg);
914 wdata->lseg = NULL;
915 } else
916 nfs_inc_stats(inode, NFSIOS_PNFS_WRITE);
917
918 dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs);
919 return trypnfs;
920}
921
898/* 922/*
899 * Call the appropriate parallel I/O subsystem read function. 923 * Call the appropriate parallel I/O subsystem read function.
900 */ 924 */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 1d4e6317fa95..6380b9405bcd 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -79,6 +79,7 @@ struct pnfs_layoutdriver_type {
79 * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS 79 * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS
80 */ 80 */
81 enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data); 81 enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data);
82 enum pnfs_try_status (*write_pagelist) (struct nfs_write_data *nfs_data, int how);
82}; 83};
83 84
84struct pnfs_layout_hdr { 85struct pnfs_layout_hdr {
@@ -120,6 +121,8 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
120 enum pnfs_iomode access_type); 121 enum pnfs_iomode access_type);
121void set_pnfs_layoutdriver(struct nfs_server *, u32 id); 122void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
122void unset_pnfs_layoutdriver(struct nfs_server *); 123void unset_pnfs_layoutdriver(struct nfs_server *);
124enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
125 const struct rpc_call_ops *, int);
123enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *, 126enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
124 const struct rpc_call_ops *); 127 const struct rpc_call_ops *);
125void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *); 128void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *);
@@ -200,6 +203,13 @@ pnfs_try_to_read_data(struct nfs_read_data *data,
200 return PNFS_NOT_ATTEMPTED; 203 return PNFS_NOT_ATTEMPTED;
201} 204}
202 205
206static inline enum pnfs_try_status
207pnfs_try_to_write_data(struct nfs_write_data *data,
208 const struct rpc_call_ops *call_ops, int how)
209{
210 return PNFS_NOT_ATTEMPTED;
211}
212
203static inline bool 213static inline bool
204pnfs_roc(struct inode *ino) 214pnfs_roc(struct inode *ino)
205{ 215{
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 49c4784c24e5..df99c5b0ee65 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -873,6 +873,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
873 data->res.verf = &data->verf; 873 data->res.verf = &data->verf;
874 nfs_fattr_init(&data->fattr); 874 nfs_fattr_init(&data->fattr);
875 875
876 if (data->lseg &&
877 (pnfs_try_to_write_data(data, call_ops, how) == PNFS_ATTEMPTED))
878 return 0;
879
876 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how); 880 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
877} 881}
878 882
diff --git a/include/linux/nfs_iostat.h b/include/linux/nfs_iostat.h
index 37a143732d02..8866bb3502ee 100644
--- a/include/linux/nfs_iostat.h
+++ b/include/linux/nfs_iostat.h
@@ -114,6 +114,7 @@ enum nfs_stat_eventcounters {
114 NFSIOS_SHORTWRITE, 114 NFSIOS_SHORTWRITE,
115 NFSIOS_DELAY, 115 NFSIOS_DELAY,
116 NFSIOS_PNFS_READ, 116 NFSIOS_PNFS_READ,
117 NFSIOS_PNFS_WRITE,
117 __NFSIOS_COUNTSMAX, 118 __NFSIOS_COUNTSMAX,
118}; 119};
119 120
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 09d96812d6d0..c82ad33cffe1 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1039,6 +1039,7 @@ struct nfs_write_data {
1039 struct nfs_writeargs args; /* argument struct */ 1039 struct nfs_writeargs args; /* argument struct */
1040 struct nfs_writeres res; /* result struct */ 1040 struct nfs_writeres res; /* result struct */
1041 struct pnfs_layout_segment *lseg; 1041 struct pnfs_layout_segment *lseg;
1042 const struct rpc_call_ops *mds_ops;
1042 int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data); 1043 int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
1043#ifdef CONFIG_NFS_V4 1044#ifdef CONFIG_NFS_V4
1044 unsigned long timestamp; /* For lease renewal */ 1045 unsigned long timestamp; /* For lease renewal */