Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfs41: change PNFS_LAYOUTRET_ON_SETATTR to only return on truncation to smaller size

Both blocks layout and objects layout want to use it to avoid CB_LAYOUTRECALL
but that should only happen if client is doing truncation to a smaller size.
For other cases, we let server decide if it wants to recall client's layouts.
Change PNFS_LAYOUTRET_ON_SETATTR to follow the logic and not to send
layoutreturn unnecessarily.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Boaz Harrosh <boaz@plexistor.com>
Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>

authored by

Peng Tao and committed by
Trond Myklebust
88ac815c cb8c20fa

+5 -2
+3 -1
fs/nfs/nfs4proc.c
··· 3211 3211 struct nfs4_label *label = NULL; 3212 3212 int status; 3213 3213 3214 - if (pnfs_ld_layoutret_on_setattr(inode)) 3214 + if (pnfs_ld_layoutret_on_setattr(inode) && 3215 + sattr->ia_valid & ATTR_SIZE && 3216 + sattr->ia_size < i_size_read(inode)) 3215 3217 pnfs_commit_and_return_layout(inode); 3216 3218 3217 3219 nfs_fattr_init(fattr);
+2 -1
fs/nfs/pnfs.h
··· 69 69 }; 70 70 71 71 enum layoutdriver_policy_flags { 72 - /* Should the pNFS client commit and return the layout upon a setattr */ 72 + /* Should the pNFS client commit and return the layout upon truncate to 73 + * a smaller size */ 73 74 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0, 74 75 PNFS_LAYOUTRET_ON_ERROR = 1 << 1, 75 76 PNFS_READ_WHOLE_PAGE = 1 << 2,