scoutfs: track inode 512b block count

We weren't doing anything with the inode blocks field.  We weren't even
initializing it which explains why we'd sometimes see garbage i_blocks
values in scoutfs inodes in segments.

The logical blocks field reflects the contents of the file regardless of
whether its online or not.  It's the sum of our online and offline block
tracking.

So we can initialize it to our persistent online and offline counts and
then keep it in sync as blocks are allocated and freed.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-02-21 09:36:44 -08:00
committed by Zach Brown
parent c1311783d5
commit 302b0f5316
3 changed files with 17 additions and 3 deletions
+7 -1
View File
@@ -234,9 +234,15 @@ static void load_inode(struct inode *inode, struct scoutfs_inode *cinode)
ci->online_blocks = le64_to_cpu(cinode->online_blocks);
ci->offline_blocks = le64_to_cpu(cinode->offline_blocks);
ci->next_readdir_pos = le64_to_cpu(cinode->next_readdir_pos);
ci->flags = le32_to_cpu(cinode->flags);
/*
* i_blocks is initialized from online and offline and is then
* maintained as blocks come and go.
*/
inode->i_blocks = (ci->online_blocks = + ci->offline_blocks)
<< SCOUTFS_BLOCK_SECTOR_SHIFT;
set_item_info(ci, cinode);
}