cifs: truncate the inode and mapping when we simulate fcollapse
authorRonnie Sahlberg <lsahlber@redhat.com>
Wed, 23 Feb 2022 01:14:16 +0000 (11:14 +1000)
committerSteve French <stfrench@microsoft.com>
Mon, 28 Feb 2022 01:18:37 +0000 (19:18 -0600)
commit3de268c4de06c17a4b6140571e6cd8d80836cc31
tree7b0ea8c0c62fa334c3dab01503341391fdb048a6
parent7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3
cifs: truncate the inode and mapping when we simulate fcollapse

RHBZ:1997367

When we collapse a range in smb3_collapse_range() we must make sure
we update the inode size and pagecache accordingly.

If not, both inode size and pagecahce may be stale until it is refreshed.

This can be demonstrated for the inode size by running :

xfs_io -i -f -c "truncate 320k" -c "fcollapse 64k 128k" -c "fiemap -v"  \
/mnt/testfile

where we can see the result of stale data in the fiemap output.
The third line of the output is wrong, all this data should be truncated.

 EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
   0: [0..127]:        hole               128
   1: [128..383]:      128..383           256   0x1
   2: [384..639]:      hole               256

And the correct output, when the inode size has been updated correctly should
look like this:

 EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
   0: [0..127]:        hole               128
   1: [128..383]:      128..383           256   0x1

Reported-by: Xiaoli Feng <xifeng@redhat.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/smb2ops.c