Skip to content

Commit

Permalink
pNFS: Don't send LAYOUTGET on OPEN for read, if we already have cache…
Browse files Browse the repository at this point in the history
…d 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 <[email protected]>
  • Loading branch information
trondmypd authored and Trond Myklebust committed May 31, 2018
1 parent 8dc9656 commit 64294b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64294b0

Please sign in to comment.