NFSv4.1: implement generic pnfs layer write switch
authorAndy Adamson <andros@netapp.com>
Thu, 3 Mar 2011 15:13:45 +0000 (15:13 +0000)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 11 Mar 2011 20:38:44 +0000 (15:38 -0500)
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>
fs/nfs/nfs4filelayout.c
fs/nfs/pnfs.c
fs/nfs/pnfs.h
fs/nfs/write.c
include/linux/nfs_iostat.h
include/linux/nfs_xdr.h

index 0040a5ee6208a742406daa181149c7d18999fbfa..9d21bfeec88f200ebfe2c20d87f04609cb07c05a 100644 (file)
@@ -238,6 +238,12 @@ filelayout_read_pagelist(struct nfs_read_data *data)
        return PNFS_ATTEMPTED;
 }
 
+static enum pnfs_try_status
+filelayout_write_pagelist(struct nfs_write_data *data, int sync)
+{
+       return PNFS_NOT_ATTEMPTED;
+}
+
 /*
  * filelayout_check_layout()
  *
@@ -455,6 +461,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
        .free_lseg              = filelayout_free_lseg,
        .pg_test                = filelayout_pg_test,
        .read_pagelist          = filelayout_read_pagelist,
+       .write_pagelist         = filelayout_write_pagelist,
 };
 
 static int __init nfs4filelayout_init(void)
index 5f205d31d96cba0650f68c336ded0b76ac784bd8..f38813a0a295929e3fb8abb0ebe6b109f11571ed 100644 (file)
@@ -895,6 +895,30 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)
        pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL;
 }
 
+enum pnfs_try_status
+pnfs_try_to_write_data(struct nfs_write_data *wdata,
+                       const struct rpc_call_ops *call_ops, int how)
+{
+       struct inode *inode = wdata->inode;
+       enum pnfs_try_status trypnfs;
+       struct nfs_server *nfss = NFS_SERVER(inode);
+
+       wdata->mds_ops = call_ops;
+
+       dprintk("%s: Writing ino:%lu %u@%llu (how %d)\n", __func__,
+               inode->i_ino, wdata->args.count, wdata->args.offset, how);
+
+       trypnfs = nfss->pnfs_curr_ld->write_pagelist(wdata, how);
+       if (trypnfs == PNFS_NOT_ATTEMPTED) {
+               put_lseg(wdata->lseg);
+               wdata->lseg = NULL;
+       } else
+               nfs_inc_stats(inode, NFSIOS_PNFS_WRITE);
+
+       dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs);
+       return trypnfs;
+}
+
 /*
  * Call the appropriate parallel I/O subsystem read function.
  */
index 1d4e6317fa95082c6ede0530ee485866c061939e..6380b9405bcde5ac02137cf455b2e88d6bed8d6e 100644 (file)
@@ -79,6 +79,7 @@ struct pnfs_layoutdriver_type {
         * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS
         */
        enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data);
+       enum pnfs_try_status (*write_pagelist) (struct nfs_write_data *nfs_data, int how);
 };
 
 struct pnfs_layout_hdr {
@@ -120,6 +121,8 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
                   enum pnfs_iomode access_type);
 void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
 void unset_pnfs_layoutdriver(struct nfs_server *);
+enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
+                                            const struct rpc_call_ops *, int);
 enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
                                            const struct rpc_call_ops *);
 void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *);
@@ -200,6 +203,13 @@ pnfs_try_to_read_data(struct nfs_read_data *data,
        return PNFS_NOT_ATTEMPTED;
 }
 
+static inline enum pnfs_try_status
+pnfs_try_to_write_data(struct nfs_write_data *data,
+                      const struct rpc_call_ops *call_ops, int how)
+{
+       return PNFS_NOT_ATTEMPTED;
+}
+
 static inline bool
 pnfs_roc(struct inode *ino)
 {
index 49c4784c24e5b3e76b52fc5aa43caf90db1dc687..df99c5b0ee65c3e131e50f3ed125aed19e29d769 100644 (file)
@@ -873,6 +873,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
        data->res.verf    = &data->verf;
        nfs_fattr_init(&data->fattr);
 
+       if (data->lseg &&
+           (pnfs_try_to_write_data(data, call_ops, how) == PNFS_ATTEMPTED))
+               return 0;
+
        return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
 }
 
index 37a143732d023f523d07823a1c5d22784896c3b1..8866bb3502ee1df94075aa2068a980cb7fe2f090 100644 (file)
@@ -114,6 +114,7 @@ enum nfs_stat_eventcounters {
        NFSIOS_SHORTWRITE,
        NFSIOS_DELAY,
        NFSIOS_PNFS_READ,
+       NFSIOS_PNFS_WRITE,
        __NFSIOS_COUNTSMAX,
 };
 
index 09d96812d6d0fcd373b86aca7ef496a2a45a25de..c82ad33cffe1ef3dc3789d954ecc6170b71ac7fd 100644 (file)
@@ -1039,6 +1039,7 @@ struct nfs_write_data {
        struct nfs_writeargs    args;           /* argument struct */
        struct nfs_writeres     res;            /* result struct */
        struct pnfs_layout_segment *lseg;
+       const struct rpc_call_ops *mds_ops;
        int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
 #ifdef CONFIG_NFS_V4
        unsigned long           timestamp;      /* For lease renewal */