New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
homework: resize to maximum disk space if disk size is not specified #25066
Conversation
04000f0
to
dffe0de
Compare
This comment was marked as resolved.
This comment was marked as resolved.
dffe0de
to
03a3ec1
Compare
03a3ec1
to
7d95458
Compare
Removed the dead code. Round up is not performed. |
int r; | ||
|
||
assert(fd >= 0); | ||
assert(p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is actually not correct to assume. if a naked block device is used (i.e. no partition table) this will be NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added partition != NULL
condition. This will make it the same as before if it's a naked block device.
|
||
last_lba = fdisk_get_last_lba(c); /* One sector before boundary where usable space ends */ | ||
assert(last_lba < UINT64_MAX/512); | ||
end = DISK_SIZE_ROUND_DOWN((last_lba + 1) * 512); /* Round down to multiple of 4K */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, this is problematic if there are partitions behind this one. I guess to to be correct we'd have to iterate through all partitions on the disk, and look for the one whose start offset is smallest of those larger than our partition. And only if no such partition exist use the last LBA value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systemd/src/home/homework-luks.c
Lines 2713 to 2715 in 4856f63
} else if (fdisk_partition_get_end(p) > partition_offset / 512U) | |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Can't extend, not last partition in image."); | |
} |
prepare_resize_partition()
returns error if the partition is not the last. Therefore, this ensures that no more partitions exist.
mm, so how come auto-resize is on on such block-device backed home dirs? |
7d95458
to
1566149
Compare
systemd/src/shared/user-record.c Line 1995 in 4856f63
How about set |
Setting the milestone, since two of the three issues this PR should address are in the milestone as well. |
last_lba = fdisk_get_last_lba(c); /* One sector before boundary where usable space ends */ | ||
assert(last_lba < UINT64_MAX/512); | ||
end = DISK_SIZE_ROUND_DOWN((last_lba + 1) * 512); /* Round down to multiple of 4K */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before we subtract start from end we shuld really check for overflows, and generate some error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e.
if (start > end)
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Last LBA is before partition end.");
or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for dropping the ball on this one, and being so slow with the review.
looks pretty good, some minor comment.s
last_lba = fdisk_get_last_lba(c); /* One sector before boundary where usable space ends */ | ||
assert(last_lba < UINT64_MAX/512); | ||
end = DISK_SIZE_ROUND_DOWN((last_lba + 1) * 512); /* Round down to multiple of 4K */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e.
if (start > end)
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Last LBA is before partition end.");
or so
src/home/homework-luks.c
Outdated
assert(last_lba < UINT64_MAX/512); | ||
end = DISK_SIZE_ROUND_DOWN((last_lba + 1) * 512); /* Round down to multiple of 4K */ | ||
|
||
*ret_maximum_partition_size = end - start; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also apply DISK_SIZE_ROUND_DOWN() just in case
If the backing storage is LUKS2 on a block device, auto resize mode is enabled, and disk size is not specified, resize the partition to the maximum expandable size. Fixes: systemd#22255, systemd#23967
1566149
to
17a8346
Compare
If the backing storage is LUKS2 on a block device, auto resize mode is enabled, and disk size is not specified, resize the partition to the maximum expandable size.
Fixes: #22255, #23967
#23740 may also be related.