summaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorTrond Myklebust2017-02-02 18:26:38 +0100
committerTrond Myklebust2018-05-31 21:03:12 +0200
commit64294b08f9d27f83cbb0975250614864fa733bda (patch)
tree5e342c641fba507f84a486b6ed6e47880bc82065 /fs/nfs/pnfs.c
parentNFSv4/pnfs: Don't switch off layoutget-on-open for transient errors (diff)
downloadkernel-qcow2-linux-64294b08f9d27f83cbb0975250614864fa733bda.tar.gz
kernel-qcow2-linux-64294b08f9d27f83cbb0975250614864fa733bda.tar.xz
kernel-qcow2-linux-64294b08f9d27f83cbb0975250614864fa733bda.zip
pNFS: Don't send LAYOUTGET on OPEN for read, if we already have cached data
If we're only opening the file for reading, and the file is empty and/or we already have cached data, then heuristically optimise away the LAYOUTGET. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index d5dc97f72b30..717cd95a0306 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2046,6 +2046,11 @@ static void _lgopen_prepare_attached(struct nfs4_opendata *data,
struct nfs4_layoutget *lgp;
struct pnfs_layout_hdr *lo;
+ /* Heuristic: don't send layoutget if we have cached data */
+ if (rng.iomode == IOMODE_READ &&
+ (i_size_read(ino) == 0 || ino->i_mapping->nrpages != 0))
+ return;
+
lo = _pnfs_grab_empty_layout(ino, ctx);
if (!lo)
return;