Accepting request 860492 from home:colyli:branches:filesystems
- bcache.h: fix typo from SUUP to SUPP (jsc#SLE-9807) 0019-bcache.h-fix-typo-from-SUUP-to-SUPP.patch - bcache-tools: only call set_bucket_size() for cache device (jsc#SLE-9807) 0020-bcache-tools-only-call-set_bucket_size-for-cache-dev.patch - bcache.h: add BCH_FEATURE_INCOMPAT_LARGE_BUCKET to BCH_FEATURE_INCOMPAT_SUPP (jsc#SLE-9807) 0021-bcache.h-add-BCH_FEATURE_INCOMPAT_LARGE_BUCKET-to-BC.patch - bcache-tools: check incompatible feature set (jsc#SLE-9807) 0022-bcache-tools-check-incompatible-feature-set.patch - bcache-tools: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket (jsc#SLE-9807) 0023-bcache-tools-introduce-BCH_FEATURE_INCOMPAT_LOG_LARG.patch - bcache-tools: display obsoleted bucket size configuration (jsc#SLE-9807) 0024-bcache-tools-display-obsoleted-bucket-size-configura.patch - bcache-tools: recover the missing sb.csum for showing bcache device super block (jsc#SLE-9807) 0025-bcache-tools-recover-the-missing-sb.csum-for-showing.patch - bcache-tools: only call to_cache_sb() for bcache device in may_add_item() (jsc#SLE-9807) 0026-bcache-tools-only-call-to_cache_sb-for-bcache-device.patch - bcache-tools: improve column alignment for "bcache show -m" output (jsc#SLE-9807) 0027-bcache-tools-improve-column-alignment-for-bcache-sho.patch OBS-URL: https://build.opensuse.org/request/show/860492 OBS-URL: https://build.opensuse.org/package/show/filesystems/bcache-tools?expand=0&rev=31
This commit is contained in:
parent
1a7fe730e2
commit
78695432ff
38
0019-bcache.h-fix-typo-from-SUUP-to-SUPP.patch
Normal file
38
0019-bcache.h-fix-typo-from-SUUP-to-SUPP.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From d5503bda96efdca8e2ebaa7b3d43845fda4b404d Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Mon, 28 Dec 2020 16:10:42 +0800
|
||||
Subject: [PATCH 1/9] bcache.h: fix typo from SUUP to SUPP
|
||||
Git-commit: d5503bda96efdca8e2ebaa7b3d43845fda4b404d
|
||||
References: jsc#SLE-9807
|
||||
|
||||
This patch fixes the following typos,
|
||||
from BCH_FEATURE_COMPAT_SUUP to BCH_FEATURE_COMPAT_SUPP
|
||||
from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_INCOMPAT_SUPP
|
||||
from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_RO_COMPAT_SUPP
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
bcache.h | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/bcache.h b/bcache.h
|
||||
index 6aef9c4..50dd2b5 100644
|
||||
--- a/bcache.h
|
||||
+++ b/bcache.h
|
||||
@@ -200,9 +200,9 @@ uint64_t crc64(const void *data, size_t len);
|
||||
#define BCH_FEATURE_INCOMPAT 2
|
||||
#define BCH_FEATURE_TYPE_MASK 0x03
|
||||
|
||||
-#define BCH_FEATURE_COMPAT_SUUP 0
|
||||
-#define BCH_FEATURE_INCOMPAT_SUUP 0
|
||||
-#define BCH_FEATURE_RO_COMPAT_SUUP 0
|
||||
+#define BCH_FEATURE_COMPAT_SUPP 0
|
||||
+#define BCH_FEATURE_INCOMPAT_SUPP 0
|
||||
+#define BCH_FEATURE_RO_COMPAT_SUPP 0
|
||||
|
||||
#define BCH_HAS_COMPAT_FEATURE(sb, mask) \
|
||||
((sb)->feature_compat & (mask))
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,41 @@
|
||||
From 287e2a743ccded3916a97a631855b1368427d6ab Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Tue, 29 Dec 2020 22:29:41 +0800
|
||||
Subject: [PATCH 2/9] bcache-tools: only call set_bucket_size() for cache
|
||||
device
|
||||
Git-commit: 287e2a743ccded3916a97a631855b1368427d6ab
|
||||
References: jsc#SLE-9807
|
||||
|
||||
It doesn't make sense to set bucket size for backing device, this patch
|
||||
moves set_bucket_size() into the code block for cache device only.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
make.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/make.c b/make.c
|
||||
index ad89377..a3f97f6 100644
|
||||
--- a/make.c
|
||||
+++ b/make.c
|
||||
@@ -340,7 +340,6 @@ static void write_sb(char *dev, unsigned int block_size,
|
||||
uuid_generate(sb.uuid);
|
||||
memcpy(sb.set_uuid, set_uuid, sizeof(sb.set_uuid));
|
||||
|
||||
- set_bucket_size(&sb, bucket_size);
|
||||
sb.block_size = block_size;
|
||||
|
||||
uuid_unparse(sb.uuid, uuid_str);
|
||||
@@ -383,6 +382,8 @@ static void write_sb(char *dev, unsigned int block_size,
|
||||
data_offset);
|
||||
putchar('\n');
|
||||
} else {
|
||||
+ set_bucket_size(&sb, bucket_size);
|
||||
+
|
||||
sb.nbuckets = getblocks(fd) / sb.bucket_size;
|
||||
sb.nr_in_set = 1;
|
||||
/* 23 is (SB_SECTOR + SB_SIZE) - 1 sectors */
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,35 @@
|
||||
From 86d708d996935edd2f53ada336c40c38cc7fdfd7 Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Mon, 28 Dec 2020 16:24:31 +0800
|
||||
Subject: [PATCH 3/9] bcache.h: add BCH_FEATURE_INCOMPAT_LARGE_BUCKET to
|
||||
BCH_FEATURE_INCOMPAT_SUPP
|
||||
Git-commit: 86d708d996935edd2f53ada336c40c38cc7fdfd7
|
||||
References: jsc#SLE-9807
|
||||
|
||||
BCH_FEATURE_INCOMPAT_LARGE_BUCKET is a feature to support 32bits bucket
|
||||
size, which is incompatible feature for existing on-disk layout. This
|
||||
patch adds this feature bit to BCH_FEATURE_INCOMPAT_SUPP feature set.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
bcache.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/bcache.h b/bcache.h
|
||||
index 50dd2b5..58e973c 100644
|
||||
--- a/bcache.h
|
||||
+++ b/bcache.h
|
||||
@@ -201,8 +201,8 @@ uint64_t crc64(const void *data, size_t len);
|
||||
#define BCH_FEATURE_TYPE_MASK 0x03
|
||||
|
||||
#define BCH_FEATURE_COMPAT_SUPP 0
|
||||
-#define BCH_FEATURE_INCOMPAT_SUPP 0
|
||||
#define BCH_FEATURE_RO_COMPAT_SUPP 0
|
||||
+#define BCH_FEATURE_INCOMPAT_SUPP BCH_FEATURE_INCOMPAT_LARGE_BUCKET
|
||||
|
||||
#define BCH_HAS_COMPAT_FEATURE(sb, mask) \
|
||||
((sb)->feature_compat & (mask))
|
||||
--
|
||||
2.26.2
|
||||
|
62
0022-bcache-tools-check-incompatible-feature-set.patch
Normal file
62
0022-bcache-tools-check-incompatible-feature-set.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From 93e83d620d21411eb82fd3c4e95d7b73e79ce49d Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Thu, 31 Dec 2020 23:59:16 +0800
|
||||
Subject: [PATCH 4/9] bcache-tools: check incompatible feature set
|
||||
Git-commit: 93e83d620d21411eb82fd3c4e95d7b73e79ce49d
|
||||
References: jsc#SLE-9807
|
||||
|
||||
When bcache-tools is not updated with kernel driver (or on the versus),
|
||||
we need to make sure the feature set conflict can be detected to avoid
|
||||
unexpected data operation.
|
||||
|
||||
This patch checks whether there is unsupported {compatc, ro_compat,
|
||||
incompat} features detected in detail_dev(). If there is, prints out
|
||||
error message and return error to its caller.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
lib.c | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/lib.c b/lib.c
|
||||
index 29172f5..a529ad3 100644
|
||||
--- a/lib.c
|
||||
+++ b/lib.c
|
||||
@@ -442,6 +442,33 @@ int detail_dev(char *devname, struct bdev *bd, struct cdev *cd, int *type)
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
+ /* Check for incompat feature set */
|
||||
+ if (sb.version >= BCACHE_SB_VERSION_BDEV_WITH_FEATURES ||
|
||||
+ sb.version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES) {
|
||||
+ uint64_t features;
|
||||
+
|
||||
+ features = sb.feature_compat & ~BCH_FEATURE_COMPAT_SUPP;
|
||||
+ if (features) {
|
||||
+ fprintf(stderr,
|
||||
+ "Unsupported compatible feature found\n");
|
||||
+ goto Fail;
|
||||
+ }
|
||||
+
|
||||
+ features = sb.feature_ro_compat & ~BCH_FEATURE_RO_COMPAT_SUPP;
|
||||
+ if (features) {
|
||||
+ fprintf(stderr,
|
||||
+ "Unsupported read-only compatible feature found\n");
|
||||
+ goto Fail;
|
||||
+ }
|
||||
+
|
||||
+ features = sb.feature_incompat & ~BCH_FEATURE_INCOMPAT_SUPP;
|
||||
+ if (features) {
|
||||
+ fprintf(stderr,
|
||||
+ "Unsupported incompatible feature found\n");
|
||||
+ goto Fail;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
*type = sb.version;
|
||||
if (sb.version == BCACHE_SB_VERSION_BDEV ||
|
||||
sb.version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET ||
|
||||
--
|
||||
2.26.2
|
||||
|
165
0023-bcache-tools-introduce-BCH_FEATURE_INCOMPAT_LOG_LARG.patch
Normal file
165
0023-bcache-tools-introduce-BCH_FEATURE_INCOMPAT_LOG_LARG.patch
Normal file
@ -0,0 +1,165 @@
|
||||
From c0b421f3b5e4479a6f8f25b7cddf53cd240a0a7e Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Fri, 1 Jan 2021 00:16:34 +0800
|
||||
Subject: [PATCH 5/9] bcache-tools: introduce
|
||||
BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket
|
||||
Git-commit: c0b421f3b5e4479a6f8f25b7cddf53cd240a0a7e
|
||||
References: jsc#SLE-9807
|
||||
|
||||
When large bucket feature was added, BCH_FEATURE_INCOMPAT_LARGE_BUCKET
|
||||
was introduced into incompat feature set. It indicates bucket_size_hi is
|
||||
added at the tail of struct cache_sb_disk, to extend current 16bit
|
||||
bucket size to 32bit with existing bucket_size in struct cache_sb_disk.
|
||||
|
||||
This is not a good idea, there are two obvious problems,
|
||||
- Bucket size is always value power of 2, if store log2(bucket size) in
|
||||
existing bucket_size of struct cache_sb_disk, it is unnecessary to add
|
||||
bucket_size_hi.
|
||||
- Macro csum_set() assumes d[SB_JOURNAL_BUCKETS] is the last member in
|
||||
struct cache_sb_disk, bucket_size_hi was added after d[] which makes
|
||||
csum_set calculate an unexpected super block checksum.
|
||||
|
||||
To fix the above problems, this patch introduces a new incompat feature
|
||||
bit BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE, when this bit is set, it
|
||||
means bucket_size in struct cache_sb_disk stores the order of power of
|
||||
2 bucket size value. When user specifies a bucket size larger than 32768
|
||||
sectors, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE will be set to
|
||||
incompat feature set, and bucket_size stores log2(bucket size) more
|
||||
than store the real bucket size value.
|
||||
|
||||
The obsoleted BCH_FEATURE_INCOMPAT_LARGE_BUCKET won't be used anymore,
|
||||
bcache-tools only display "obso_large_bucket" for cache device created
|
||||
with BCH_FEATURE_INCOMPAT_LARGE_BUCKET, kernel driver will make bcache
|
||||
device as read-only if BCH_FEATURE_INCOMPAT_LARGE_BUCKET is set.
|
||||
|
||||
With this change, the unnecessary extra space extend of bcache on-disk
|
||||
super block can be avoided, and csum_set() may generate expected check
|
||||
sum as well.
|
||||
|
||||
Fixes: 8c063851990a ("bcache-tools: add large_bucket incompat feature")
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
bcache.h | 13 +++++++++----
|
||||
features.c | 4 +++-
|
||||
lib.c | 17 +++++++++++++++--
|
||||
lib.h | 2 +-
|
||||
4 files changed, 28 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/bcache.h b/bcache.h
|
||||
index 58e973c..6dcdbb7 100644
|
||||
--- a/bcache.h
|
||||
+++ b/bcache.h
|
||||
@@ -100,7 +100,7 @@ struct cache_sb_disk {
|
||||
__le16 keys;
|
||||
};
|
||||
__le64 d[SB_JOURNAL_BUCKETS]; /* journal buckets */
|
||||
- __le16 bucket_size_hi;
|
||||
+ __le16 obso_bucket_size_hi; /* obsoleted */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -202,7 +202,8 @@ uint64_t crc64(const void *data, size_t len);
|
||||
|
||||
#define BCH_FEATURE_COMPAT_SUPP 0
|
||||
#define BCH_FEATURE_RO_COMPAT_SUPP 0
|
||||
-#define BCH_FEATURE_INCOMPAT_SUPP BCH_FEATURE_INCOMPAT_LARGE_BUCKET
|
||||
+#define BCH_FEATURE_INCOMPAT_SUPP (BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET| \
|
||||
+ BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE)
|
||||
|
||||
#define BCH_HAS_COMPAT_FEATURE(sb, mask) \
|
||||
((sb)->feature_compat & (mask))
|
||||
@@ -214,7 +215,10 @@ uint64_t crc64(const void *data, size_t len);
|
||||
/* Feature set definition */
|
||||
|
||||
/* Incompat feature set */
|
||||
-#define BCH_FEATURE_INCOMPAT_LARGE_BUCKET 0x0001 /* 32bit bucket size */
|
||||
+/* 32bit bucket size, obsoleted */
|
||||
+#define BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET 0x0001
|
||||
+/* real bucket size is (1 << bucket_size) */
|
||||
+#define BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE 0x0002
|
||||
|
||||
#define BCH_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
static inline int bch_has_feature_##name(struct cache_sb *sb) \
|
||||
@@ -267,6 +271,7 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
|
||||
~BCH##_FEATURE_INCOMPAT_##flagname; \
|
||||
}
|
||||
|
||||
-BCH_FEATURE_INCOMPAT_FUNCS(large_bucket, LARGE_BUCKET);
|
||||
+BCH_FEATURE_INCOMPAT_FUNCS(obso_large_bucket, OBSO_LARGE_BUCKET);
|
||||
+BCH_FEATURE_INCOMPAT_FUNCS(large_bucket, LOG_LARGE_BUCKET_SIZE);
|
||||
|
||||
#endif
|
||||
diff --git a/features.c b/features.c
|
||||
index 181e348..f7f6224 100644
|
||||
--- a/features.c
|
||||
+++ b/features.c
|
||||
@@ -20,7 +20,9 @@ struct feature {
|
||||
};
|
||||
|
||||
static struct feature feature_list[] = {
|
||||
- {BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_LARGE_BUCKET,
|
||||
+ {BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET,
|
||||
+ "obso_large_bucket"},
|
||||
+ {BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE,
|
||||
"large_bucket"},
|
||||
{0, 0, 0 },
|
||||
};
|
||||
diff --git a/lib.c b/lib.c
|
||||
index a529ad3..8e7da8b 100644
|
||||
--- a/lib.c
|
||||
+++ b/lib.c
|
||||
@@ -21,6 +21,19 @@
|
||||
* utils function
|
||||
*/
|
||||
|
||||
+static unsigned int log2_u32(uint32_t n)
|
||||
+{
|
||||
+ int r = 0;
|
||||
+
|
||||
+ n = n >> 1;
|
||||
+ while (n) {
|
||||
+ n = n >> 1;
|
||||
+ r++;
|
||||
+ }
|
||||
+
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
static void trim_prefix(char *dest, char *src, int num)
|
||||
{
|
||||
strcpy(dest, src + num);
|
||||
@@ -772,7 +785,7 @@ struct cache_sb *to_cache_sb(struct cache_sb *sb,
|
||||
|
||||
if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES &&
|
||||
bch_has_feature_large_bucket(sb))
|
||||
- sb->bucket_size += le16_to_cpu(sb_disk->bucket_size_hi) << 16;
|
||||
+ sb->bucket_size = 1 << le16_to_cpu(sb_disk->bucket_size);
|
||||
|
||||
return sb;
|
||||
}
|
||||
@@ -824,7 +837,7 @@ struct cache_sb_disk *to_cache_sb_disk(struct cache_sb_disk *sb_disk,
|
||||
|
||||
if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES &&
|
||||
bch_has_feature_large_bucket(sb))
|
||||
- sb_disk->bucket_size_hi = cpu_to_le16(sb->bucket_size >> 16);
|
||||
+ sb_disk->bucket_size = cpu_to_le16(log2_u32(sb->bucket_size));
|
||||
|
||||
return sb_disk;
|
||||
}
|
||||
diff --git a/lib.h b/lib.h
|
||||
index 9b5ed02..0357a11 100644
|
||||
--- a/lib.h
|
||||
+++ b/lib.h
|
||||
@@ -13,7 +13,7 @@ struct dev {
|
||||
char label[SB_LABEL_SIZE + 1];
|
||||
char uuid[40];
|
||||
uint16_t sectors_per_block;
|
||||
- uint16_t sectors_per_bucket;
|
||||
+ uint32_t sectors_per_bucket;
|
||||
char cset[40];
|
||||
char state[40];
|
||||
char bname[40];
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,47 @@
|
||||
From 40cf747541aea3905c328ff351e88cc6ad9a66bf Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Fri, 1 Jan 2021 14:38:27 +0800
|
||||
Subject: [PATCH 6/9] bcache-tools: display obsoleted bucket size configuration
|
||||
Git-commit: 40cf747541aea3905c328ff351e88cc6ad9a66bf
|
||||
References: jsc#SLE-9807
|
||||
|
||||
Although BCH_FEATURE_INCOMPAT_LARGE_BUCKET is obsoleted and we don't
|
||||
support it anymore, we still need to display the obsoleted bucket
|
||||
size combines by,
|
||||
bucket_size + (obso_bucket_size_hi << 16)
|
||||
for the legancy consistency purpose.
|
||||
|
||||
This patch checks bch_has_feature_obso_large_bucket() in to_cache_sb(),
|
||||
if it is true, still try to combine and display the bucket size from
|
||||
obso_bucket_size_hi.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
lib.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib.c b/lib.c
|
||||
index 8e7da8b..b005eb5 100644
|
||||
--- a/lib.c
|
||||
+++ b/lib.c
|
||||
@@ -783,9 +783,13 @@ struct cache_sb *to_cache_sb(struct cache_sb *sb,
|
||||
sb->feature_ro_compat = le64_to_cpu(sb_disk->feature_ro_compat);
|
||||
}
|
||||
|
||||
- if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES &&
|
||||
- bch_has_feature_large_bucket(sb))
|
||||
- sb->bucket_size = 1 << le16_to_cpu(sb_disk->bucket_size);
|
||||
+ if (sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES) {
|
||||
+ if (bch_has_feature_large_bucket(sb))
|
||||
+ sb->bucket_size = 1 << le16_to_cpu(sb_disk->bucket_size);
|
||||
+ else if (bch_has_feature_obso_large_bucket(sb))
|
||||
+ sb->bucket_size +=
|
||||
+ le16_to_cpu(sb_disk->obso_bucket_size_hi) << 16;
|
||||
+ }
|
||||
|
||||
return sb;
|
||||
}
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,52 @@
|
||||
From 0c6e42ef568cece1c041fea5dcd0178d403b517b Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Sun, 3 Jan 2021 23:35:50 +0800
|
||||
Subject: [PATCH 7/9] bcache-tools: recover the missing sb.csum for showing
|
||||
bcache device super block
|
||||
Git-commit: 0c6e42ef568cece1c041fea5dcd0178d403b517b
|
||||
References: jsc#SLE-9807
|
||||
|
||||
Commit 2891723d7075 ("bcache-tools: define separated super block for
|
||||
in-memory and on-disk format") does following change in detail_base(),
|
||||
strcpy(base->name, devname);
|
||||
base->magic = "ok";
|
||||
base->first_sector = SB_SECTOR;
|
||||
- base->csum = sb.csum;
|
||||
base->version = sb.version;
|
||||
because sb (in type struct cache_sb) doesn't have csum of the on-disk
|
||||
super block anymore. The aftermath is base.csum was missing, and the
|
||||
"show" command always display sb.csum as 0.
|
||||
|
||||
This patch recovers the csum value setting for base.csum, then command
|
||||
"bcache show -d" may display the correct super block check sum.
|
||||
|
||||
Fixes: 2891723d7075 ("bcache-tools: define separated super block for in-memory and on-disk format")
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
lib.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/lib.c b/lib.c
|
||||
index b005eb5..340ddf3 100644
|
||||
--- a/lib.c
|
||||
+++ b/lib.c
|
||||
@@ -487,6 +487,7 @@ int detail_dev(char *devname, struct bdev *bd, struct cdev *cd, int *type)
|
||||
sb.version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET ||
|
||||
sb.version == BCACHE_SB_VERSION_BDEV_WITH_FEATURES) {
|
||||
detail_base(devname, sb, &bd->base);
|
||||
+ bd->base.csum = expected_csum;
|
||||
bd->first_sector = BDEV_DATA_START_DEFAULT;
|
||||
bd->cache_mode = BDEV_CACHE_MODE(&sb);
|
||||
bd->cache_state = BDEV_STATE(&sb);
|
||||
@@ -494,6 +495,7 @@ int detail_dev(char *devname, struct bdev *bd, struct cdev *cd, int *type)
|
||||
sb.version == BCACHE_SB_VERSION_CDEV_WITH_UUID ||
|
||||
sb.version == BCACHE_SB_VERSION_CDEV_WITH_FEATURES) {
|
||||
detail_base(devname, sb, &cd->base);
|
||||
+ cd->base.csum = expected_csum;
|
||||
cd->first_sector = sb.bucket_size * sb.first_bucket;
|
||||
cd->cache_sectors =
|
||||
sb.bucket_size * (sb.nbuckets - sb.first_bucket);
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,69 @@
|
||||
From 11f6bab95e5a8d4ec0089692ec78285a1fc96bab Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Mon, 4 Jan 2021 00:07:46 +0800
|
||||
Subject: [PATCH 8/9] bcache-tools: only call to_cache_sb() for bcache device
|
||||
in may_add_item()
|
||||
Git-commit: 11f6bab95e5a8d4ec0089692ec78285a1fc96bab
|
||||
References: jsc#SLE-9807
|
||||
|
||||
to_cache_sb() will print an error message "Unsupported super block
|
||||
version" if the super block version is invalid. For non-bcache devices,
|
||||
it is unnecessary to check version number and print bogus error messages.
|
||||
|
||||
This patch checks bcache_magic earlier in may_add_item(), and only calls
|
||||
to_cache_sb() if the magic string matched. Then the non-bcache devices
|
||||
can be skipped, and no more bogus error message observed.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
lib.c | 15 +++++++--------
|
||||
1 file changed, 7 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/lib.c b/lib.c
|
||||
index 340ddf3..b8487db 100644
|
||||
--- a/lib.c
|
||||
+++ b/lib.c
|
||||
@@ -343,32 +343,31 @@ int may_add_item(char *devname, struct list_head *head)
|
||||
{
|
||||
struct cache_sb_disk sb_disk;
|
||||
struct cache_sb sb;
|
||||
+ char dev[512];
|
||||
+ struct dev *tmp;
|
||||
+ int ret;
|
||||
|
||||
if (strcmp(devname, ".") == 0 || strcmp(devname, "..") == 0)
|
||||
return 0;
|
||||
- char dev[261];
|
||||
|
||||
sprintf(dev, "/dev/%s", devname);
|
||||
int fd = open(dev, O_RDONLY);
|
||||
-
|
||||
if (fd == -1)
|
||||
return 0;
|
||||
+
|
||||
if (pread(fd, &sb_disk, sizeof(sb_disk), SB_START) != sizeof(sb_disk)) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- to_cache_sb(&sb, &sb_disk);
|
||||
-
|
||||
- if (memcmp(sb.magic, bcache_magic, 16)) {
|
||||
+ if (memcmp(sb_disk.magic, bcache_magic, 16)) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
- struct dev *tmp;
|
||||
- int ret;
|
||||
|
||||
- tmp = (struct dev *) malloc(DEVLEN);
|
||||
+ to_cache_sb(&sb, &sb_disk);
|
||||
|
||||
+ tmp = (struct dev *) malloc(DEVLEN);
|
||||
tmp->csum = le64_to_cpu(sb_disk.csum);
|
||||
ret = detail_base(dev, sb, tmp);
|
||||
if (ret != 0) {
|
||||
--
|
||||
2.26.2
|
||||
|
@ -0,0 +1,43 @@
|
||||
From 59338c230950a9d20ed210b9b169eb91fc8b37d8 Mon Sep 17 00:00:00 2001
|
||||
From: Coly Li <colyli@suse.de>
|
||||
Date: Mon, 4 Jan 2021 00:15:53 +0800
|
||||
Subject: [PATCH 9/9] bcache-tools: improve column alignment for "bcache show
|
||||
-m" output
|
||||
Git-commit: 59338c230950a9d20ed210b9b169eb91fc8b37d8
|
||||
References: jsc#SLE-9807
|
||||
|
||||
This patch improves the output column alignment for command
|
||||
"bcache show -m". The changes are adding missing '\t' in printf
|
||||
format strings.
|
||||
|
||||
Signed-off-by: Coly Li <colyli@suse.de>
|
||||
|
||||
---
|
||||
bcache.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/bcache.c b/bcache.c
|
||||
index a0c5a67..234702b 100644
|
||||
--- a/bcache.c
|
||||
+++ b/bcache.c
|
||||
@@ -195,7 +195,7 @@ int show_bdevs_detail(void)
|
||||
fprintf(stderr, "Failed to list devices\n");
|
||||
return ret;
|
||||
}
|
||||
- printf("Name\t\tUuid\t\t\t\t\tCset_Uuid\t\t\t\tType\t\tState");
|
||||
+ printf("Name\t\tUuid\t\t\t\t\tCset_Uuid\t\t\t\tType\t\t\tState");
|
||||
printf("\t\t\tBname\t\tAttachToDev\tAttachToCset\n");
|
||||
list_for_each_entry_safe(devs, n, &head, dev_list) {
|
||||
printf("%s\t%s\t%s\t%lu", devs->name, devs->uuid,
|
||||
@@ -217,7 +217,7 @@ int show_bdevs_detail(void)
|
||||
printf(" (unknown)");
|
||||
break;
|
||||
}
|
||||
- printf("\t%-16s", devs->state);
|
||||
+ printf("\t\t%-16s", devs->state);
|
||||
printf("\t%-16s", devs->bname);
|
||||
char attachdev[30];
|
||||
|
||||
--
|
||||
2.26.2
|
||||
|
@ -1,3 +1,32 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 5 14:20:48 UTC 2021 - Coly Li <colyli@suse.com>
|
||||
|
||||
- bcache.h: fix typo from SUUP to SUPP (jsc#SLE-9807)
|
||||
0019-bcache.h-fix-typo-from-SUUP-to-SUPP.patch
|
||||
- bcache-tools: only call set_bucket_size() for cache device
|
||||
(jsc#SLE-9807)
|
||||
0020-bcache-tools-only-call-set_bucket_size-for-cache-dev.patch
|
||||
- bcache.h: add BCH_FEATURE_INCOMPAT_LARGE_BUCKET to
|
||||
BCH_FEATURE_INCOMPAT_SUPP (jsc#SLE-9807)
|
||||
0021-bcache.h-add-BCH_FEATURE_INCOMPAT_LARGE_BUCKET-to-BC.patch
|
||||
- bcache-tools: check incompatible feature set (jsc#SLE-9807)
|
||||
0022-bcache-tools-check-incompatible-feature-set.patch
|
||||
- bcache-tools: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE
|
||||
for large bucket (jsc#SLE-9807)
|
||||
0023-bcache-tools-introduce-BCH_FEATURE_INCOMPAT_LOG_LARG.patch
|
||||
- bcache-tools: display obsoleted bucket size configuration
|
||||
(jsc#SLE-9807)
|
||||
0024-bcache-tools-display-obsoleted-bucket-size-configura.patch
|
||||
- bcache-tools: recover the missing sb.csum for showing bcache device
|
||||
super block (jsc#SLE-9807)
|
||||
0025-bcache-tools-recover-the-missing-sb.csum-for-showing.patch
|
||||
- bcache-tools: only call to_cache_sb() for bcache device
|
||||
in may_add_item() (jsc#SLE-9807)
|
||||
0026-bcache-tools-only-call-to_cache_sb-for-bcache-device.patch
|
||||
- bcache-tools: improve column alignment for "bcache show
|
||||
-m" output (jsc#SLE-9807)
|
||||
0027-bcache-tools-improve-column-alignment-for-bcache-sho.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Nov 15 15:58:35 UTC 2020 - Coly Li <colyli@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package bcache-tools
|
||||
#
|
||||
# Copyright (c) 2020 SUSE LLC
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -43,6 +43,15 @@ Patch15: 0015-bcache-tools-make-permit-only-one-cache-device-to-be.patch
|
||||
Patch16: 0016-bcache-tools-add-bcache-status.patch
|
||||
Patch17: 0017-bcache-tools-add-man-page-bcache-status.8.patch
|
||||
Patch18: 0018-Makefile-install-bcache-status.patch
|
||||
Patch19: 0019-bcache.h-fix-typo-from-SUUP-to-SUPP.patch
|
||||
Patch20: 0020-bcache-tools-only-call-set_bucket_size-for-cache-dev.patch
|
||||
Patch21: 0021-bcache.h-add-BCH_FEATURE_INCOMPAT_LARGE_BUCKET-to-BC.patch
|
||||
Patch22: 0022-bcache-tools-check-incompatible-feature-set.patch
|
||||
Patch23: 0023-bcache-tools-introduce-BCH_FEATURE_INCOMPAT_LOG_LARG.patch
|
||||
Patch24: 0024-bcache-tools-display-obsoleted-bucket-size-configura.patch
|
||||
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
|
||||
BuildRequires: pkg-config
|
||||
BuildRequires: xz
|
||||
BuildRequires: pkgconfig(blkid)
|
||||
|
Loading…
Reference in New Issue
Block a user