From fe813a0354f44f54839a9e295bd16305e232a0d01ca2167f684d021b8ebefed4 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 2 Mar 2023 08:56:36 +0000 Subject: [PATCH] Accepting request 1068623 from home:colyli:branches:filesystems - bcache-tools: improve is_zoned_device() (bsc#1208425) 0029-bcache-tools-improve-is_zoned_device.patch OBS-URL: https://build.opensuse.org/request/show/1068623 OBS-URL: https://build.opensuse.org/package/show/filesystems/bcache-tools?expand=0&rev=35 --- ...bcache-tools-improve-is_zoned_device.patch | 56 +++++++++++++++++++ bcache-tools.changes | 6 ++ bcache-tools.spec | 3 +- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0029-bcache-tools-improve-is_zoned_device.patch diff --git a/0029-bcache-tools-improve-is_zoned_device.patch b/0029-bcache-tools-improve-is_zoned_device.patch new file mode 100644 index 0000000..e514d58 --- /dev/null +++ b/0029-bcache-tools-improve-is_zoned_device.patch @@ -0,0 +1,56 @@ +From a5e3753516bd39c431def86c8dfec8a9cea1ddd4 Mon Sep 17 00:00:00 2001 +From: Coly Li +Date: Fri, 17 Feb 2023 21:08:10 +0800 +Subject: [PATCH] bcache-tools: improve is_zoned_device() +Git-commit: a5e3753516bd39c431def86c8dfec8a9cea1ddd4 +References: bsc#1208425 + +To check whether a block device is zoned or not, is_zoned_device() +returns true when /sys/block//queue/chunk_sectors is not zero. + +Now there are devices which are not zoned devices but has non-zero +chunk-sectors values. For such situation, the more accurate method is +to read file /sys/block//queue/zoned. If the content is not +string "none", this device is not a zoned device. Otherwise (e.g. +"host-aware" or "host- managed"), it is a zoned device. + +For elder kernel if the above sysfs file doesn't exist, get_zone_size() +is still called by is_zoned_device() for compatibility. + +Signed-off-by: Coly Li +--- + zoned.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/zoned.c b/zoned.c +index d078286..f214787 100644 +--- a/zoned.c ++++ b/zoned.c +@@ -90,5 +90,24 @@ void check_data_offset_for_zoned_device(char *devname, + + int is_zoned_device(char *devname) + { ++ char str[128]; ++ FILE *file; ++ int res; ++ ++ snprintf(str, sizeof(str), ++ "/sys/block/%s/queue/zoned", ++ basename(devname)); ++ file = fopen(str, "r"); ++ if (file) { ++ memset(str, 0, sizeof(str)); ++ res = fscanf(file, "%s", str); ++ fclose(file); ++ ++ /* "none" indicates non-zoned device */ ++ if (res == 1) ++ return !(strcmp(str, "none") == 0); ++ } ++ ++ /* Only used when "zoned" file doesn't exist */ + return (get_zone_size(devname) != 0); + } +-- +2.39.2 + diff --git a/bcache-tools.changes b/bcache-tools.changes index 6379e2b..b748162 100644 --- a/bcache-tools.changes +++ b/bcache-tools.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Mar 2 07:58:54 UTC 2023 - Coly Li + +- bcache-tools: improve is_zoned_device() (bsc#1208425) + 0029-bcache-tools-improve-is_zoned_device.patch + ------------------------------------------------------------------- Wed Feb 24 14:00:08 UTC 2021 - Coly Li diff --git a/bcache-tools.spec b/bcache-tools.spec index 6029bcd..10024be 100644 --- a/bcache-tools.spec +++ b/bcache-tools.spec @@ -1,7 +1,7 @@ # # spec file for package bcache-tools # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -53,6 +53,7 @@ Patch25: 0025-bcache-tools-recover-the-missing-sb.csum-for-showing.patch Patch26: 0026-bcache-tools-only-call-to_cache_sb-for-bcache-device.patch Patch27: 0027-bcache-tools-improve-column-alignment-for-bcache-sho.patch Patch28: 0028-bcache-tools-Update-super-block-version-in-bch_set_f.patch +Patch29: 0029-bcache-tools-improve-is_zoned_device.patch BuildRequires: pkg-config BuildRequires: xz BuildRequires: pkgconfig(blkid)