Skip to content
Commit 22538c1b authored by David Howells's avatar David Howells Committed by Greg Kroah-Hartman
Browse files

afs: Fix updating of i_blocks on file/dir extension



[ Upstream commit 9d37e1ca ]

When an afs file or directory is modified locally such that the total file
size is extended, i_blocks needs to be recalculated too.

Fix this by making afs_write_end() and afs_edit_dir_add() call
afs_set_i_size() rather than setting inode->i_size directly as that also
recalculates inode->i_blocks.

This can be tested by creating and writing into directories and files and
then examining them with du.  Without this change, directories show a 4
blocks (they start out at 2048 bytes) and files show 0 blocks; with this
change, they should show a number of blocks proportional to the file size
rounded up to 1024.

Fixes: 31143d5d ("AFS: implement basic file write support")
Fixes: 63a4681f ("afs: Locally edit directory data for mkdir/create/unlink/...")
Reported-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/163113612442.352844.11162345591911691150.stgit@warthog.procyon.org.uk/


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 55352944
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment