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>
This commit is contained in:
Trond Myklebust 2017-02-02 12:26:38 -05:00 committed by Trond Myklebust
parent 8dc96566c0
commit 64294b08f9
1 changed files with 5 additions and 0 deletions

View 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;