mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-26 12:26:11 +00:00
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: 63a4681ff3
("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
This commit is contained in:
parent
d7f74e9a91
commit
45f66fa03b
1 changed files with 8 additions and 1 deletions
|
@ -450,7 +450,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)
|
||||||
0 : FSCACHE_ADV_SINGLE_CHUNK,
|
0 : FSCACHE_ADV_SINGLE_CHUNK,
|
||||||
&key, sizeof(key),
|
&key, sizeof(key),
|
||||||
&aux, sizeof(aux),
|
&aux, sizeof(aux),
|
||||||
vnode->status.size));
|
i_size_read(&vnode->netfs.inode)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,6 +777,13 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
|
||||||
if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) &&
|
if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) &&
|
||||||
stat->nlink > 0)
|
stat->nlink > 0)
|
||||||
stat->nlink -= 1;
|
stat->nlink -= 1;
|
||||||
|
|
||||||
|
/* Lie about the size of directories. We maintain a locally
|
||||||
|
* edited copy and may make different allocation decisions on
|
||||||
|
* it, but we need to give userspace the server's size.
|
||||||
|
*/
|
||||||
|
if (S_ISDIR(inode->i_mode))
|
||||||
|
stat->size = vnode->netfs.remote_i_size;
|
||||||
} while (need_seqretry(&vnode->cb_lock, seq));
|
} while (need_seqretry(&vnode->cb_lock, seq));
|
||||||
|
|
||||||
done_seqretry(&vnode->cb_lock, seq);
|
done_seqretry(&vnode->cb_lock, seq);
|
||||||
|
|
Loading…
Reference in a new issue