mirror of
https://github.com/versity/scoutfs.git
synced 2025-12-23 13:35:18 +00:00
Fix total_data_blocks calculation in mkfs
mkfs was incorrectly initializing total_data_blocks. The field is meant to record the number of blocks from the start of the device that the filesystem could access. mkfs was subtracting the initial reserved area of the device, meaning the number of blocks that the filesystem might access. This could allow accesses past devices if mount checks the device size against the smaller total_data_blocks. And we're about to use total_data_blocks as the start of a new extent to add when growing the volume. It needs to be fixed so that this new grown free extent doesn't overlap with the end of the existing free extents. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -241,7 +241,7 @@ static int do_mkfs(struct mkfs_args *args)
|
|||||||
super->next_ino = cpu_to_le64(SCOUTFS_ROOT_INO + 1);
|
super->next_ino = cpu_to_le64(SCOUTFS_ROOT_INO + 1);
|
||||||
super->seq = cpu_to_le64(1);
|
super->seq = cpu_to_le64(1);
|
||||||
super->total_meta_blocks = cpu_to_le64(last_meta + 1);
|
super->total_meta_blocks = cpu_to_le64(last_meta + 1);
|
||||||
super->total_data_blocks = cpu_to_le64(last_data - first_data + 1);
|
super->total_data_blocks = cpu_to_le64(last_data + 1);
|
||||||
|
|
||||||
assert(sizeof(args->slots) ==
|
assert(sizeof(args->slots) ==
|
||||||
member_sizeof(struct scoutfs_super_block, qconf.slots));
|
member_sizeof(struct scoutfs_super_block, qconf.slots));
|
||||||
@@ -316,7 +316,7 @@ static int do_mkfs(struct mkfs_args *args)
|
|||||||
blkno = next_meta++;
|
blkno = next_meta++;
|
||||||
ret = write_alloc_root(meta_fd, fsid, &super->data_alloc, bt,
|
ret = write_alloc_root(meta_fd, fsid, &super->data_alloc, bt,
|
||||||
1, blkno, first_data,
|
1, blkno, first_data,
|
||||||
le64_to_cpu(super->total_data_blocks));
|
last_data - first_data + 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user