Commit 180bb5ec authored by Weston Andros Adamson's avatar Weston Andros Adamson Committed by Tom Haynes

pnfs: release lseg in pnfs_generic_pg_cleanup

This is needed to support mirrored writes - the first write can't just
trash the lseg, we need to keep it around until all mirrors have
written.
Signed-off-by: default avatarWeston Andros Adamson <dros@primarydata.com>
parent 2176bf42
...@@ -860,12 +860,14 @@ static const struct nfs_pageio_ops bl_pg_read_ops = { ...@@ -860,12 +860,14 @@ static const struct nfs_pageio_ops bl_pg_read_ops = {
.pg_init = bl_pg_init_read, .pg_init = bl_pg_init_read,
.pg_test = bl_pg_test_read, .pg_test = bl_pg_test_read,
.pg_doio = pnfs_generic_pg_readpages, .pg_doio = pnfs_generic_pg_readpages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static const struct nfs_pageio_ops bl_pg_write_ops = { static const struct nfs_pageio_ops bl_pg_write_ops = {
.pg_init = bl_pg_init_write, .pg_init = bl_pg_init_write,
.pg_test = bl_pg_test_write, .pg_test = bl_pg_test_write,
.pg_doio = pnfs_generic_pg_writepages, .pg_doio = pnfs_generic_pg_writepages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static struct pnfs_layoutdriver_type blocklayout_type = { static struct pnfs_layoutdriver_type blocklayout_type = {
......
...@@ -933,12 +933,14 @@ static const struct nfs_pageio_ops filelayout_pg_read_ops = { ...@@ -933,12 +933,14 @@ static const struct nfs_pageio_ops filelayout_pg_read_ops = {
.pg_init = filelayout_pg_init_read, .pg_init = filelayout_pg_init_read,
.pg_test = filelayout_pg_test, .pg_test = filelayout_pg_test,
.pg_doio = pnfs_generic_pg_readpages, .pg_doio = pnfs_generic_pg_readpages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static const struct nfs_pageio_ops filelayout_pg_write_ops = { static const struct nfs_pageio_ops filelayout_pg_write_ops = {
.pg_init = filelayout_pg_init_write, .pg_init = filelayout_pg_init_write,
.pg_test = filelayout_pg_test, .pg_test = filelayout_pg_test,
.pg_doio = pnfs_generic_pg_writepages, .pg_doio = pnfs_generic_pg_writepages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j) static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
......
...@@ -607,12 +607,14 @@ static const struct nfs_pageio_ops objio_pg_read_ops = { ...@@ -607,12 +607,14 @@ static const struct nfs_pageio_ops objio_pg_read_ops = {
.pg_init = objio_init_read, .pg_init = objio_init_read,
.pg_test = objio_pg_test, .pg_test = objio_pg_test,
.pg_doio = pnfs_generic_pg_readpages, .pg_doio = pnfs_generic_pg_readpages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static const struct nfs_pageio_ops objio_pg_write_ops = { static const struct nfs_pageio_ops objio_pg_write_ops = {
.pg_init = objio_init_write, .pg_init = objio_init_write,
.pg_test = objio_pg_test, .pg_test = objio_pg_test,
.pg_doio = pnfs_generic_pg_writepages, .pg_doio = pnfs_generic_pg_writepages,
.pg_cleanup = pnfs_generic_pg_cleanup,
}; };
static struct pnfs_layoutdriver_type objlayout_type = { static struct pnfs_layoutdriver_type objlayout_type = {
......
...@@ -1631,6 +1631,16 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, ...@@ -1631,6 +1631,16 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
} }
EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
void
pnfs_generic_pg_cleanup(struct nfs_pageio_descriptor *desc)
{
if (desc->pg_lseg) {
pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
}
}
EXPORT_SYMBOL_GPL(pnfs_generic_pg_cleanup);
/* /*
* Return 0 if @req cannot be coalesced into @pgio, otherwise return the number * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
* of bytes (maximum @req->wb_bytes) that can be coalesced. * of bytes (maximum @req->wb_bytes) that can be coalesced.
...@@ -1756,11 +1766,9 @@ pnfs_do_write(struct nfs_pageio_descriptor *desc, ...@@ -1756,11 +1766,9 @@ pnfs_do_write(struct nfs_pageio_descriptor *desc,
struct pnfs_layout_segment *lseg = desc->pg_lseg; struct pnfs_layout_segment *lseg = desc->pg_lseg;
enum pnfs_try_status trypnfs; enum pnfs_try_status trypnfs;
desc->pg_lseg = NULL;
trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how); trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how);
if (trypnfs == PNFS_NOT_ATTEMPTED) if (trypnfs == PNFS_NOT_ATTEMPTED)
pnfs_write_through_mds(desc, hdr); pnfs_write_through_mds(desc, hdr);
pnfs_put_lseg(lseg);
} }
static void pnfs_writehdr_free(struct nfs_pgio_header *hdr) static void pnfs_writehdr_free(struct nfs_pgio_header *hdr)
...@@ -1779,17 +1787,13 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc) ...@@ -1779,17 +1787,13 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
hdr = nfs_pgio_header_alloc(desc->pg_rw_ops); hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
if (!hdr) { if (!hdr) {
desc->pg_completion_ops->error_cleanup(&desc->pg_list); desc->pg_completion_ops->error_cleanup(&desc->pg_list);
pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
return -ENOMEM; return -ENOMEM;
} }
nfs_pgheader_init(desc, hdr, pnfs_writehdr_free); nfs_pgheader_init(desc, hdr, pnfs_writehdr_free);
hdr->lseg = pnfs_get_lseg(desc->pg_lseg); hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
ret = nfs_generic_pgio(desc, hdr); ret = nfs_generic_pgio(desc, hdr);
if (ret != 0) { if (!ret)
pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
} else
pnfs_do_write(desc, hdr, desc->pg_ioflags); pnfs_do_write(desc, hdr, desc->pg_ioflags);
return ret; return ret;
} }
...@@ -1874,11 +1878,9 @@ pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr) ...@@ -1874,11 +1878,9 @@ pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr)
struct pnfs_layout_segment *lseg = desc->pg_lseg; struct pnfs_layout_segment *lseg = desc->pg_lseg;
enum pnfs_try_status trypnfs; enum pnfs_try_status trypnfs;
desc->pg_lseg = NULL;
trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg); trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg);
if (trypnfs == PNFS_NOT_ATTEMPTED) if (trypnfs == PNFS_NOT_ATTEMPTED)
pnfs_read_through_mds(desc, hdr); pnfs_read_through_mds(desc, hdr);
pnfs_put_lseg(lseg);
} }
static void pnfs_readhdr_free(struct nfs_pgio_header *hdr) static void pnfs_readhdr_free(struct nfs_pgio_header *hdr)
...@@ -1897,18 +1899,12 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc) ...@@ -1897,18 +1899,12 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
hdr = nfs_pgio_header_alloc(desc->pg_rw_ops); hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
if (!hdr) { if (!hdr) {
desc->pg_completion_ops->error_cleanup(&desc->pg_list); desc->pg_completion_ops->error_cleanup(&desc->pg_list);
ret = -ENOMEM; return -ENOMEM;
pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
return ret;
} }
nfs_pgheader_init(desc, hdr, pnfs_readhdr_free); nfs_pgheader_init(desc, hdr, pnfs_readhdr_free);
hdr->lseg = pnfs_get_lseg(desc->pg_lseg); hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
ret = nfs_generic_pgio(desc, hdr); ret = nfs_generic_pgio(desc, hdr);
if (ret != 0) { if (!ret)
pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL;
} else
pnfs_do_read(desc, hdr); pnfs_do_read(desc, hdr);
return ret; return ret;
} }
......
...@@ -230,6 +230,7 @@ void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page * ...@@ -230,6 +230,7 @@ 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,
struct nfs_page *req, u64 wb_size); struct nfs_page *req, u64 wb_size);
void pnfs_generic_pg_cleanup(struct nfs_pageio_descriptor *);
int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio,
struct nfs_page *prev, struct nfs_page *req); struct nfs_page *prev, struct nfs_page *req);
......
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