NFSv4.1: Add an initialisation callback for pNFS
Ensure that we always get a layout before setting up the i/o request. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
1751c3638f
commit
d8007d4dd6
8 changed files with 47 additions and 59 deletions
|
@ -682,11 +682,13 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct nfs_pageio_ops filelayout_pg_read_ops = {
|
static const struct nfs_pageio_ops filelayout_pg_read_ops = {
|
||||||
|
.pg_init = pnfs_generic_pg_init_read,
|
||||||
.pg_test = filelayout_pg_test,
|
.pg_test = filelayout_pg_test,
|
||||||
.pg_doio = nfs_generic_pg_readpages,
|
.pg_doio = nfs_generic_pg_readpages,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct nfs_pageio_ops filelayout_pg_write_ops = {
|
static const struct nfs_pageio_ops filelayout_pg_write_ops = {
|
||||||
|
.pg_init = pnfs_generic_pg_init_write,
|
||||||
.pg_test = filelayout_pg_test,
|
.pg_test = filelayout_pg_test,
|
||||||
.pg_doio = nfs_generic_pg_writepages,
|
.pg_doio = nfs_generic_pg_writepages,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1008,11 +1008,13 @@ static bool objio_pg_test(struct nfs_pageio_descriptor *pgio,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct nfs_pageio_ops objio_pg_read_ops = {
|
static const struct nfs_pageio_ops objio_pg_read_ops = {
|
||||||
|
.pg_init = pnfs_generic_pg_init_read,
|
||||||
.pg_test = objio_pg_test,
|
.pg_test = objio_pg_test,
|
||||||
.pg_doio = nfs_generic_pg_readpages,
|
.pg_doio = nfs_generic_pg_readpages,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct nfs_pageio_ops objio_pg_write_ops = {
|
static const struct nfs_pageio_ops objio_pg_write_ops = {
|
||||||
|
.pg_init = pnfs_generic_pg_init_write,
|
||||||
.pg_test = objio_pg_test,
|
.pg_test = objio_pg_test,
|
||||||
.pg_doio = nfs_generic_pg_writepages,
|
.pg_doio = nfs_generic_pg_writepages,
|
||||||
};
|
};
|
||||||
|
|
|
@ -295,6 +295,8 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
|
||||||
if (!nfs_can_coalesce_requests(prev, req, desc))
|
if (!nfs_can_coalesce_requests(prev, req, desc))
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (desc->pg_ops->pg_init)
|
||||||
|
desc->pg_ops->pg_init(desc, req);
|
||||||
desc->pg_base = req->wb_pgbase;
|
desc->pg_base = req->wb_pgbase;
|
||||||
}
|
}
|
||||||
nfs_list_remove_request(req);
|
nfs_list_remove_request(req);
|
||||||
|
|
|
@ -911,7 +911,7 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo,
|
||||||
* Layout segment is retreived from the server if not cached.
|
* Layout segment is retreived from the server if not cached.
|
||||||
* The appropriate layout segment is referenced and returned to the caller.
|
* The appropriate layout segment is referenced and returned to the caller.
|
||||||
*/
|
*/
|
||||||
struct pnfs_layout_segment *
|
static struct pnfs_layout_segment *
|
||||||
pnfs_update_layout(struct inode *ino,
|
pnfs_update_layout(struct inode *ino,
|
||||||
struct nfs_open_context *ctx,
|
struct nfs_open_context *ctx,
|
||||||
loff_t pos,
|
loff_t pos,
|
||||||
|
@ -1055,6 +1055,34 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
|
||||||
|
{
|
||||||
|
BUG_ON(pgio->pg_lseg != NULL);
|
||||||
|
|
||||||
|
pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
|
||||||
|
req->wb_context,
|
||||||
|
req_offset(req),
|
||||||
|
req->wb_bytes,
|
||||||
|
IOMODE_READ,
|
||||||
|
GFP_KERNEL);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read);
|
||||||
|
|
||||||
|
void
|
||||||
|
pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
|
||||||
|
{
|
||||||
|
BUG_ON(pgio->pg_lseg != NULL);
|
||||||
|
|
||||||
|
pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
|
||||||
|
req->wb_context,
|
||||||
|
req_offset(req),
|
||||||
|
req->wb_bytes,
|
||||||
|
IOMODE_RW,
|
||||||
|
GFP_NOFS);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode)
|
pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode)
|
||||||
{
|
{
|
||||||
|
@ -1083,31 +1111,8 @@ bool
|
||||||
pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
||||||
struct nfs_page *req)
|
struct nfs_page *req)
|
||||||
{
|
{
|
||||||
enum pnfs_iomode access_type;
|
if (pgio->pg_lseg == NULL)
|
||||||
gfp_t gfp_flags;
|
return nfs_generic_pg_test(pgio, prev, req);
|
||||||
|
|
||||||
/* We assume that pg_ioflags == 0 iff we're reading a page */
|
|
||||||
if (pgio->pg_ioflags == 0) {
|
|
||||||
access_type = IOMODE_READ;
|
|
||||||
gfp_flags = GFP_KERNEL;
|
|
||||||
} else {
|
|
||||||
access_type = IOMODE_RW;
|
|
||||||
gfp_flags = GFP_NOFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pgio->pg_lseg == NULL) {
|
|
||||||
if (pgio->pg_count != prev->wb_bytes)
|
|
||||||
return true;
|
|
||||||
/* This is first coelesce call for a series of nfs_pages */
|
|
||||||
pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
|
|
||||||
prev->wb_context,
|
|
||||||
req_offset(prev),
|
|
||||||
pgio->pg_count,
|
|
||||||
access_type,
|
|
||||||
gfp_flags);
|
|
||||||
if (pgio->pg_lseg == NULL)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test if a nfs_page is fully contained in the pnfs_layout_range.
|
* Test if a nfs_page is fully contained in the pnfs_layout_range.
|
||||||
|
|
|
@ -149,10 +149,6 @@ extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
|
||||||
/* pnfs.c */
|
/* pnfs.c */
|
||||||
void get_layout_hdr(struct pnfs_layout_hdr *lo);
|
void get_layout_hdr(struct pnfs_layout_hdr *lo);
|
||||||
void put_lseg(struct pnfs_layout_segment *lseg);
|
void put_lseg(struct pnfs_layout_segment *lseg);
|
||||||
struct pnfs_layout_segment *
|
|
||||||
pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
|
|
||||||
loff_t pos, u64 count, enum pnfs_iomode access_type,
|
|
||||||
gfp_t gfp_flags);
|
|
||||||
|
|
||||||
bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *);
|
bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *);
|
||||||
bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, int);
|
bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, int);
|
||||||
|
@ -163,6 +159,8 @@ enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
|
||||||
const struct rpc_call_ops *, int);
|
const struct rpc_call_ops *, int);
|
||||||
enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
|
enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
|
||||||
const struct rpc_call_ops *);
|
const struct rpc_call_ops *);
|
||||||
|
void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
|
||||||
|
void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *);
|
||||||
bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
|
bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
|
||||||
int pnfs_layout_process(struct nfs4_layoutget *lgp);
|
int pnfs_layout_process(struct nfs4_layoutget *lgp);
|
||||||
void pnfs_free_lseg_list(struct list_head *tmp_list);
|
void pnfs_free_lseg_list(struct list_head *tmp_list);
|
||||||
|
@ -318,14 +316,6 @@ static inline void put_lseg(struct pnfs_layout_segment *lseg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct pnfs_layout_segment *
|
|
||||||
pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
|
|
||||||
loff_t pos, u64 count, enum pnfs_iomode access_type,
|
|
||||||
gfp_t gfp_flags)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum pnfs_try_status
|
static inline enum pnfs_try_status
|
||||||
pnfs_try_to_read_data(struct nfs_read_data *data,
|
pnfs_try_to_read_data(struct nfs_read_data *data,
|
||||||
const struct rpc_call_ops *call_ops)
|
const struct rpc_call_ops *call_ops)
|
||||||
|
|
|
@ -147,9 +147,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
|
||||||
zero_user_segment(page, len, PAGE_CACHE_SIZE);
|
zero_user_segment(page, len, PAGE_CACHE_SIZE);
|
||||||
|
|
||||||
nfs_pageio_init_read(&pgio, inode);
|
nfs_pageio_init_read(&pgio, inode);
|
||||||
nfs_list_add_request(new, &pgio.pg_list);
|
nfs_pageio_add_request(&pgio, new);
|
||||||
pgio.pg_count = len;
|
|
||||||
|
|
||||||
nfs_pageio_complete(&pgio);
|
nfs_pageio_complete(&pgio);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +279,7 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
int requests = 0;
|
int requests = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct pnfs_layout_segment *lseg;
|
struct pnfs_layout_segment *lseg = desc->pg_lseg;
|
||||||
LIST_HEAD(list);
|
LIST_HEAD(list);
|
||||||
|
|
||||||
nfs_list_remove_request(req);
|
nfs_list_remove_request(req);
|
||||||
|
@ -299,10 +297,6 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
|
||||||
} while(nbytes != 0);
|
} while(nbytes != 0);
|
||||||
atomic_set(&req->wb_complete, requests);
|
atomic_set(&req->wb_complete, requests);
|
||||||
|
|
||||||
BUG_ON(desc->pg_lseg != NULL);
|
|
||||||
lseg = pnfs_update_layout(desc->pg_inode, req->wb_context,
|
|
||||||
req_offset(req), desc->pg_count,
|
|
||||||
IOMODE_READ, GFP_KERNEL);
|
|
||||||
ClearPageError(page);
|
ClearPageError(page);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
nbytes = desc->pg_count;
|
nbytes = desc->pg_count;
|
||||||
|
@ -336,6 +330,8 @@ static int nfs_pagein_multi(struct nfs_pageio_descriptor *desc)
|
||||||
}
|
}
|
||||||
SetPageError(page);
|
SetPageError(page);
|
||||||
nfs_readpage_release(req);
|
nfs_readpage_release(req);
|
||||||
|
put_lseg(lseg);
|
||||||
|
desc->pg_lseg = NULL;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,10 +360,6 @@ static int nfs_pagein_one(struct nfs_pageio_descriptor *desc)
|
||||||
*pages++ = req->wb_page;
|
*pages++ = req->wb_page;
|
||||||
}
|
}
|
||||||
req = nfs_list_entry(data->pages.next);
|
req = nfs_list_entry(data->pages.next);
|
||||||
if ((!lseg) && list_is_singular(&data->pages))
|
|
||||||
lseg = pnfs_update_layout(desc->pg_inode, req->wb_context,
|
|
||||||
req_offset(req), desc->pg_count,
|
|
||||||
IOMODE_READ, GFP_KERNEL);
|
|
||||||
|
|
||||||
ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count,
|
ret = nfs_read_rpcsetup(req, data, &nfs_read_full_ops, desc->pg_count,
|
||||||
0, lseg);
|
0, lseg);
|
||||||
|
|
|
@ -916,7 +916,7 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
int requests = 0;
|
int requests = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct pnfs_layout_segment *lseg;
|
struct pnfs_layout_segment *lseg = desc->pg_lseg;
|
||||||
LIST_HEAD(list);
|
LIST_HEAD(list);
|
||||||
|
|
||||||
nfs_list_remove_request(req);
|
nfs_list_remove_request(req);
|
||||||
|
@ -940,10 +940,6 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
|
||||||
} while (nbytes != 0);
|
} while (nbytes != 0);
|
||||||
atomic_set(&req->wb_complete, requests);
|
atomic_set(&req->wb_complete, requests);
|
||||||
|
|
||||||
BUG_ON(desc->pg_lseg);
|
|
||||||
lseg = pnfs_update_layout(desc->pg_inode, req->wb_context,
|
|
||||||
req_offset(req), desc->pg_count,
|
|
||||||
IOMODE_RW, GFP_NOFS);
|
|
||||||
ClearPageError(page);
|
ClearPageError(page);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
nbytes = desc->pg_count;
|
nbytes = desc->pg_count;
|
||||||
|
@ -976,6 +972,8 @@ static int nfs_flush_multi(struct nfs_pageio_descriptor *desc)
|
||||||
nfs_writedata_free(data);
|
nfs_writedata_free(data);
|
||||||
}
|
}
|
||||||
nfs_redirty_request(req);
|
nfs_redirty_request(req);
|
||||||
|
put_lseg(lseg);
|
||||||
|
desc->pg_lseg = NULL;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,10 +1014,6 @@ static int nfs_flush_one(struct nfs_pageio_descriptor *desc)
|
||||||
*pages++ = req->wb_page;
|
*pages++ = req->wb_page;
|
||||||
}
|
}
|
||||||
req = nfs_list_entry(data->pages.next);
|
req = nfs_list_entry(data->pages.next);
|
||||||
if ((!lseg) && list_is_singular(&data->pages))
|
|
||||||
lseg = pnfs_update_layout(desc->pg_inode, req->wb_context,
|
|
||||||
req_offset(req), desc->pg_count,
|
|
||||||
IOMODE_RW, GFP_NOFS);
|
|
||||||
|
|
||||||
if ((desc->pg_ioflags & FLUSH_COND_STABLE) &&
|
if ((desc->pg_ioflags & FLUSH_COND_STABLE) &&
|
||||||
(desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit))
|
(desc->pg_moreio || NFS_I(desc->pg_inode)->ncommit))
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct nfs_page {
|
||||||
|
|
||||||
struct nfs_pageio_descriptor;
|
struct nfs_pageio_descriptor;
|
||||||
struct nfs_pageio_ops {
|
struct nfs_pageio_ops {
|
||||||
|
void (*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *);
|
||||||
bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
|
bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
|
||||||
int (*pg_doio)(struct nfs_pageio_descriptor *);
|
int (*pg_doio)(struct nfs_pageio_descriptor *);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue