Message ID | 88f58821cecf10db0fc419319cd26cb5bf56fa71.1678741088.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: fix btrfs filesystem usage on older kernels | expand |
On 3/14/23 04:58, Josef Bacik wrote: > Commit 32c2e57c ("btrfs-progs: read fsid from the sysfs in > device_is_seed") introduced a regression on older kernels where we don't > have the fsid exported for devices in sysfs. Being unable to open this > file means that we don't get the device fsid and then fail to find any > devices to show. Fix this by dealing with an error from opening the > sysfs file, which this patch we can now pass make test-mkfs on older > kernels. > > Fixes: 32c2e57c ("btrfs-progs: read fsid from the sysfs in device_is_seed") > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Thank you for fixing it. My bad. > --- > cmds/filesystem-usage.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c > index 57eec98c..45d4ea39 100644 > --- a/cmds/filesystem-usage.c > +++ b/cmds/filesystem-usage.c > @@ -724,9 +724,7 @@ static int device_is_seed(int fd, const char *dev_path, u64 devid, const u8 *mnt > fsid_str[BTRFS_UUID_UNPARSED_SIZE - 1] = 0; > ret = uuid_parse(fsid_str, fsid); To handle the uuid_parse() failure,... > close(sysfs_fd); > - } > - > - if (ret) { > + } else { > ret = dev_to_fsid(dev_path, fsid); > if (ret) > return ret; we need to move the corresponding code (above) outside of the else block, as shown below. diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index 57eec98c077a..60266ca492a6 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -724,14 +724,13 @@ static int device_is_seed(int fd, const char *dev_path, u64 devid, const u8 *mnt fsid_str[BTRFS_UUID_UNPARSED_SIZE - 1] = 0; ret = uuid_parse(fsid_str, fsid); close(sysfs_fd); - } - - if (ret) { + } else { ret = dev_to_fsid(dev_path, fsid); - if (ret) - return ret; } + if (ret) + return ret; + if (memcmp(mnt_fsid, fsid, BTRFS_FSID_SIZE) != 0) return 0; Thanks, Anand
diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index 57eec98c..45d4ea39 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -724,9 +724,7 @@ static int device_is_seed(int fd, const char *dev_path, u64 devid, const u8 *mnt fsid_str[BTRFS_UUID_UNPARSED_SIZE - 1] = 0; ret = uuid_parse(fsid_str, fsid); close(sysfs_fd); - } - - if (ret) { + } else { ret = dev_to_fsid(dev_path, fsid); if (ret) return ret;
Commit 32c2e57c ("btrfs-progs: read fsid from the sysfs in device_is_seed") introduced a regression on older kernels where we don't have the fsid exported for devices in sysfs. Being unable to open this file means that we don't get the device fsid and then fail to find any devices to show. Fix this by dealing with an error from opening the sysfs file, which this patch we can now pass make test-mkfs on older kernels. Fixes: 32c2e57c ("btrfs-progs: read fsid from the sysfs in device_is_seed") Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- cmds/filesystem-usage.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)