]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFS: Create an write_pageio_init() function
authorBryan Schumaker <bjschuma@netapp.com>
Wed, 20 Jun 2012 19:53:48 +0000 (15:53 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 29 Jun 2012 15:46:46 +0000 (11:46 -0400)
pNFS needs to select a write function based on the layout driver
currently in use, so I let each NFS version decide how to best handle
initializing writes.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/internal.h
fs/nfs/nfs3proc.c
fs/nfs/nfs4proc.c
fs/nfs/pnfs.c
fs/nfs/pnfs.h
fs/nfs/proc.c
fs/nfs/write.c
include/linux/nfs_xdr.h

index b3121123b40db93360cf5be712e86054cf64e0ef..7edc172c371eb0bc0a80ce185b4d7a47be4e6d7e 100644 (file)
@@ -320,7 +320,7 @@ extern struct nfs_write_header *nfs_writehdr_alloc(void);
 extern void nfs_writehdr_free(struct nfs_pgio_header *hdr);
 extern int nfs_generic_flush(struct nfs_pageio_descriptor *desc,
                             struct nfs_pgio_header *hdr);
-extern void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
+extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
                        struct inode *inode, int ioflags,
                        const struct nfs_pgio_completion_ops *compl_ops);
 extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
index 9864d05432dafc1afc0ab3ae6507d3bdd12368fa..f3344f7f46a99616c53aa2311b15030073a91697 100644 (file)
@@ -925,6 +925,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
        .read_rpc_prepare = nfs3_proc_read_rpc_prepare,
        .read_done      = nfs3_read_done,
        .write_setup    = nfs3_proc_write_setup,
+       .write_pageio_init = nfs_pageio_init_write,
        .write_rpc_prepare = nfs3_proc_write_rpc_prepare,
        .write_done     = nfs3_write_done,
        .commit_setup   = nfs3_proc_commit_setup,
index f99cf71f4e36bb44cd8d7cf484c13a5e78feca72..7d387cb8ceb5de57ce978276faceb1e958474afc 100644 (file)
@@ -6796,6 +6796,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
        .read_rpc_prepare = nfs4_proc_read_rpc_prepare,
        .read_done      = nfs4_read_done,
        .write_setup    = nfs4_proc_write_setup,
+       .write_pageio_init = pnfs_pageio_init_write,
        .write_rpc_prepare = nfs4_proc_write_rpc_prepare,
        .write_done     = nfs4_write_done,
        .commit_setup   = nfs4_proc_commit_setup,
index 9c830603a16c18e53f485aa6d55aeba48709f49b..2617831afd392879bf2ce117cd82166cde28b064 100644 (file)
@@ -1222,7 +1222,7 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode,
                nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0);
 }
 
-bool
+void
 pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode,
                       int ioflags,
                       const struct nfs_pgio_completion_ops *compl_ops)
@@ -1231,10 +1231,9 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode,
        struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld;
 
        if (ld == NULL)
-               return false;
-       nfs_pageio_init(pgio, inode, ld->pg_write_ops, compl_ops,
-                       server->wsize, ioflags);
-       return true;
+               nfs_pageio_init_write(pgio, inode, ioflags, compl_ops);
+       else
+               nfs_pageio_init(pgio, inode, ld->pg_write_ops, compl_ops, server->wsize, ioflags);
 }
 
 bool
@@ -1271,7 +1270,7 @@ int pnfs_write_done_resend_to_mds(struct inode *inode,
        LIST_HEAD(failed);
 
        /* Resend all requests through the MDS */
-       nfs_pageio_init_write_mds(&pgio, inode, FLUSH_STABLE, compl_ops);
+       nfs_pageio_init_write(&pgio, inode, FLUSH_STABLE, compl_ops);
        while (!list_empty(head)) {
                struct nfs_page *req = nfs_list_entry(head->next);
 
index 80ee8919dd5e3f37770ea07ff65d0376c4322a22..592beb02c955d6102f5f92405b3dd395e3d9bb8b 100644 (file)
@@ -180,7 +180,7 @@ void put_lseg(struct pnfs_layout_segment *lseg);
 
 void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *,
                           const struct nfs_pgio_completion_ops *);
-bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *,
+void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *,
                            int, const struct nfs_pgio_completion_ops *);
 
 void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32);
@@ -444,10 +444,10 @@ static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, str
        nfs_pageio_init_read(pgio, inode, compl_ops);
 }
 
-static inline bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags,
+static inline void pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags,
                                          const struct nfs_pgio_completion_ops *compl_ops)
 {
-       return false;
+       nfs_pageio_init_write(pgio, inode, ioflags, compl_ops);
 }
 
 static inline int
index 6fea6e107bc3bb77c4da44a75d19dcfdc0693c6f..cf6499742b107c3a3cfaa9827539672ee9ea98ae 100644 (file)
@@ -782,6 +782,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
        .read_rpc_prepare = nfs_proc_read_rpc_prepare,
        .read_done      = nfs_read_done,
        .write_setup    = nfs_proc_write_setup,
+       .write_pageio_init = nfs_pageio_init_write,
        .write_rpc_prepare = nfs_proc_write_rpc_prepare,
        .write_done     = nfs_write_done,
        .commit_setup   = nfs_proc_commit_setup,
index f163355b96186745039ca86ee0c9b7082e55a5aa..c11fb0025f0b421e7669683cb5877e0a88e56406 100644 (file)
@@ -336,8 +336,10 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
        struct nfs_pageio_descriptor pgio;
        int err;
 
-       nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc),
-                             &nfs_async_write_completion_ops);
+       NFS_PROTO(page->mapping->host)->write_pageio_init(&pgio,
+                                                         page->mapping->host,
+                                                         wb_priority(wbc),
+                                                         &nfs_async_write_completion_ops);
        err = nfs_do_writepage(page, wbc, &pgio);
        nfs_pageio_complete(&pgio);
        if (err < 0)
@@ -380,8 +382,7 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
 
        nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES);
 
-       nfs_pageio_init_write(&pgio, inode, wb_priority(wbc),
-                             &nfs_async_write_completion_ops);
+       NFS_PROTO(inode)->write_pageio_init(&pgio, inode, wb_priority(wbc), &nfs_async_write_completion_ops);
        err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio);
        nfs_pageio_complete(&pgio);
 
@@ -1202,7 +1203,7 @@ static const struct nfs_pageio_ops nfs_pageio_write_ops = {
        .pg_doio = nfs_generic_pg_writepages,
 };
 
-void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
+void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
                               struct inode *inode, int ioflags,
                               const struct nfs_pgio_completion_ops *compl_ops)
 {
@@ -1217,13 +1218,6 @@ void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
 }
 EXPORT_SYMBOL_GPL(nfs_pageio_reset_write_mds);
 
-void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
-                          struct inode *inode, int ioflags,
-                          const struct nfs_pgio_completion_ops *compl_ops)
-{
-       if (!pnfs_pageio_init_write(pgio, inode, ioflags, compl_ops))
-               nfs_pageio_init_write_mds(pgio, inode, ioflags, compl_ops);
-}
 
 void nfs_write_prepare(struct rpc_task *task, void *calldata)
 {
index e00b8b3c334e6bb679dc9af754415f1ca3cd0277..8ed8ec628290af3e754d49216c57e0356d028c69 100644 (file)
@@ -1413,6 +1413,8 @@ struct nfs_rpc_ops {
        void    (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *);
        int     (*read_done)  (struct rpc_task *, struct nfs_read_data *);
        void    (*write_setup)  (struct nfs_write_data *, struct rpc_message *);
+       void    (*write_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, int,
+                                    const struct nfs_pgio_completion_ops *);
        void    (*write_rpc_prepare)(struct rpc_task *, struct nfs_write_data *);
        int     (*write_done)  (struct rpc_task *, struct nfs_write_data *);
        void    (*commit_setup) (struct nfs_commit_data *, struct rpc_message *);