btrfs-progs: device_get_partition_size*() enhancement and cleanup
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest6 patches 13 repliesIn review
- v15 patches 5 repliesSuperseded
Changes in v2 from the cover letter
- Include and update Zoltan's fix to device_get_partition_size_sysfs() The "/dev/block/<device>/size" attribute is always in sector unit (512Bytes), independent from the physical device's block size.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | btrfs-progs: fix the wrong size from device_get_partition_size_sysfs()common/ | +3 | 3 replies | |
| 2/6 | btrfs-progs: remove the unnecessary device_get_partition_size() callcmds/ | +0 | 1 reply | |
| 3/6 | btrfs-progs: remove device_get_partition_size_fd()common/ common/ | +0 | 1 reply | |
| 4/6 | btrfs-progs: remove is_vol_small() helpermkfs/ mkfs/ | +0 | 1 reply | |
| 5/6 | btrfs-progs: add error handling for device_get_partition_size()cmds/ cmds/ common/ +1 more | +40 | 5 replies | |
| 6/6 | btrfs-progs: add error handling for device_get_partition_size_fd_stat()check/ check/ common/ +5 more | +69 | 1 reply |
Reviews trailers per patch
3 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Anand Jain |
|---|---|
| 1/6 | |
| 2/6 | R-b |
| 3/6 | R-b |
| 4/6 | R-b |
| 5/6 | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/6] btrfs-progs: device_get_partition_size*() enhancement and cleanup
[CHANGELOG]
v2:
- Include and update Zoltan's fix to device_get_partition_size_sysfs() The "/dev/block/<device>/size" attribute is always in sector unit (512Bytes), independent from the physical device's block size.
So the fix is pretty straightforward, just do the left shift before returning.
And update the commit message to properly reflect that.
- Use s64 as the return value of device_get_partition_size*() Kernel ensures the max sector number of a device is LLONG_MAX >> 9, so s64 is more than enough to cover the device size, and we are safe to use the minus part to pass errors.
- Extra error handling when device_get_partition_size*() failed Ouput an error message and exit.
Most callers are already doing that correctly but some are not.
- Keep the sysfs method as the fallback way to grab device size Since the device_get_partition_size_sysfs() can be easily fixed, no need to use complex path search for sector size.
- Add a new cleanup to remove is_vol_small()
Zoltan recently sent a fix to solve the bug in device_get_partition_size_sysfs(), which is causing problems for "btrfs dev usage".
It turns out that, the bug is just the attribute "/sys/block/<device>/size" is in sector unit (512B), not in bytes.
So fix the bug first by reporting the correct size in bytes.
Then remove several unused functions exposed during the error handling cleanup.
Finally cleanup device_get_partition_size*() helpers to provide a proper error handling, not just return 0 for errors, but proper minus erro code, and extra overflow check.
Qu Wenruo (5):
btrfs-progs: remove the unnecessary device_get_partition_size() call
btrfs-progs: remove device_get_partition_size_fd()
btrfs-progs: remove is_vol_small() helper
btrfs-progs: add error handling for device_get_partition_size()
btrfs-progs: add error handling for
device_get_partition_size_fd_stat()
Zoltan Racz (1):
btrfs-progs: fix the wrong size from device_get_partition_size_sysfs()
check/main.c | 8 ++++- check/mode-lowmem.c | 9 ++++- cmds/filesystem-usage.c | 15 ++++++--- cmds/replace.c | 14 ++++++-- common/device-utils.c | 74 ++++++++++++++++++----------------------- common/device-utils.h | 5 ++- kernel-shared/volumes.c | 11 ++++-- kernel-shared/zoned.c | 18 +++++++--- mkfs/common.c | 39 ++++------------------ mkfs/common.h | 1 - mkfs/main.c | 14 +++++--- 11 files changed, 110 insertions(+), 98 deletions(-)
--
2.50.1