linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] bcache patches for Linux v5.16 (first wave)
@ 2021-10-20 14:38 Coly Li
  2021-10-20 14:38 ` [PATCH 1/8] md: bcache: Fix spelling of 'acquire' Coly Li
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Coly Li

Hi Jens,

This is the first wave bcache series for Linux v5.16. In this merge
window, there is no large change set submitted, most of the patches
are code clean up from Chao, Christoph and me. This time we have a
new contributor Feng who provides a useful bug fix for dirty data size
calculation during cache detaching. 

Please take them and thanks in advance.

Coly Li
---

Chao Yu (1):
  bcache: fix error info in register_bcache()

Christoph Hellwig (4):
  bcache: remove the cache_dev_name field from struct cache
  bcache: remove the backing_dev_name field from struct cached_dev
  bcache: use bvec_kmap_local in bch_data_verify
  bcache: remove bch_crc64_update

Coly Li (1):
  bcache: reserve never used bits from bkey.high

Ding Senjie (1):
  md: bcache: Fix spelling of 'acquire'

Lin Feng (1):
  bcache: move calc_cached_dev_sectors to proper place on backing device
    detach

 drivers/md/bcache/bcache.h  |  4 ---
 drivers/md/bcache/btree.c   |  2 +-
 drivers/md/bcache/debug.c   | 15 ++++----
 drivers/md/bcache/io.c      | 16 ++++-----
 drivers/md/bcache/request.c |  6 ++--
 drivers/md/bcache/super.c   | 72 ++++++++++++++++++-------------------
 drivers/md/bcache/sysfs.c   |  2 +-
 drivers/md/bcache/util.h    |  8 -----
 include/uapi/linux/bcache.h |  4 +--
 9 files changed, 57 insertions(+), 72 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] md: bcache: Fix spelling of 'acquire'
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 2/8] bcache: reserve never used bits from bkey.high Coly Li
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Ding Senjie, Hannes Reinecke, Coly Li

From: Ding Senjie <dingsenjie@yulong.com>

acqurie -> acquire

Signed-off-by: Ding Senjie <dingsenjie@yulong.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 185246a0d855..ab64b7762b6e 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2746,7 +2746,7 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
 		 * The reason bch_register_lock is not held to call
 		 * bch_cache_set_stop() and bcache_device_stop() is to
 		 * avoid potential deadlock during reboot, because cache
-		 * set or bcache device stopping process will acqurie
+		 * set or bcache device stopping process will acquire
 		 * bch_register_lock too.
 		 *
 		 * We are safe here because bcache_is_reboot sets to
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] bcache: reserve never used bits from bkey.high
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
  2021-10-20 14:38 ` [PATCH 1/8] md: bcache: Fix spelling of 'acquire' Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 3/8] bcache: fix error info in register_bcache() Coly Li
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Coly Li

There sre 3 bits in member high of struct bkey are never used, and no
plan to support them in future,
- HEADER_SIZE, start at bit 58, length 2 bits
- KEY_PINNED,  start at bit 55, length 1 bit

No any kernel code, or user space tool references or accesses the three
bits. Therefore it is possible and feasible to reserve the valuable bits
from bkey.high. They can be used in future for other purpose.

Signed-off-by: Coly Li <colyli@suse.de>
---
 include/uapi/linux/bcache.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index cf7399f03b71..97413586195b 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -43,9 +43,9 @@ static inline void SET_##name(struct bkey *k, unsigned int i, __u64 v)	\
 #define KEY_MAX_U64S		8
 
 KEY_FIELD(KEY_PTRS,	high, 60, 3)
-KEY_FIELD(HEADER_SIZE,	high, 58, 2)
+KEY_FIELD(__PAD0,	high, 58, 2)
 KEY_FIELD(KEY_CSUM,	high, 56, 2)
-KEY_FIELD(KEY_PINNED,	high, 55, 1)
+KEY_FIELD(__PAD1,	high, 55, 1)
 KEY_FIELD(KEY_DIRTY,	high, 36, 1)
 
 KEY_FIELD(KEY_SIZE,	high, 20, KEY_SIZE_BITS)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] bcache: fix error info in register_bcache()
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
  2021-10-20 14:38 ` [PATCH 1/8] md: bcache: Fix spelling of 'acquire' Coly Li
  2021-10-20 14:38 ` [PATCH 2/8] bcache: reserve never used bits from bkey.high Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 4/8] bcache: move calc_cached_dev_sectors to proper place on backing device detach Coly Li
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Chao Yu, Hannes Reinecke, Coly Li

