[PATCH 7/8] pnfs_post_submit: Restore "pnfs: pnfs_modify_new_request"

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

 



From: Fred Isaman <iisaman@xxxxxxxxxxxxxx>

pnfs: pnfs_modify_new_request

Add hook into nfs_page initialization to allow for setting of
PG_USE_PNFS.

[pnfs: pass lseg from write_begin to write_end]
Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxxxxxx>
Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx>

Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxx>
---
 fs/nfs/pagelist.c         |    2 ++
 fs/nfs/pnfs.c             |   19 +++++++++++++++++++
 fs/nfs/pnfs.h             |   15 +++++++++++++++
 include/linux/nfs4_pnfs.h |    3 +++
 4 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 3584b6a..3a1d673 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -20,6 +20,7 @@
 #include <linux/nfs_mount.h>
 
 #include "internal.h"
+#include "pnfs.h"
 
 static struct kmem_cache *nfs_page_cachep;
 
@@ -86,6 +87,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
 	req->wb_bytes   = count;
 	req->wb_context = get_nfs_open_context(ctx);
 	kref_init(&req->wb_kref);
+	pnfs_modify_new_request(req, fsdata);
 	return req;
 }
 
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index ce6ca4b..46fe088 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2245,6 +2245,25 @@ out_unlock:
 	goto out;
 }
 
+/* Note that fsdata != NULL */
+void _pnfs_modify_new_write_request(struct nfs_page *req,
+				    struct pnfs_fsdata *fsdata)
+{
+	struct inode *inode = req->wb_page->mapping->host;
+	struct pnfs_layout_segment *lseg = NULL;
+	loff_t pos;
+	unsigned count;
+
+	pos = ((loff_t)req->wb_index << PAGE_CACHE_SHIFT) + req->wb_offset;
+	count = req->wb_bytes;
+	lseg = pnfs_find_get_lseg(inode, pos, count, IOMODE_RW);
+	if (lseg) {
+		if (fsdata->ok_to_use_pnfs)
+			set_bit(PG_USE_PNFS, &req->wb_flags);
+		put_lseg(lseg);
+	}
+}
+
 void pnfs_free_fsdata(struct pnfs_fsdata *fsdata)
 {
 	if (fsdata) {
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 8d37dfb..1c94984 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -78,6 +78,8 @@ int _pnfs_write_begin(struct inode *inode, struct page *page,
 		      struct pnfs_fsdata **fsdata);
 int _pnfs_do_flush(struct inode *inode, struct nfs_page *req,
 		   struct pnfs_fsdata *fsdata);
+void _pnfs_modify_new_write_request(struct nfs_page *req,
+				    struct pnfs_fsdata *fsdata);
 void _pnfs_direct_init_io(struct inode *inode, struct nfs_open_context *ctx,
 			  size_t count, loff_t loff, int iswrite,
 			  size_t *rwsize, size_t *remaining);
@@ -205,6 +207,14 @@ static inline void pnfs_redirty_request(struct nfs_page *req)
 	clear_bit(PG_USE_PNFS, &req->wb_flags);
 }
 
+static inline void pnfs_modify_new_request(struct nfs_page *req,
+					   void *fsdata)
+{
+	if (fsdata)
+		_pnfs_modify_new_write_request(req, fsdata);
+	/* Should we do something (like set PG_USE_PNFS) if !fsdata ? */
+}
+
 static inline int pnfs_return_layout(struct inode *ino,
 				     struct nfs4_pnfs_layout_segment *lseg,
 				     const nfs4_stateid *stateid, /* optional */
@@ -294,6 +304,11 @@ static inline void pnfs_redirty_request(struct nfs_page *req)
 {
 }
 
+static inline void pnfs_modify_new_request(struct nfs_page *req,
+					   void *fsdata)
+{
+}
+
 static inline int pnfs_get_write_status(struct nfs_write_data *data)
 {
 	return 0;
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 1ba0590..e01a065 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -142,6 +142,9 @@ struct layoutdriver_io_operations {
 	int (*write_begin) (struct pnfs_layout_segment *lseg, struct page *page,
 			    loff_t pos, unsigned count,
 			    struct pnfs_fsdata *fsdata);
+	void (*new_request)(struct pnfs_layout_segment *lseg,
+			    struct nfs_page *req, loff_t pos, unsigned count,
+			    struct pnfs_fsdata *fsdata);
 
 	/* Consistency ops */
 	/* 2 problems:
-- 
1.6.6.1

--
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