NFS: Fallocate should use the nfs4_fattr_bitmap
authorAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 12 Nov 2019 21:37:24 +0000 (16:37 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 18 Nov 2019 09:47:05 +0000 (10:47 +0100)
Changing a sparse file could have an effect not only on the file size,
but also on the number of blocks used by the file in the underlying
filesystem. The server's cache_consistency_bitmap doesn't update the
SPACE_USED attribute, so let's switch to the nfs4_fattr_bitmap to catch
this update whenever we do an ALLOCATE or DEALLOCATE.

This patch fixes xfstests generic/568, which tests that fallocating an
unaligned range allocates all blocks touched by that range. Without this
patch, `stat` reports 0 bytes used immediately after the fallocate.
Adding a `sleep 5` to the test also catches the update, but it's better
to do so when we know something has changed.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs42proc.c

index aab6b7b6a24a4ce1efe073c94f36399519e6c55a..0a9720880e8175bacf3b089bd0363abcb24e1ffb 100644 (file)
@@ -49,7 +49,7 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
                .falloc_fh      = NFS_FH(inode),
                .falloc_offset  = offset,
                .falloc_length  = len,
-               .falloc_bitmask = server->cache_consistency_bitmask,
+               .falloc_bitmask = nfs4_fattr_bitmap,
        };
        struct nfs42_falloc_res res = {
                .falloc_server  = server,