From: Chao Yu <yuchao0@huawei.com>

In register_bcache(), there are several cases we didn't set
correct error info (return value and/or error message):
- if kzalloc() fails, it needs to return ENOMEM and print
"cannot allocate memory";
- if register_cache() fails, it's better to propagate its
return value rather than using default EINVAL.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/super.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index ab64b7762b6e..6bc5ee42a059 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2613,8 +2613,11 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
 	if (SB_IS_BDEV(sb)) {
 		struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
 
-		if (!dc)
+		if (!dc) {
+			ret = -ENOMEM;
+			err = "cannot allocate memory";
 			goto out_put_sb_page;
+		}
 
 		mutex_lock(&bch_register_lock);
 		ret = register_bdev(sb, sb_disk, bdev, dc);
@@ -2625,11 +2628,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
 	} else {
 		struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
 
-		if (!ca)
+		if (!ca) {
+			ret = -ENOMEM;
+			err = "cannot allocate memory";
 			goto out_put_sb_page;
+		}
 
 		/* blkdev_put() will be called in bch_cache_release() */
-		if (register_cache(sb, sb_disk, bdev, ca) != 0)
+		ret = register_cache(sb, sb_disk, bdev, ca);
+		if (ret)
 			goto out_free_sb;
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] bcache: move calc_cached_dev_sectors to proper place on backing device detach
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (2 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 3/8] bcache: fix error info in register_bcache() Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 5/8] bcache: remove the cache_dev_name field from struct cache Coly Li
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Lin Feng, Coly Li

From: Lin Feng <linf@wangsu.com>

Calculation of cache_set's cached sectors is done by travelling
cached_devs list as shown below:

static void calc_cached_dev_sectors(struct cache_set *c)
{
...
        list_for_each_entry(dc, &c->cached_devs, list)
                sectors += bdev_sectors(dc->bdev);

        c->cached_dev_sectors = sectors;
}

But cached_dev won't be unlinked from c->cached_devs list until we call
following list_move(&dc->list, &uncached_devices),
so previous fix in 'commit 46010141da6677b81cc77f9b47f8ac62bd1cbfd3
("bcache: recal cached_dev_sectors on detach")' is wrong, now we move
it to its right place.

Signed-off-by: Lin Feng <linf@wangsu.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 6bc5ee42a059..05877177b768 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1153,9 +1153,9 @@ static void cached_dev_detach_finish(struct work_struct *w)
 
 	mutex_lock(&bch_register_lock);
 
-	calc_cached_dev_sectors(dc->disk.c);
 	bcache_device_detach(&dc->disk);
 	list_move(&dc->list, &uncached_devices);
+	calc_cached_dev_sectors(dc->disk.c);
 
 	clear_bit(BCACHE_DEV_DETACHING, &dc->disk.flags);
 	clear_bit(BCACHE_DEV_UNLINK_DONE, &dc->disk.flags);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] bcache: remove the cache_dev_name field from struct cache
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (3 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 4/8] bcache: move calc_cached_dev_sectors to proper place on backing device detach Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 6/8] bcache: remove the backing_dev_name field from struct cached_dev Coly Li
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Christoph Hellwig, Coly Li

From: Christoph Hellwig <hch@lst.de>

Just use the %pg format specifier to print the name directly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/bcache.h | 2 --
 drivers/md/bcache/io.c     | 8 ++++----
 drivers/md/bcache/super.c  | 7 +++----
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 5fc989a6d452..47ff9ecea2e2 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -470,8 +470,6 @@ struct cache {
 	atomic_long_t		meta_sectors_written;
 	atomic_long_t		btree_sectors_written;
 	atomic_long_t		sectors_written;
-
-	char			cache_dev_name[BDEVNAME_SIZE];
 };
 
 struct gc_stat {
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index e4388fe3ab7e..564357de7640 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -123,13 +123,13 @@ void bch_count_io_errors(struct cache *ca,
 		errors >>= IO_ERROR_SHIFT;
 
 		if (errors < ca->set->error_limit)
-			pr_err("%s: IO error on %s%s\n",
-			       ca->cache_dev_name, m,
+			pr_err("%pg: IO error on %s%s\n",
+			       ca->bdev, m,
 			       is_read ? ", recovering." : ".");
 		else
 			bch_cache_set_error(ca->set,
-					    "%s: too many IO errors %s\n",
-					    ca->cache_dev_name, m);
+					    "%pg: too many IO errors %s\n",
+					    ca->bdev, m);
 	}
 }
 
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 05877177b768..01e6b0bce9c0 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2334,7 +2334,7 @@ static int cache_alloc(struct cache *ca)
 err_free:
 	module_put(THIS_MODULE);
 	if (err)
