pNFS: Don't send LAYOUTGET on OPEN for read, if we already have cached data
authorTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 2 Feb 2017 17:26:38 +0000 (12:26 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 31 May 2018 19:03:12 +0000 (15:03 -0400)
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>
fs/nfs/pnfs.c

index d5dc97f..717cd95 100644 (file)
@@ -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;