[pnfs] [PATCH 7/7] nfs4_pnfs_layout_segment: layout driver has_layout method
Benny Halevy
bhalevy at panasas.com
Thu Aug 30 09:16:07 EDT 2007
declare and use a layout-driver has_layout method
that can optionally determine if the layout driver has the
layout for a given layout segment (iomode and byte range).
Layout drivers that maintain only a single layout per file
do not have to implement this method.
Use this method in virtual_update_layout to determine whether
LAYOUTGET is required or not.
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfs/pnfs.c | 5 ++++-
include/linux/nfs4_pnfs.h | 1 +
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index aa7afa3..646db94 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -462,7 +462,10 @@ virtual_update_layout(struct inode* ino,
arg.lseg.offset = pos;
arg.lseg.length = count;
/* Check to see if the layout for the given range already exists */
- if (nfsi->current_layout != NULL) {
+ if (nfsi->current_layout != NULL &&
+ (!nfss->pnfs_curr_ld->ld_io_ops->has_layout ||
+ nfss->pnfs_curr_ld->ld_io_ops->has_layout(
+ nfsi->current_layout, ino, &arg.lseg))) {
/* TODO: To make this generic, I would need to compare the extents
* of the existing layout information.
* For now, assume that whole file layouts are always returned.
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 964065d..493c842 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -62,6 +62,7 @@ struct layoutdriver_io_operations {
* inode specific layout structure. Each subsequent layoutget operation results in
* a set_layout call to set the opaque layout in the layout driver.*/
struct pnfs_layout_type* (*alloc_layout) (struct pnfs_mount_type * mountid, struct inode * inode);
+ int (*has_layout) (struct pnfs_layout_type * layoutid, struct inode * inode, struct nfs4_pnfs_layout_segment *range);
void (*free_layout) (struct pnfs_layout_type * layoutid, struct inode * inode, struct nfs4_pnfs_layout_segment *range);
struct pnfs_layout_type* (*set_layout) (struct pnfs_layout_type * layoutid, struct inode * inode, struct nfs4_pnfs_layoutget_res *lgr);
--
1.5.2.5
More information about the pNFS
mailing list