-		pr_notice("error %s: %s\n", ca->cache_dev_name, err);
+		pr_notice("error %pg: %s\n", ca->bdev, err);
 	return ret;
 }
 
@@ -2344,7 +2344,6 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
 	const char *err = NULL; /* must be set for any error case */
 	int ret = 0;
 
-	bdevname(bdev, ca->cache_dev_name);
 	memcpy(&ca->sb, sb, sizeof(struct cache_sb));
 	ca->bdev = bdev;
 	ca->bdev->bd_holder = ca;
@@ -2386,14 +2385,14 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
 		goto out;
 	}
 
-	pr_info("registered cache device %s\n", ca->cache_dev_name);
+	pr_info("registered cache device %pg\n", ca->bdev);
 
 out:
 	kobject_put(&ca->kobj);
 
 err:
 	if (err)
-		pr_notice("error %s: %s\n", ca->cache_dev_name, err);
+		pr_notice("error %pg: %s\n", ca->bdev, err);
 
 	return ret;
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] bcache: remove the backing_dev_name field from struct cached_dev
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (4 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 5/8] bcache: remove the cache_dev_name field from struct cache Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 7/8] bcache: use bvec_kmap_local in bch_data_verify Coly Li
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Christoph Hellwig, Coly Li

From: Christoph Hellwig <hch@lst.de>

Just use the %pg format specifier to print the name directly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/bcache.h  |  2 --
 drivers/md/bcache/debug.c   |  4 ++--
 drivers/md/bcache/io.c      |  8 +++----
 drivers/md/bcache/request.c |  4 ++--
 drivers/md/bcache/super.c   | 48 ++++++++++++++++---------------------
 drivers/md/bcache/sysfs.c   |  2 +-
 6 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 47ff9ecea2e2..941685409c68 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -395,8 +395,6 @@ struct cached_dev {
 	atomic_t		io_errors;
 	unsigned int		error_limit;
 	unsigned int		offline_seconds;
-
-	char			backing_dev_name[BDEVNAME_SIZE];
 };
 
 enum alloc_reserve {
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 116edda845c3..e803cad864be 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -137,8 +137,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
 					p2 + bv.bv_offset,
 					bv.bv_len),
 				 dc->disk.c,
-				 "verify failed at dev %s sector %llu",
-				 dc->backing_dev_name,
+				 "verify failed at dev %pg sector %llu",
+				 dc->bdev,
 				 (uint64_t) bio->bi_iter.bi_sector);
 
 		kunmap_atomic(p1);
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index 564357de7640..9c6f9ec55b72 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -65,15 +65,15 @@ void bch_count_backing_io_errors(struct cached_dev *dc, struct bio *bio)
 	 * we shouldn't count failed REQ_RAHEAD bio to dc->io_errors.
 	 */
 	if (bio->bi_opf & REQ_RAHEAD) {
-		pr_warn_ratelimited("%s: Read-ahead I/O failed on backing device, ignore\n",
-				    dc->backing_dev_name);
+		pr_warn_ratelimited("%pg: Read-ahead I/O failed on backing device, ignore\n",
+				    dc->bdev);
 		return;
 	}
 
 	errors = atomic_add_return(1, &dc->io_errors);
 	if (errors < dc->error_limit)
