• Dave Wysochanski's avatar
    NFS: Pass i_size to fscache_unuse_cookie() when a file is released · 9c4a5c75
    Dave Wysochanski authored
    Pass updated i_size in fscache_unuse_cookie() when called
    from nfs_fscache_release_file(), which ensures the size of
    an fscache object gets written to the cache storage.  Failing
    to do so results in unnessary reads from the NFS server, even
    when the data is cached, due to a cachefiles object coherency
    check failing with a trace similar to the following:
      cachefiles_coherency: o=0000000e BAD osiz B=afbb3 c=0
    
    This problem can be reproduced as follows:
      #!/bin/bash
      v=4.2; NFS_SERVER=127.0.0.1
      set -e; trap cleanup EXIT; rc=1
      function cleanup {
              umount /mnt/nfs > /dev/null 2>&1
              RC_STR="TEST PASS"
              [ $rc -eq 1 ] && RC_STR="TEST FAIL"
              echo "$RC_STR on $(uname -r) with NFSv$v and server $NFS_SERVER"
      }
      mount -o vers=$v,fsc $NFS_SERVER:/export /mnt/nfs
      rm -f /mnt/nfs/file1.bin > /dev/null 2>&1
      dd if=/dev/zero of=/mnt/nfs/file1.bin bs=4096 count=1 > /dev/null 2>&1
      echo 3 > /proc/sys/vm/drop_caches
      echo Read file 1st time from NFS server into fscache
      dd if=/mnt/nfs/file1.bin of=/dev/null > /dev/null 2>&1
      umount /mnt/nfs && mount -o vers=$v,fsc $NFS_SERVER:/export /mnt/nfs
      echo 3 > /proc/sys/vm/drop_caches
      echo Read file 2nd time from fscache
      dd if=/mnt/nfs/file1.bin of=/dev/null > /dev/null 2>&1
      echo Check mountstats for NFS read
      grep -q "READ: 0" /proc/self/mountstats # (1st number) == 0
      [ $? -eq 0 ] && rc=0
    
    Fixes: a6b5a28e "nfs: Convert to new fscache volume/cookie API"
    Signed-off-by: default avatarDave Wysochanski <dwysocha@redhat.com>
    Tested-by: default avatarDaire Byrne <daire@dneg.com>
    Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
    9c4a5c75
fscache.c 9.38 KB