Skip to content

Commit c0abbb5

Browse files
Marc Dionnedhowells
authored andcommitted
afs: Calculate i_blocks based on file size
While it's not possible to give an accurate number for the blocks used on the server, populate i_blocks based on the file size so that 'du' can give a reasonable estimate. The value is rounded up to 1K granularity, for consistency with what other AFS clients report, and the servers' 1K usage quota unit. Note that the value calculated by 'du' at the root of a volume can still be slightly lower than the quota usage on the server, as 0-length files are charged 1 quota block, but are reported as occupying 0 blocks. Again, this is consistent with other AFS clients. Signed-off-by: Marc Dionne <[email protected]> Signed-off-by: David Howells <[email protected]>
1 parent b134d68 commit c0abbb5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/afs/inode.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
111111
return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type);
112112
}
113113

114-
inode->i_blocks = 0;
114+
/*
115+
* Estimate 512 bytes blocks used, rounded up to nearest 1K
116+
* for consistency with other AFS clients.
117+
*/
118+
inode->i_blocks = ((i_size_read(inode) + 1023) >> 10) << 1;
115119
vnode->invalid_before = vnode->status.data_version;
116120

117121
read_sequnlock_excl(&vnode->cb_lock);

0 commit comments

Comments
 (0)