Commit a01b077a authored by Olga Kornievskaia's avatar Olga Kornievskaia Committed by Trond Myklebust

pNFS: rework pnfs_generic_pg_check_layout to check IO range

All callers of pnfs_generic_pg_check_layout() also want to do a call to
check that the layout's range covers the IO range. Merge the functionality
of the pnfs_generic_pg_check_range() into that of
pnfs_generic_pg_check_layout().
Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 523412b9
...@@ -867,8 +867,7 @@ static void ...@@ -867,8 +867,7 @@ static void
filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio, filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req) struct nfs_page *req)
{ {
pnfs_generic_pg_check_layout(pgio); pnfs_generic_pg_check_layout(pgio, req);
pnfs_generic_pg_check_range(pgio, req);
if (!pgio->pg_lseg) { if (!pgio->pg_lseg) {
pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode,
nfs_req_openctx(req), nfs_req_openctx(req),
...@@ -892,8 +891,7 @@ static void ...@@ -892,8 +891,7 @@ static void
filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req) struct nfs_page *req)
{ {
pnfs_generic_pg_check_layout(pgio); pnfs_generic_pg_check_layout(pgio, req);
pnfs_generic_pg_check_range(pgio, req);
if (!pgio->pg_lseg) { if (!pgio->pg_lseg) {
pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode,
nfs_req_openctx(req), nfs_req_openctx(req),
......
...@@ -822,14 +822,6 @@ ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, ...@@ -822,14 +822,6 @@ ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio,
} }
} }
static void
ff_layout_pg_check_layout(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req)
{
pnfs_generic_pg_check_layout(pgio);
pnfs_generic_pg_check_range(pgio, req);
}
static void static void
ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req) struct nfs_page *req)
...@@ -840,7 +832,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, ...@@ -840,7 +832,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
u32 ds_idx; u32 ds_idx;
retry: retry:
ff_layout_pg_check_layout(pgio, req); pnfs_generic_pg_check_layout(pgio, req);
/* Use full layout for now */ /* Use full layout for now */
if (!pgio->pg_lseg) { if (!pgio->pg_lseg) {
ff_layout_pg_get_read(pgio, req, false); ff_layout_pg_get_read(pgio, req, false);
...@@ -895,7 +887,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, ...@@ -895,7 +887,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
u32 i; u32 i;
retry: retry:
ff_layout_pg_check_layout(pgio, req); pnfs_generic_pg_check_layout(pgio, req);
if (!pgio->pg_lseg) { if (!pgio->pg_lseg) {
pgio->pg_lseg = pgio->pg_lseg =
pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req),
......
...@@ -2705,38 +2705,28 @@ pnfs_layout_return_unused_byclid(struct nfs_client *clp, ...@@ -2705,38 +2705,28 @@ pnfs_layout_return_unused_byclid(struct nfs_client *clp,
&range); &range);
} }
/* Check if we have we have a valid layout but if there isn't an intersection
* between the request and the pgio->pg_lseg, put this pgio->pg_lseg away.
*/
void void
pnfs_generic_pg_check_layout(struct nfs_pageio_descriptor *pgio) pnfs_generic_pg_check_layout(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req)
{ {
if (pgio->pg_lseg == NULL || if (pgio->pg_lseg == NULL ||
test_bit(NFS_LSEG_VALID, &pgio->pg_lseg->pls_flags)) (test_bit(NFS_LSEG_VALID, &pgio->pg_lseg->pls_flags) &&
pnfs_lseg_request_intersecting(pgio->pg_lseg, req)))
return; return;
pnfs_put_lseg(pgio->pg_lseg); pnfs_put_lseg(pgio->pg_lseg);
pgio->pg_lseg = NULL; pgio->pg_lseg = NULL;
} }
EXPORT_SYMBOL_GPL(pnfs_generic_pg_check_layout); EXPORT_SYMBOL_GPL(pnfs_generic_pg_check_layout);
/*
* Check for any intersection between the request and the pgio->pg_lseg,
* and if none, put this pgio->pg_lseg away.
*/
void
pnfs_generic_pg_check_range(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
{
if (pgio->pg_lseg && !pnfs_lseg_request_intersecting(pgio->pg_lseg, req)) {
pnfs_put_lseg(pgio->pg_lseg);
pgio->pg_lseg = NULL;
}
}
EXPORT_SYMBOL_GPL(pnfs_generic_pg_check_range);
void void
pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
{ {
u64 rd_size; u64 rd_size;
pnfs_generic_pg_check_layout(pgio); pnfs_generic_pg_check_layout(pgio, req);
pnfs_generic_pg_check_range(pgio, req);
if (pgio->pg_lseg == NULL) { if (pgio->pg_lseg == NULL) {
if (pgio->pg_dreq == NULL) if (pgio->pg_dreq == NULL)
rd_size = i_size_read(pgio->pg_inode) - req_offset(req); rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
...@@ -2766,8 +2756,7 @@ void ...@@ -2766,8 +2756,7 @@ void
pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
struct nfs_page *req, u64 wb_size) struct nfs_page *req, u64 wb_size)
{ {
pnfs_generic_pg_check_layout(pgio); pnfs_generic_pg_check_layout(pgio, req);
pnfs_generic_pg_check_range(pgio, req);
if (pgio->pg_lseg == NULL) { if (pgio->pg_lseg == NULL) {
pgio->pg_lseg = pgio->pg_lseg =
pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req), pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req),
......
...@@ -257,8 +257,7 @@ void pnfs_put_lseg(struct pnfs_layout_segment *lseg); ...@@ -257,8 +257,7 @@ void pnfs_put_lseg(struct pnfs_layout_segment *lseg);
void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, struct nfs_fsinfo *); void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, struct nfs_fsinfo *);
void unset_pnfs_layoutdriver(struct nfs_server *); void unset_pnfs_layoutdriver(struct nfs_server *);
void pnfs_generic_pg_check_layout(struct nfs_pageio_descriptor *pgio); void pnfs_generic_pg_check_layout(struct nfs_pageio_descriptor *pgio, struct nfs_page *req);
void pnfs_generic_pg_check_range(struct nfs_pageio_descriptor *pgio, struct nfs_page *req);
void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *); void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc); int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment