Skip to content

Commit

Permalink
NFS: Create an read_pageio_init() function
Browse files Browse the repository at this point in the history
pNFS needs to select a read function based on the layout driver
currently in use, so I let each NFS version decide how to best handle
initializing reads.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Bryan Schumaker authored and Trond Myklebust committed Jun 29, 2012
1 parent 6663ee7 commit 1abb508
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ extern int nfs_initiate_read(struct rpc_clnt *clnt,
extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr);
extern void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio,
extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
struct inode *inode,
const struct nfs_pgio_completion_ops *compl_ops);
extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/nfs3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
.pathconf = nfs3_proc_pathconf,
.decode_dirent = nfs3_decode_dirent,
.read_setup = nfs3_proc_read_setup,
.read_pageio_init = nfs_pageio_init_read,
.read_rpc_prepare = nfs3_proc_read_rpc_prepare,
.read_done = nfs3_read_done,
.write_setup = nfs3_proc_write_setup,
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6792,6 +6792,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.set_capabilities = nfs4_server_capabilities,
.decode_dirent = nfs4_decode_dirent,
.read_setup = nfs4_proc_read_setup,
.read_pageio_init = pnfs_pageio_init_read,
.read_rpc_prepare = nfs4_proc_read_rpc_prepare,
.read_done = nfs4_read_done,
.write_setup = nfs4_proc_write_setup,
Expand Down
11 changes: 5 additions & 6 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,18 +1209,17 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *
}
EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);

bool
void
pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode,
const struct nfs_pgio_completion_ops *compl_ops)
{
struct nfs_server *server = NFS_SERVER(inode);
struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld;

if (ld == NULL)
return false;
nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops,
server->rsize, 0);
return true;
nfs_pageio_init_read(pgio, inode, compl_ops);
else
nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0);
}

bool
Expand Down Expand Up @@ -1427,7 +1426,7 @@ int pnfs_read_done_resend_to_mds(struct inode *inode,
LIST_HEAD(failed);

/* Resend all requests through the MDS */
nfs_pageio_init_read_mds(&pgio, inode, compl_ops);
nfs_pageio_init_read(&pgio, inode, compl_ops);
while (!list_empty(head)) {
struct nfs_page *req = nfs_list_entry(head->next);

Expand Down
6 changes: 3 additions & 3 deletions fs/nfs/pnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
void get_layout_hdr(struct pnfs_layout_hdr *lo);
void put_lseg(struct pnfs_layout_segment *lseg);

bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *,
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 *,
int, const struct nfs_pgio_completion_ops *);
Expand Down Expand Up @@ -438,10 +438,10 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s)
{
}

static inline bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode,
static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode,
const struct nfs_pgio_completion_ops *compl_ops)
{
return false;
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,
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
.pathconf = nfs_proc_pathconf,
.decode_dirent = nfs2_decode_dirent,
.read_setup = nfs_proc_read_setup,
.read_pageio_init = nfs_pageio_init_read,
.read_rpc_prepare = nfs_proc_read_rpc_prepare,
.read_done = nfs_read_done,
.write_setup = nfs_proc_write_setup,
Expand Down
16 changes: 3 additions & 13 deletions fs/nfs/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <linux/nfs_page.h>
#include <linux/module.h>

#include "pnfs.h"

#include "nfs4_fs.h"
#include "internal.h"
#include "iostat.h"
Expand Down Expand Up @@ -108,7 +106,7 @@ int nfs_return_empty_page(struct page *page)
return 0;
}

void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio,
void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
struct inode *inode,
const struct nfs_pgio_completion_ops *compl_ops)
{
Expand All @@ -123,14 +121,6 @@ void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio)
}
EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds);

void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
struct inode *inode,
const struct nfs_pgio_completion_ops *compl_ops)
{
if (!pnfs_pageio_init_read(pgio, inode, compl_ops))
nfs_pageio_init_read_mds(pgio, inode, compl_ops);
}

int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
struct page *page)
{
Expand All @@ -149,7 +139,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
if (len < PAGE_CACHE_SIZE)
zero_user_segment(page, len, PAGE_CACHE_SIZE);

nfs_pageio_init_read(&pgio, inode, &nfs_async_read_completion_ops);
NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops);
nfs_pageio_add_request(&pgio, new);
nfs_pageio_complete(&pgio);
NFS_I(inode)->read_io += pgio.pg_bytes_written;
Expand Down Expand Up @@ -652,7 +642,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
if (ret == 0)
goto read_complete; /* all pages were read */

nfs_pageio_init_read(&pgio, inode, &nfs_async_read_completion_ops);
NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops);

ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);

Expand Down
3 changes: 3 additions & 0 deletions include/linux/nfs_xdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ struct nfs_access_entry;
struct nfs_client;
struct rpc_timeout;
struct nfs_client_initdata;
struct nfs_pageio_descriptor;

/*
* RPC procedure vector for NFSv2/NFSv3 demuxing
Expand Down Expand Up @@ -1407,6 +1408,8 @@ struct nfs_rpc_ops {
int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
void (*read_pageio_init)(struct nfs_pageio_descriptor *, struct inode *,
const struct nfs_pgio_completion_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 *);
Expand Down

0 comments on commit 1abb508

Please sign in to comment.