linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcache: fix UUID room exhausted fake issue.
@ 2020-12-17  8:00 Yi Li
  0 siblings, 0 replies; only message in thread
From: Yi Li @ 2020-12-17  8:00 UTC (permalink / raw)
  To: colyli
  Cc: yilikernel, kent.overstreet, linux-bcache, linux-kernel, Yi Li, Li bing

The UUID room will be exhausted fake when loop attach/dettach backing dev.

Using zero_uuid to the UUID room after dettach normaly.
And attach dev can request UUID room successfully.

Signed-off-by: Yi Li <yili@winhong.com>
Signed-off-by: Li bing <libing@winhong.com>
---
 drivers/md/bcache/super.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0e06d721cd8e..f7ad1e26b013 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -34,10 +34,7 @@ static const char bcache_magic[] = {
 	0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81
 };
 
-static const char invalid_uuid[] = {
-	0xa0, 0x3e, 0xf8, 0xed, 0x3e, 0xe1, 0xb8, 0x78,
-	0xc8, 0x50, 0xfc, 0x5e, 0xcb, 0x16, 0xcd, 0x99
-};
+static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 
 static struct kobject *bcache_kobj;
 struct mutex bch_register_lock;
@@ -515,13 +512,6 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
 	return NULL;
 }
 
-static struct uuid_entry *uuid_find_empty(struct cache_set *c)
-{
-	static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-
-	return uuid_find(c, zero_uuid);
-}
-
 /*
  * Bucket priorities/gens:
  *
@@ -803,7 +793,7 @@ static void bcache_device_detach(struct bcache_device *d)
 		struct uuid_entry *u = d->c->uuids + d->id;
 
 		SET_UUID_FLASH_ONLY(u, 0);
-		memcpy(u->uuid, invalid_uuid, 16);
+		memcpy(u->uuid, zero_uuid, 16);
 		u->invalidated = cpu_to_le32((u32)ktime_get_real_seconds());
 		bch_uuid_write(d->c);
 	}
@@ -1211,7 +1201,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 	if (u &&
 	    (BDEV_STATE(&dc->sb) == BDEV_STATE_STALE ||
 	     BDEV_STATE(&dc->sb) == BDEV_STATE_NONE)) {
-		memcpy(u->uuid, invalid_uuid, 16);
+		memcpy(u->uuid, zero_uuid, 16);
 		u->invalidated = cpu_to_le32((u32)ktime_get_real_seconds());
 		u = NULL;
 	}
@@ -1223,7 +1213,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 			return -ENOENT;
 		}
 
-		u = uuid_find_empty(c);
+		u = uuid_find(c, zero_uuid);
 		if (!u) {
 			pr_err("Not caching %s, no room for UUID\n",
 			       dc->backing_dev_name);
@@ -1554,7 +1544,7 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
 	if (!test_bit(CACHE_SET_RUNNING, &c->flags))
 		return -EPERM;
 
-	u = uuid_find_empty(c);
+	u = uuid_find(c, zero_uuid);
 	if (!u) {
 		pr_err("Can't create volume, no room for UUID\n");
 		return -EINVAL;
-- 
2.25.3




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-17  8:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17  8:00 [PATCH] bcache: fix UUID room exhausted fake issue Yi Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).