-		pr_err("%s: IO error on backing device, unrecoverable\n",
-			dc->backing_dev_name);
+		pr_err("%pg: IO error on backing device, unrecoverable\n",
+			dc->bdev);
 	else
 		bch_cached_dev_error(dc);
 }
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 6d1de889baeb..64ce5788f80c 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -651,8 +651,8 @@ static void backing_request_endio(struct bio *bio)
 		 */
 		if (unlikely(s->iop.writeback &&
 			     bio->bi_opf & REQ_PREFLUSH)) {
-			pr_err("Can't flush %s: returned bi_status %i\n",
-				dc->backing_dev_name, bio->bi_status);
+			pr_err("Can't flush %pg: returned bi_status %i\n",
+				dc->bdev, bio->bi_status);
 		} else {
 			/* set to orig_bio->bi_status in bio_complete() */
 			s->iop.status = bio->bi_status;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 01e6b0bce9c0..ca557204b6c6 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1025,8 +1025,8 @@ static int cached_dev_status_update(void *arg)
 			dc->offline_seconds = 0;
 
 		if (dc->offline_seconds >= BACKING_DEV_OFFLINE_TIMEOUT) {
-			pr_err("%s: device offline for %d seconds\n",
-			       dc->backing_dev_name,
+			pr_err("%pg: device offline for %d seconds\n",
+			       dc->bdev,
 			       BACKING_DEV_OFFLINE_TIMEOUT);
 			pr_err("%s: disable I/O request due to backing device offline\n",
 			       dc->disk.name);
@@ -1057,15 +1057,13 @@ int bch_cached_dev_run(struct cached_dev *dc)
 	};
 
 	if (dc->io_disable) {
-		pr_err("I/O disabled on cached dev %s\n",
-		       dc->backing_dev_name);
+		pr_err("I/O disabled on cached dev %pg\n", dc->bdev);
 		ret = -EIO;
 		goto out;
 	}
 
 	if (atomic_xchg(&dc->running, 1)) {
-		pr_info("cached dev %s is running already\n",
-		       dc->backing_dev_name);
+		pr_info("cached dev %pg is running already\n", dc->bdev);
 		ret = -EBUSY;
 		goto out;
 	}
@@ -1162,7 +1160,7 @@ static void cached_dev_detach_finish(struct work_struct *w)
 
 	mutex_unlock(&bch_register_lock);
 
-	pr_info("Caching disabled for %s\n", dc->backing_dev_name);
+	pr_info("Caching disabled for %pg\n", dc->bdev);
 
 	/* Drop ref we took in cached_dev_detach() */
 	closure_put(&dc->disk.cl);
@@ -1202,29 +1200,27 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 		return -ENOENT;
 
 	if (dc->disk.c) {
-		pr_err("Can't attach %s: already attached\n",
-		       dc->backing_dev_name);
+		pr_err("Can't attach %pg: already attached\n", dc->bdev);
 		return -EINVAL;
 	}
 
 	if (test_bit(CACHE_SET_STOPPING, &c->flags)) {
-		pr_err("Can't attach %s: shutting down\n",
-		       dc->backing_dev_name);
+		pr_err("Can't attach %pg: shutting down\n", dc->bdev);
 		return -EINVAL;
 	}
 
 	if (dc->sb.block_size < c->cache->sb.block_size) {
 		/* Will die */
-		pr_err("Couldn't attach %s: block size less than set's block size\n",
-		       dc->backing_dev_name);
+		pr_err("Couldn't attach %pg: block size less than set's block size\n",
+		       dc->bdev);
 		return -EINVAL;
 	}
 
 	/* Check whether already attached */
 	list_for_each_entry_safe(exist_dc, t, &c->cached_devs, list) {
 		if (!memcmp(dc->sb.uuid, exist_dc->sb.uuid, 16)) {
-			pr_err("Tried to attach %s but duplicate UUID already attached\n",
-				dc->backing_dev_name);
+			pr_err("Tried to attach %pg but duplicate UUID already attached\n",
+				dc->bdev);
 
 			return -EINVAL;
 		}
@@ -1242,15 +1238,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 
 	if (!u) {
 		if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
-			pr_err("Couldn't find uuid for %s in set\n",
-			       dc->backing_dev_name);
+			pr_err("Couldn't find uuid for %pg in set\n", dc->bdev);
 			return -ENOENT;
 		}
 
 		u = uuid_find_empty(c);
 		if (!u) {
-			pr_err("Not caching %s, no room for UUID\n",
-			       dc->backing_dev_name);
+			pr_err("Not caching %pg, no room for UUID\n", dc->bdev);
 			return -EINVAL;
 		}
 	}
@@ -1318,8 +1312,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 		 */
 		kthread_stop(dc->writeback_thread);
 		cancel_writeback_rate_update_dwork(dc);
-		pr_err("Couldn't run cached device %s\n",
-		       dc->backing_dev_name);
+		pr_err("Couldn't run cached device %pg\n", dc->bdev);
 		return ret;
 	}
 
@@ -1335,8 +1328,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 	/* Allow the writeback thread to proceed */
 	up_write(&dc->writeback_lock);
 
-	pr_info("Caching %s as %s on set %pU\n",
-		dc->backing_dev_name,
+	pr_info("Caching %pg as %s on set %pU\n",
+		dc->bdev,
 		dc->disk.disk->disk_name,
 		dc->disk.c->set_uuid);
 	return 0;
@@ -1458,7 +1451,6 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
 	struct cache_set *c;
 	int ret = -ENOMEM;
 
-	bdevname(bdev, dc->backing_dev_name);
 	memcpy(&dc->sb, sb, sizeof(struct cache_sb));
 	dc->bdev = bdev;
 	dc->bdev->bd_holder = dc;
@@ -1473,7 +1465,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
 	if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
 		goto err;
 
-	pr_info("registered backing device %s\n", dc->backing_dev_name);
+	pr_info("registered backing device %pg\n", dc->bdev);
 
 	list_add(&dc->list, &uncached_devices);
 	/* attach to a matched cache set if it exists */
@@ -1490,7 +1482,7 @@ static int register_bdev(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
 
 	return 0;
 err:
-	pr_notice("error %s: %s\n", dc->backing_dev_name, err);
+	pr_notice("error %pg: %s\n", dc->bdev, err);
 	bcache_device_stop(&dc->disk);
 	return ret;
 }
@@ -1617,8 +1609,8 @@ bool bch_cached_dev_error(struct cached_dev *dc)
 	/* make others know io_disable is true earlier */
 	smp_mb();
 
-	pr_err("stop %s: too many IO errors on backing device %s\n",
-	       dc->disk.disk->disk_name, dc->backing_dev_name);
+	pr_err("stop %s: too many IO errors on backing device %pg\n",
+	       dc->disk.disk->disk_name, dc->bdev);
 
 	bcache_device_stop(&dc->disk);
 	return true;
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 05ac1d6fbbf3..1f0dce30fa75 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -271,7 +271,7 @@ SHOW(__bch_cached_dev)
 	}
 
 	if (attr == &sysfs_backing_dev_name) {
-		snprintf(buf, BDEVNAME_SIZE + 1, "%s", dc->backing_dev_name);
+		snprintf(buf, BDEVNAME_SIZE + 1, "%pg", dc->bdev);
 		strcat(buf, "\n");
 		return strlen(buf);
 	}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] bcache: use bvec_kmap_local in bch_data_verify
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (5 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 6/8] bcache: remove the backing_dev_name field from struct cached_dev Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:38 ` [PATCH 8/8] bcache: remove bch_crc64_update Coly Li
  2021-10-20 14:41 ` [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Jens Axboe
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Christoph Hellwig, Coly Li

From: Christoph Hellwig <hch@lst.de>

Using local kmaps slightly reduces the chances to stray writes, and
the bvec interface cleans up the code a little bit.

Also switch from page_address to bvec_kmap_local for cbv to be on the
safe side and to avoid pointlessly poking into bvec internals.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/debug.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index e803cad864be..6230dfdd9286 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -127,21 +127,20 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
 
 	citer.bi_size = UINT_MAX;
 	bio_for_each_segment(bv, bio, iter) {
-		void *p1 = kmap_atomic(bv.bv_page);
+		void *p1 = bvec_kmap_local(&bv);
 		void *p2;
 
 		cbv = bio_iter_iovec(check, citer);
-		p2 = page_address(cbv.bv_page);
+		p2 = bvec_kmap_local(&cbv);
 
-		cache_set_err_on(memcmp(p1 + bv.bv_offset,
-					p2 + bv.bv_offset,
-					bv.bv_len),
+		cache_set_err_on(memcmp(p1, p2, bv.bv_len),
 				 dc->disk.c,
 				 "verify failed at dev %pg sector %llu",
 				 dc->bdev,
 				 (uint64_t) bio->bi_iter.bi_sector);
 
-		kunmap_atomic(p1);
+		kunmap_local(p2);
+		kunmap_local(p1);
 		bio_advance_iter(check, &citer, bv.bv_len);
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] bcache: remove bch_crc64_update
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (6 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 7/8] bcache: use bvec_kmap_local in bch_data_verify Coly Li
@ 2021-10-20 14:38 ` Coly Li
  2021-10-20 14:41 ` [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Jens Axboe
  8 siblings, 0 replies; 10+ messages in thread
From: Coly Li @ 2021-10-20 14:38 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Christoph Hellwig, Coly Li

From: Christoph Hellwig <hch@lst.de>

bch_crc64_update is an entirely pointless wrapper around crc64_be.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/btree.c   | 2 +-
 drivers/md/bcache/request.c | 2 +-
 drivers/md/bcache/util.h    | 8 --------
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 183a58c89377..88c573eeb598 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -141,7 +141,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
 	uint64_t crc = b->key.ptr[0];
 	void *data = (void *) i + 8, *end = bset_bkey_last(i);
 
-	crc = bch_crc64_update(crc, data, end - data);
+	crc = crc64_be(crc, data, end - data);
 	return crc ^ 0xffffffffffffffffULL;
 }
 
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 64ce5788f80c..3f10f8248304 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -46,7 +46,7 @@ static void bio_csum(struct bio *bio, struct bkey *k)
 	bio_for_each_segment(bv, bio, iter) {
 		void *d = kmap(bv.bv_page) + bv.bv_offset;
 
-		csum = bch_crc64_update(csum, d, bv.bv_len);
+		csum = crc64_be(csum, d, bv.bv_len);
 		kunmap(bv.bv_page);
 	}
 
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
index bca4a7c97da7..50d1dc69d970 100644
--- a/drivers/md/bcache/util.h
+++ b/drivers/md/bcache/util.h
@@ -550,14 +550,6 @@ static inline uint64_t bch_crc64(const void *p, size_t len)
 	return crc ^ 0xffffffffffffffffULL;
 }
 
-static inline uint64_t bch_crc64_update(uint64_t crc,
-					const void *p,
-					size_t len)
-{
-	crc = crc64_be(crc, p, len);
-	return crc;
-}
-
 /*
  * A stepwise-linear pseudo-exponential.  This returns 1 << (x >>
  * frac_bits), with the less-significant bits filled in by linear
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/8] bcache patches for Linux v5.16 (first wave)
  2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
                   ` (7 preceding siblings ...)
  2021-10-20 14:38 ` [PATCH 8/8] bcache: remove bch_crc64_update Coly Li
@ 2021-10-20 14:41 ` Jens Axboe
  8 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2021-10-20 14:41 UTC (permalink / raw)
  To: Coly Li; +Cc: Jens Axboe, linux-bcache, linux-block

On Wed, 20 Oct 2021 22:38:04 +0800, Coly Li wrote:
> This is the first wave bcache series for Linux v5.16. In this merge
> window, there is no large change set submitted, most of the patches
> are code clean up from Chao, Christoph and me. This time we have a
> new contributor Feng who provides a useful bug fix for dirty data size
> calculation during cache detaching.
> 
> Please take them and thanks in advance.
> 
> [...]

Applied, thanks!

[1/8] md: bcache: Fix spelling of 'acquire'
      commit: a307e2abfc22880a3026bc2f2a997402b7c2d833
[2/8] bcache: reserve never used bits from bkey.high
      commit: 0a2b3e363566c4cc8792d37c5e73b9d9295e075c
[3/8] bcache: fix error info in register_bcache()
      commit: d55f7cb2e5c053010d2b527494da9bbb722a78ba
[4/8] bcache: move calc_cached_dev_sectors to proper place on backing device detach
      commit: 0259d4498ba48454749ecfb9c81e892cdb8d1a32
[5/8] bcache: remove the cache_dev_name field from struct cache
      commit: 7e84c2150731faec088ebfe33459f61d118b2497
[6/8] bcache: remove the backing_dev_name field from struct cached_dev
      commit: 0f5cd7815f7f4bb1dd340a9aeb9b9d6a7c7eec22
[7/8] bcache: use bvec_kmap_local in bch_data_verify
      commit: 00387bd21dac98f9e793294c895768d9e5441f82
[8/8] bcache: remove bch_crc64_update
      commit: 39fa7a95552cc851029267b97c1317f1dea61cad

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-20 14:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 14:38 [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Coly Li
2021-10-20 14:38 ` [PATCH 1/8] md: bcache: Fix spelling of 'acquire' Coly Li
2021-10-20 14:38 ` [PATCH 2/8] bcache: reserve never used bits from bkey.high Coly Li
2021-10-20 14:38 ` [PATCH 3/8] bcache: fix error info in register_bcache() Coly Li
2021-10-20 14:38 ` [PATCH 4/8] bcache: move calc_cached_dev_sectors to proper place on backing device detach Coly Li
2021-10-20 14:38 ` [PATCH 5/8] bcache: remove the cache_dev_name field from struct cache Coly Li
2021-10-20 14:38 ` [PATCH 6/8] bcache: remove the backing_dev_name field from struct cached_dev Coly Li
2021-10-20 14:38 ` [PATCH 7/8] bcache: use bvec_kmap_local in bch_data_verify Coly Li
2021-10-20 14:38 ` [PATCH 8/8] bcache: remove bch_crc64_update Coly Li
2021-10-20 14:41 ` [PATCH 0/8] bcache patches for Linux v5.16 (first wave) Jens Axboe

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).