From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/6] btrfs-progs: device_get_partition_size*() enhancement and cleanup
Date: Wed, 6 Aug 2025 14:18:49 +0930 [thread overview]
Message-ID: <cover.1754455239.git.wqu@suse.com> (raw)
[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
next reply other threads:[~2025-08-06 4:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 4:48 Qu Wenruo [this message]
2025-08-06 4:48 ` [PATCH v2 1/6] btrfs-progs: fix the wrong size from device_get_partition_size_sysfs() Qu Wenruo
2025-08-08 5:47 ` Anand Jain
2025-08-08 6:05 ` Qu Wenruo
2025-08-08 15:23 ` David Sterba
2025-08-06 4:48 ` [PATCH v2 2/6] btrfs-progs: remove the unnecessary device_get_partition_size() call Qu Wenruo
2025-08-08 5:53 ` Anand Jain
2025-08-06 4:48 ` [PATCH v2 3/6] btrfs-progs: remove device_get_partition_size_fd() Qu Wenruo
2025-08-08 5:59 ` Anand Jain
2025-08-06 4:48 ` [PATCH v2 4/6] btrfs-progs: remove is_vol_small() helper Qu Wenruo
2025-08-08 6:11 ` Anand Jain
2025-08-06 4:48 ` [PATCH v2 5/6] btrfs-progs: add error handling for device_get_partition_size() Qu Wenruo
2025-08-08 7:23 ` Anand Jain
2025-08-08 9:26 ` Anand Jain
2025-08-08 9:31 ` Qu Wenruo
2025-08-08 15:37 ` David Sterba
2025-08-08 16:28 ` Boris Burkov
2025-08-06 4:48 ` [PATCH v2 6/6] btrfs-progs: add error handling for device_get_partition_size_fd_stat() Qu Wenruo
2025-08-08 7:27 ` Anand Jain
2025-08-08 17:07 ` [PATCH v2 0/6] btrfs-progs: device_get_partition_size*() enhancement and cleanup David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1754455239.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.