aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 63992c826faf..2da2e771fefe 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1631,6 +1631,16 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
1631} 1631}
1632EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); 1632EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
1633 1633
1634void
1635pnfs_generic_pg_cleanup(struct nfs_pageio_descriptor *desc)
1636{
1637 if (desc->pg_lseg) {
1638 pnfs_put_lseg(desc->pg_lseg);
1639 desc->pg_lseg = NULL;
1640 }
1641}
1642EXPORT_SYMBOL_GPL(pnfs_generic_pg_cleanup);
1643
1634/* 1644/*
1635 * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number 1645 * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
1636 * of bytes (maximum @req->wb_bytes) that can be coalesced. 1646 * of bytes (maximum @req->wb_bytes) that can be coalesced.
@@ -1756,11 +1766,9 @@ pnfs_do_write(struct nfs_pageio_descriptor *desc,
1756 struct pnfs_layout_segment *lseg = desc->pg_lseg; 1766 struct pnfs_layout_segment *lseg = desc->pg_lseg;
1757 enum pnfs_try_status trypnfs; 1767 enum pnfs_try_status trypnfs;
1758 1768
1759 desc->pg_lseg = NULL;
1760 trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how); 1769 trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how);
1761 if (trypnfs == PNFS_NOT_ATTEMPTED) 1770 if (trypnfs == PNFS_NOT_ATTEMPTED)
1762 pnfs_write_through_mds(desc, hdr); 1771 pnfs_write_through_mds(desc, hdr);
1763 pnfs_put_lseg(lseg);
1764} 1772}
1765 1773
1766static void pnfs_writehdr_free(struct nfs_pgio_header *hdr) 1774static void pnfs_writehdr_free(struct nfs_pgio_header *hdr)
@@ -1779,17 +1787,13 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
1779 hdr = nfs_pgio_header_alloc(desc->pg_rw_ops); 1787 hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
1780 if (!hdr) { 1788 if (!hdr) {
1781 desc->pg_completion_ops->error_cleanup(&desc->pg_list); 1789 desc->pg_completion_ops->error_cleanup(&desc->pg_list);
1782 pnfs_put_lseg(desc->pg_lseg);
1783 desc->pg_lseg = NULL;
1784 return -ENOMEM; 1790 return -ENOMEM;
1785 } 1791 }
1786 nfs_pgheader_init(desc, hdr, pnfs_writehdr_free); 1792 nfs_pgheader_init(desc, hdr, pnfs_writehdr_free);
1793
1787 hdr->lseg = pnfs_get_lseg(desc->pg_lseg); 1794 hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
1788 ret = nfs_generic_pgio(desc, hdr); 1795 ret = nfs_generic_pgio(desc, hdr);
1789 if (ret != 0) { 1796 if (!ret)
1790 pnfs_put_lseg(desc->pg_lseg);
1791 desc->pg_lseg = NULL;
1792 } else
1793 pnfs_do_write(desc, hdr, desc->pg_ioflags); 1797 pnfs_do_write(desc, hdr, desc->pg_ioflags);
1794 return ret; 1798 return ret;
1795} 1799}
@@ -1874,11 +1878,9 @@ pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr)
1874 struct pnfs_layout_segment *lseg = desc->pg_lseg; 1878 struct pnfs_layout_segment *lseg = desc->pg_lseg;
1875 enum pnfs_try_status trypnfs; 1879 enum pnfs_try_status trypnfs;
1876 1880
1877 desc->pg_lseg = NULL;
1878 trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg); 1881 trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg);
1879 if (trypnfs == PNFS_NOT_ATTEMPTED) 1882 if (trypnfs == PNFS_NOT_ATTEMPTED)
1880 pnfs_read_through_mds(desc, hdr); 1883 pnfs_read_through_mds(desc, hdr);
1881 pnfs_put_lseg(lseg);
1882} 1884}
1883 1885
1884static void pnfs_readhdr_free(struct nfs_pgio_header *hdr) 1886static void pnfs_readhdr_free(struct nfs_pgio_header *hdr)
@@ -1897,18 +1899,12 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
1897 hdr = nfs_pgio_header_alloc(desc->pg_rw_ops); 1899 hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
1898 if (!hdr) { 1900 if (!hdr) {
1899 desc->pg_completion_ops->error_cleanup(&desc->pg_list); 1901 desc->pg_completion_ops->error_cleanup(&desc->pg_list);
1900 ret = -ENOMEM; 1902 return -ENOMEM;
1901 pnfs_put_lseg(desc->pg_lseg);
1902 desc->pg_lseg = NULL;
1903 return ret;
1904 } 1903 }
1905 nfs_pgheader_init(desc, hdr, pnfs_readhdr_free); 1904 nfs_pgheader_init(desc, hdr, pnfs_readhdr_free);
1906 hdr->lseg = pnfs_get_lseg(desc->pg_lseg); 1905 hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
1907 ret = nfs_generic_pgio(desc, hdr); 1906 ret = nfs_generic_pgio(desc, hdr);
1908 if (ret != 0) { 1907 if (!ret)
1909 pnfs_put_lseg(desc->pg_lseg);
1910 desc->pg_lseg = NULL;
1911 } else
1912 pnfs_do_read(desc, hdr); 1908 pnfs_do_read(desc, hdr);
1913 return ret; 1909 return ret;
1914} 1910}