Skip to content

Commit 45f66fa

Browse files
committed
afs: Fix getattr to report server i_size on dirs, not local size
Fix afs_getattr() to report the server's idea of the file size of a directory rather than the local size. The local size may differ as we edit the local copy to avoid having to redownload it and we may end up with a differently structured blob of a different size. However, if the directory is discarded from the pagecache we then download it again and the user may see the directory file size apparently change. Fixes: 63a4681 ("afs: Locally edit directory data for mkdir/create/unlink/...") Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org
1 parent d7f74e9 commit 45f66fa

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

fs/afs/inode.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)
450450
0 : FSCACHE_ADV_SINGLE_CHUNK,
451451
&key, sizeof(key),
452452
&aux, sizeof(aux),
453-
vnode->status.size));
453+
i_size_read(&vnode->netfs.inode)));
454454
#endif
455455
}
456456

@@ -777,6 +777,13 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
777777
if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) &&
778778
stat->nlink > 0)
779779
stat->nlink -= 1;
780+
781+
/* Lie about the size of directories. We maintain a locally
782+
* edited copy and may make different allocation decisions on
783+
* it, but we need to give userspace the server's size.
784+
*/
785+
if (S_ISDIR(inode->i_mode))
786+
stat->size = vnode->netfs.remote_i_size;
780787
} while (need_seqretry(&vnode->cb_lock, seq));
781788

782789
done_seqretry(&vnode->cb_lock, seq);

0 commit comments

Comments
 (0)