[pnfs] [PATCH 7/8] pnfs: pnfs_modify_new_request
Fred Isaman
iisaman at citi.umich.edu
Thu May 1 09:02:16 EDT 2008
Add hook into nfs_page initialization to allow for setting of
PG_USE_PNFS.
Signed-off-by: Fred Isaman <iisaman at citi.umich.edu>
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfs/pagelist.c | 1 +
fs/nfs/pnfs.c | 19 +++++++++++++++++++
fs/nfs/pnfs.h | 15 +++++++++++++++
include/linux/nfs4_pnfs.h | 3 +++
4 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 43634d3..04f9fd6 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -87,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 14760c2..c964beb 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1925,6 +1925,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_request_data(struct nfs_page *req)
{
struct layoutdriver_io_operations *lo;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index edbe85f..d6fca00 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -64,6 +64,8 @@ int _pnfs_write_begin(struct inode *inode, struct page *page,
loff_t pos, unsigned len, void **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);
#define PNFS_EXISTS_LDIO_OP(srv, opname) ((srv)->pnfs_curr_ld && \
(srv)->pnfs_curr_ld->ld_io_ops && \
@@ -155,6 +157,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 ? */
+}
+
#else /* CONFIG_PNFS */
static inline int pnfs_try_to_read_data(struct nfs_read_data *data,
@@ -194,6 +204,11 @@ static inline void pnfs_redirty_request(struct nfs_page *req)
{
}
+static inline void pnfs_modify_new_request(struct nfs_page *req,
+ void *fsdata)
+{
+}
+
#endif /* CONFIG_PNFS */
#endif /* FS_NFS_PNFS_H */
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 4233dee..e893ca6 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -141,6 +141,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);
void (*free_request_data) (struct nfs_page *);
--
1.5.3.3
More information about the pNFS
mailing list