[RFC 04/12] nfs: Create a common pnfs_ld_rw_done()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The read and write paths run mostly the same code, so it makes sense to
combine them.

Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>
---
 fs/nfs/pnfs.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 4eaf74a..5976b87 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1457,6 +1457,18 @@ static void pnfs_ld_handle_rw_error(struct nfs_pgio_header *hdr,
 		hdr->task.tk_status = resend_to_mds(hdr);
 }
 
+static void pnfs_ld_rw_done(struct nfs_pgio_header *hdr,
+			    void (*cb)(struct nfs_pgio_header *),
+			    int (*resend_to_mds)(struct nfs_pgio_header *))
+{
+	if (!hdr->pnfs_error) {
+		cb(hdr);
+		hdr->mds_ops->rpc_call_done(&hdr->task, hdr);
+	} else
+		pnfs_ld_handle_rw_error(hdr, resend_to_mds);
+	hdr->mds_ops->rpc_release(hdr);
+}
+
 void
 pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
 			   struct nfs_page *req, u64 wb_size)
@@ -1482,12 +1494,7 @@ EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds);
 void pnfs_ld_write_done(struct nfs_pgio_header *hdr)
 {
 	trace_nfs4_pnfs_write(hdr, hdr->pnfs_error);
-	if (!hdr->pnfs_error) {
-		pnfs_set_layoutcommit(hdr);
-		hdr->mds_ops->rpc_call_done(&hdr->task, hdr);
-	} else
-		pnfs_ld_handle_rw_error(hdr, pnfs_write_done_resend_to_mds);
-	hdr->mds_ops->rpc_release(hdr);
+	pnfs_ld_rw_done(hdr, pnfs_set_layoutcommit, pnfs_write_done_resend_to_mds);
 }
 EXPORT_SYMBOL_GPL(pnfs_ld_write_done);
 
@@ -1601,12 +1608,7 @@ EXPORT_SYMBOL_GPL(pnfs_read_done_resend_to_mds);
 void pnfs_ld_read_done(struct nfs_pgio_header *hdr)
 {
 	trace_nfs4_pnfs_read(hdr, hdr->pnfs_error);
-	if (likely(!hdr->pnfs_error)) {
-		__nfs4_read_done_cb(hdr);
-		hdr->mds_ops->rpc_call_done(&hdr->task, hdr);
-	} else
-		pnfs_ld_handle_rw_error(hdr, pnfs_read_done_resend_to_mds);
-	hdr->mds_ops->rpc_release(hdr);
+	pnfs_ld_rw_done(hdr, __nfs4_read_done_cb, pnfs_read_done_resend_to_mds);
 }
 EXPORT_SYMBOL_GPL(pnfs_ld_read_done);
 
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux