[pnfs] [PATCH 07/10] pnfs: Add function to set up O_DIRECT I/O

Dean Hildebrand seattleplus at gmail.com
Tue Jul 8 17:54:03 EDT 2008


Determines the rsize/wsize for use with the
data servers, the stripe boundary, and the
amount of data remaining in the current
stripe unit.

Signed-off-by: Dean Hildebrand <dhildeb at us.ibm.com>
---
 fs/nfs/pnfs.c |   32 ++++++++++++++++++++++++++++++++
 fs/nfs/pnfs.h |   25 +++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 88a6fa7..8d2ed6f 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1244,6 +1244,38 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)
 	pnfs_set_pg_test(inode, pgio);
 }
 
+/* Retrieve I/O parameters for O_DIRECT.
+ * Out Args:
+ * iosize    - min of boundary and (rsize or wsize)
+ * remaining - # bytes remaining in the current stripe unit
+ */
+void
+_pnfs_direct_init_io(struct inode *inode, struct nfs_open_context *ctx,
+		     size_t count, loff_t loff, int iswrite, size_t *iosize,
+		     size_t *remaining)
+{
+	struct nfs_server *nfss = NFS_SERVER(inode);
+	u32 boundary;
+	unsigned int rwsize;
+
+	if (count <= 0 ||
+	    below_threshold(inode, count, iswrite) ||
+	    pnfs_update_layout(inode, ctx, count, loff, IOMODE_READ, NULL))
+		return;
+
+	if (iswrite)
+		rwsize = nfss->ds_wsize;
+	else
+		rwsize = nfss->ds_rsize;
+
+	boundary = pnfs_getboundary(inode);
+
+	*iosize = min(rwsize, boundary);
+	*remaining = boundary - (do_div(loff, boundary));
+
+	dprintk("%s Rem %Zu iosize %Zu\n", __func__, *remaining, *iosize);
+}
+
 /*
  * Get a layoutout for COMMIT
  */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index e2e32d9..ffd7153 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -74,6 +74,9 @@ 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);
 
 #define PNFS_EXISTS_LDIO_OP(srv, opname) ((srv)->pnfs_curr_ld &&	\
 				     (srv)->pnfs_curr_ld->ld_io_ops &&	\
@@ -208,6 +211,20 @@ static inline int pnfs_return_layout(struct inode *ino,
 	return 0;
 }
 
+static inline void pnfs_direct_init_io(struct inode *inode,
+				       struct nfs_open_context *ctx,
+				       size_t count, loff_t loff, int iswrite,
+				       size_t *iosize, size_t *remaining)
+{
+	struct nfs_server *nfss = NFS_SERVER(inode);
+
+	if (pnfs_enabled_sb(nfss))
+		return _pnfs_direct_init_io(inode, ctx, count, loff, iswrite,
+					    iosize, remaining);
+
+	return;
+}
+
 #else  /* CONFIG_PNFS */
 
 static inline int pnfs_try_to_read_data(struct nfs_read_data *data,
@@ -261,6 +278,14 @@ static inline void pnfs_modify_new_request(struct nfs_page *req,
 {
 }
 
+/* Set num of remaining bytes, which is everything */
+static inline void pnfs_direct_init_io(struct inode *inode,
+				       struct nfs_open_context *ctx,
+				       size_t count, loff_t loff, int iswrite,
+				       size_t *iosize, size_t *remaining)
+{
+}
+
 #endif /* CONFIG_PNFS */
 
 #endif /* FS_NFS_PNFS_H */
-- 
1.5.3.3



More information about the pNFS mailing list