linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave
@ 2021-04-11 13:43 Coly Li
  2021-04-11 13:43 ` [PATCH 1/7] bcache: reduce redundant code in bch_cached_dev_run() Coly Li
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Coly Li

Hi Jens,

This is the 1st wave of bcache for Linux v5.13.
All the patches in this submission are all about code cleanup or
minor fixes.

The 2nd wave patches are about the NVDIMM support on bcache which were
held in previous merge window. The refined patches work as expected, and
I am waiting Intel developers to post the update version with the fixes
of the integration testing. Then I will post out the 2nd wave bcache
patches for 5.13 merge window.

Thanks in advance for taking the 1st wave patches.

Coly Li

---
Arnd Bergmann (1):
  md: bcache: avoid -Wempty-body warnings

Bhaskar Chowdhury (1):
  md: bcache: Trivial typo fixes in the file journal.c

Christoph Hellwig (1):
  bcache: remove PTR_CACHE

Coly Li (1):
  bcache: fix a regression of code compiling failure in debug.c

Gustavo A. R. Silva (1):
  bcache: Use 64-bit arithmetic instead of 32-bit

Yang Li (1):
  bcache: use NULL instead of using plain integer as pointer

Zhiqiang Liu (1):
  bcache: reduce redundant code in bch_cached_dev_run()

 drivers/md/bcache/alloc.c     |  5 ++---
 drivers/md/bcache/bcache.h    | 11 ++---------
 drivers/md/bcache/btree.c     |  4 ++--
 drivers/md/bcache/debug.c     |  2 +-
 drivers/md/bcache/extents.c   |  4 ++--
 drivers/md/bcache/features.c  |  2 +-
 drivers/md/bcache/io.c        |  4 ++--
 drivers/md/bcache/journal.c   |  6 +++---
 drivers/md/bcache/super.c     | 25 ++++++++++++-------------
 drivers/md/bcache/util.h      |  2 +-
 drivers/md/bcache/writeback.c | 11 +++++------
 11 files changed, 33 insertions(+), 43 deletions(-)

-- 
2.26.2


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

* [PATCH 1/7] bcache: reduce redundant code in bch_cached_dev_run()
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 2/7] bcache: remove PTR_CACHE Coly Li
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Zhiqiang Liu, Coly Li

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>

In bch_cached_dev_run(), free(env[1])|free(env[2])|free(buf)
show up three times. This patch introduce out tag in
which free(env[1])|free(env[2])|free(buf) are only called
one time. If we need to call free() when errors occur,
we can set error code to ret, and then goto out tag directly.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/super.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 03e1fe4de53d..2b6d6e9cd680 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1052,6 +1052,7 @@ static int cached_dev_status_update(void *arg)
 
 int bch_cached_dev_run(struct cached_dev *dc)
 {
+	int ret = 0;
 	struct bcache_device *d = &dc->disk;
 	char *buf = kmemdup_nul(dc->sb.label, SB_LABEL_SIZE, GFP_KERNEL);
 	char *env[] = {
@@ -1064,19 +1065,15 @@ 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);
-		kfree(env[1]);
-		kfree(env[2]);
-		kfree(buf);
-		return -EIO;
+		ret = -EIO;
+		goto out;
 	}
 
 	if (atomic_xchg(&dc->running, 1)) {
-		kfree(env[1]);
-		kfree(env[2]);
-		kfree(buf);
 		pr_info("cached dev %s is running already\n",
 		       dc->backing_dev_name);
-		return -EBUSY;
+		ret = -EBUSY;
+		goto out;
 	}
 
 	if (!d->c &&
@@ -1097,15 +1094,13 @@ int bch_cached_dev_run(struct cached_dev *dc)
 	 * only class / kset properties are persistent
 	 */
 	kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env);
-	kfree(env[1]);
-	kfree(env[2]);
-	kfree(buf);
 
 	if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
 	    sysfs_create_link(&disk_to_dev(d->disk)->kobj,
 			      &d->kobj, "bcache")) {
 		pr_err("Couldn't create bcache dev <-> disk sysfs symlinks\n");
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out;
 	}
 
 	dc->status_update_thread = kthread_run(cached_dev_status_update,
@@ -1114,7 +1109,11 @@ int bch_cached_dev_run(struct cached_dev *dc)
 		pr_warn("failed to create bcache_status_update kthread, continue to run without monitoring backing device status\n");
 	}
 
-	return 0;
+out:
+	kfree(env[1]);
+	kfree(env[2]);
+	kfree(buf);
+	return ret;
 }
 
 /*
-- 
2.26.2


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

* [PATCH 2/7] bcache: remove PTR_CACHE
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
  2021-04-11 13:43 ` [PATCH 1/7] bcache: reduce redundant code in bch_cached_dev_run() Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 3/7] bcache: use NULL instead of using plain integer as pointer Coly Li
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Christoph Hellwig, Coly Li

From: Christoph Hellwig <hch@lst.de>

Remove the PTR_CACHE inline and replace it with a direct dereference
of c->cache.

(Coly Li: fix the typo from PTR_BUCKET to PTR_CACHE in commit log)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/alloc.c     |  5 ++---
 drivers/md/bcache/bcache.h    | 11 ++---------
 drivers/md/bcache/btree.c     |  4 ++--
 drivers/md/bcache/debug.c     |  2 +-
 drivers/md/bcache/extents.c   |  4 ++--
 drivers/md/bcache/io.c        |  4 ++--
 drivers/md/bcache/journal.c   |  2 +-
 drivers/md/bcache/writeback.c |  5 ++---
 8 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index 8c371d5eef8e..097577ae3c47 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -482,8 +482,7 @@ void bch_bucket_free(struct cache_set *c, struct bkey *k)
 	unsigned int i;
 
 	for (i = 0; i < KEY_PTRS(k); i++)
-		__bch_bucket_free(PTR_CACHE(c, k, i),
-				  PTR_BUCKET(c, k, i));
+		__bch_bucket_free(c->cache, PTR_BUCKET(c, k, i));
 }
 
 int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,
@@ -674,7 +673,7 @@ bool bch_alloc_sectors(struct cache_set *c,
 		SET_PTR_OFFSET(&b->key, i, PTR_OFFSET(&b->key, i) + sectors);
 
 		atomic_long_add(sectors,
-				&PTR_CACHE(c, &b->key, i)->sectors_written);
+				&c->cache->sectors_written);
 	}
 
 	if (b->sectors_free < c->cache->sb.block_size)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 848dd4db1659..0a4551e165ab 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -804,13 +804,6 @@ static inline sector_t bucket_remainder(struct cache_set *c, sector_t s)
 	return s & (c->cache->sb.bucket_size - 1);
 }
 
-static inline struct cache *PTR_CACHE(struct cache_set *c,
-				      const struct bkey *k,
-				      unsigned int ptr)
-{
-	return c->cache;
-}
-
 static inline size_t PTR_BUCKET_NR(struct cache_set *c,
 				   const struct bkey *k,
 				   unsigned int ptr)
@@ -822,7 +815,7 @@ static inline struct bucket *PTR_BUCKET(struct cache_set *c,
 					const struct bkey *k,
 					unsigned int ptr)
 {
-	return PTR_CACHE(c, k, ptr)->buckets + PTR_BUCKET_NR(c, k, ptr);
+	return c->cache->buckets + PTR_BUCKET_NR(c, k, ptr);
 }
 
 static inline uint8_t gen_after(uint8_t a, uint8_t b)
@@ -841,7 +834,7 @@ static inline uint8_t ptr_stale(struct cache_set *c, const struct bkey *k,
 static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
 				 unsigned int i)
 {
-	return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && PTR_CACHE(c, k, i);
+	return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && c->cache;
 }
 
 /* Btree key macros */
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index fe6dce125aba..183a58c89377 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -426,7 +426,7 @@ void __bch_btree_node_write(struct btree *b, struct closure *parent)
 	do_btree_node_write(b);
 
 	atomic_long_add(set_blocks(i, block_bytes(b->c->cache)) * b->c->cache->sb.block_size,
-			&PTR_CACHE(b->c, &b->key, 0)->btree_sectors_written);
+			&b->c->cache->btree_sectors_written);
 
 	b->written += set_blocks(i, block_bytes(b->c->cache));
 }
@@ -1161,7 +1161,7 @@ static void make_btree_freeing_key(struct btree *b, struct bkey *k)
 
 	for (i = 0; i < KEY_PTRS(k); i++)
 		SET_PTR_GEN(k, i,
-			    bch_inc_gen(PTR_CACHE(b->c, &b->key, i),
+			    bch_inc_gen(b->c->cache,
 					PTR_BUCKET(b->c, &b->key, i)));
 
 	mutex_unlock(&b->c->bucket_lock);
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 63e809f38e3f..589a052efeb1 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -50,7 +50,7 @@ void bch_btree_verify(struct btree *b)
 	v->keys.ops = b->keys.ops;
 
 	bio = bch_bbio_alloc(b->c);
-	bio_set_dev(bio, PTR_CACHE(b->c, &b->key, 0)->bdev);
+	bio_set_dev(bio, c->cache->bdev);
 	bio->bi_iter.bi_sector	= PTR_OFFSET(&b->key, 0);
 	bio->bi_iter.bi_size	= KEY_SIZE(&v->key) << 9;
 	bio->bi_opf		= REQ_OP_READ | REQ_META;
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index f4658a1f37b8..d626ffcbecb9 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -50,7 +50,7 @@ static bool __ptr_invalid(struct cache_set *c, const struct bkey *k)
 
 	for (i = 0; i < KEY_PTRS(k); i++)
 		if (ptr_available(c, k, i)) {
-			struct cache *ca = PTR_CACHE(c, k, i);
+			struct cache *ca = c->cache;
 			size_t bucket = PTR_BUCKET_NR(c, k, i);
 			size_t r = bucket_remainder(c, PTR_OFFSET(k, i));
 
@@ -71,7 +71,7 @@ static const char *bch_ptr_status(struct cache_set *c, const struct bkey *k)
 
 	for (i = 0; i < KEY_PTRS(k); i++)
 		if (ptr_available(c, k, i)) {
-			struct cache *ca = PTR_CACHE(c, k, i);
+			struct cache *ca = c->cache;
 			size_t bucket = PTR_BUCKET_NR(c, k, i);
 			size_t r = bucket_remainder(c, PTR_OFFSET(k, i));
 
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index dad71a6b7889..e4388fe3ab7e 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -36,7 +36,7 @@ void __bch_submit_bbio(struct bio *bio, struct cache_set *c)
 	struct bbio *b = container_of(bio, struct bbio, bio);
 
 	bio->bi_iter.bi_sector	= PTR_OFFSET(&b->key, 0);
-	bio_set_dev(bio, PTR_CACHE(c, &b->key, 0)->bdev);
+	bio_set_dev(bio, c->cache->bdev);
 
 	b->submit_time_us = local_clock_us();
 	closure_bio_submit(c, bio, bio->bi_private);
@@ -137,7 +137,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
 			      blk_status_t error, const char *m)
 {
 	struct bbio *b = container_of(bio, struct bbio, bio);
-	struct cache *ca = PTR_CACHE(c, &b->key, 0);
+	struct cache *ca = c->cache;
 	int is_read = (bio_data_dir(bio) == READ ? 1 : 0);
 
 	unsigned int threshold = op_is_write(bio_op(bio))
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index c6613e817333..de2c0d7699cf 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -768,7 +768,7 @@ static void journal_write_unlocked(struct closure *cl)
 	w->data->csum		= csum_set(w->data);
 
 	for (i = 0; i < KEY_PTRS(k); i++) {
-		ca = PTR_CACHE(c, k, i);
+		ca = c->cache;
 		bio = &ca->journal.bio;
 
 		atomic_long_add(sectors, &ca->meta_sectors_written);
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 82d4e0880a99..bcd550a2b0da 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -416,7 +416,7 @@ static void read_dirty_endio(struct bio *bio)
 	struct dirty_io *io = w->private;
 
 	/* is_read = 1 */
-	bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0),
+	bch_count_io_errors(io->dc->disk.c->cache,
 			    bio->bi_status, 1,
 			    "reading dirty data from cache");
 
@@ -510,8 +510,7 @@ static void read_dirty(struct cached_dev *dc)
 			dirty_init(w);
 			bio_set_op_attrs(&io->bio, REQ_OP_READ, 0);
 			io->bio.bi_iter.bi_sector = PTR_OFFSET(&w->key, 0);
-			bio_set_dev(&io->bio,
-				    PTR_CACHE(dc->disk.c, &w->key, 0)->bdev);
+			bio_set_dev(&io->bio, dc->disk.c->cache->bdev);
 			io->bio.bi_end_io	= read_dirty_endio;
 
 			if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL))
-- 
2.26.2


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

* [PATCH 3/7] bcache: use NULL instead of using plain integer as pointer
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
  2021-04-11 13:43 ` [PATCH 1/7] bcache: reduce redundant code in bch_cached_dev_run() Coly Li
  2021-04-11 13:43 ` [PATCH 2/7] bcache: remove PTR_CACHE Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 4/7] md: bcache: avoid -Wempty-body warnings Coly Li
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Yang Li, Abaci Robot, Coly Li

From: Yang Li <yang.lee@linux.alibaba.com>

This fixes the following sparse warnings:
drivers/md/bcache/features.c:22:16: warning: Using plain integer as NULL
pointer

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/features.c b/drivers/md/bcache/features.c
index d636b7b2d070..6d2b7b84a7b7 100644
--- a/drivers/md/bcache/features.c
+++ b/drivers/md/bcache/features.c
@@ -19,7 +19,7 @@ struct feature {
 static struct feature feature_list[] = {
 	{BCH_FEATURE_INCOMPAT, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE,
 		"large_bucket"},
-	{0, 0, 0 },
+	{0, 0, NULL },
 };
 
 #define compose_feature_string(type)				\
-- 
2.26.2


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

* [PATCH 4/7] md: bcache: avoid -Wempty-body warnings
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
                   ` (2 preceding siblings ...)
  2021-04-11 13:43 ` [PATCH 3/7] bcache: use NULL instead of using plain integer as pointer Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 5/7] md: bcache: Trivial typo fixes in the file journal.c Coly Li
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Arnd Bergmann, Coly Li

From: Arnd Bergmann <arnd@arndb.de>

building with 'make W=1' shows a harmless warning for each user of the
EBUG_ON() macro:

drivers/md/bcache/bset.c: In function 'bch_btree_sort_partial':
drivers/md/bcache/util.h:30:55: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
   30 | #define EBUG_ON(cond)                   do { if (cond); } while (0)
      |                                                       ^
drivers/md/bcache/bset.c:1312:9: note: in expansion of macro 'EBUG_ON'
 1312 |         EBUG_ON(oldsize >= 0 && bch_count_data(b) != oldsize);
      |         ^~~~~~~

Reword the macro slightly to avoid the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
index c029f7443190..bca4a7c97da7 100644
--- a/drivers/md/bcache/util.h
+++ b/drivers/md/bcache/util.h
@@ -27,7 +27,7 @@ struct closure;
 
 #else /* DEBUG */
 
-#define EBUG_ON(cond)			do { if (cond); } while (0)
+#define EBUG_ON(cond)		do { if (cond) do {} while (0); } while (0)
 #define atomic_dec_bug(v)	atomic_dec(v)
 #define atomic_inc_bug(v, i)	atomic_inc(v)
 
-- 
2.26.2


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

* [PATCH 5/7] md: bcache: Trivial typo fixes in the file journal.c
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
                   ` (3 preceding siblings ...)
  2021-04-11 13:43 ` [PATCH 4/7] md: bcache: avoid -Wempty-body warnings Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 6/7] bcache: Use 64-bit arithmetic instead of 32-bit Coly Li
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Bhaskar Chowdhury, Coly Li

From: Bhaskar Chowdhury <unixbhaskar@gmail.com>

s/condidate/candidate/
s/folowing/following/

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/journal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index de2c0d7699cf..61bd79babf7a 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -111,7 +111,7 @@ reread:		left = ca->sb.bucket_size - offset;
 			 * Check from the oldest jset for last_seq. If
 			 * i->j.seq < j->last_seq, it means the oldest jset
 			 * in list is expired and useless, remove it from
-			 * this list. Otherwise, j is a condidate jset for
+			 * this list. Otherwise, j is a candidate jset for
 			 * further following checks.
 			 */
 			while (!list_empty(list)) {
@@ -498,7 +498,7 @@ static void btree_flush_write(struct cache_set *c)
 		 * - If there are matched nodes recorded in btree_nodes[],
 		 *   they are clean now (this is why and how the oldest
 		 *   journal entry can be reclaimed). These selected nodes
-		 *   will be ignored and skipped in the folowing for-loop.
+		 *   will be ignored and skipped in the following for-loop.
 		 */
 		if (((btree_current_write(b)->journal - fifo_front_p) &
 		     mask) != 0) {
-- 
2.26.2


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

* [PATCH 6/7] bcache: Use 64-bit arithmetic instead of 32-bit
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
                   ` (4 preceding siblings ...)
  2021-04-11 13:43 ` [PATCH 5/7] md: bcache: Trivial typo fixes in the file journal.c Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-11 13:43 ` [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c Coly Li
  2021-04-11 14:40 ` [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Jens Axboe
  7 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Gustavo A. R. Silva, Coly Li

From: "Gustavo A. R. Silva" <gustavoars@kernel.org>

Cast multiple variables to (int64_t) in order to give the compiler
complete information about the proper arithmetic to use. Notice that
these variables are being used in contexts that expect expressions of
type int64_t  (64 bit, signed). And currently, such expressions are
being evaluated using 32-bit arithmetic.

Fixes: d0cf9503e908 ("octeontx2-pf: ethtool fec mode support")
Addresses-Coverity-ID: 1501724 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1501725 ("Unintentional integer overflow")
Addresses-Coverity-ID: 1501726 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/writeback.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index bcd550a2b0da..8120da278161 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -110,13 +110,13 @@ static void __update_writeback_rate(struct cached_dev *dc)
 		int64_t fps;
 
 		if (c->gc_stats.in_use <= BCH_WRITEBACK_FRAGMENT_THRESHOLD_MID) {
-			fp_term = dc->writeback_rate_fp_term_low *
+			fp_term = (int64_t)dc->writeback_rate_fp_term_low *
 			(c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_LOW);
 		} else if (c->gc_stats.in_use <= BCH_WRITEBACK_FRAGMENT_THRESHOLD_HIGH) {
-			fp_term = dc->writeback_rate_fp_term_mid *
+			fp_term = (int64_t)dc->writeback_rate_fp_term_mid *
 			(c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_MID);
 		} else {
-			fp_term = dc->writeback_rate_fp_term_high *
+			fp_term = (int64_t)dc->writeback_rate_fp_term_high *
 			(c->gc_stats.in_use - BCH_WRITEBACK_FRAGMENT_THRESHOLD_HIGH);
 		}
 		fps = div_s64(dirty, dirty_buckets) * fp_term;
-- 
2.26.2


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

* [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
                   ` (5 preceding siblings ...)
  2021-04-11 13:43 ` [PATCH 6/7] bcache: Use 64-bit arithmetic instead of 32-bit Coly Li
@ 2021-04-11 13:43 ` Coly Li
  2021-04-12  9:06   ` Christoph Hellwig
  2021-04-11 14:40 ` [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Jens Axboe
  7 siblings, 1 reply; 13+ messages in thread
From: Coly Li @ 2021-04-11 13:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Coly Li, Christoph Hellwig

The patch "bcache: remove PTR_CACHE" introduces a compiling failure in
debug.c with following error message,
  In file included from drivers/md/bcache/bcache.h:182:0,
                   from drivers/md/bcache/debug.c:9:
  drivers/md/bcache/debug.c: In function 'bch_btree_verify':
  drivers/md/bcache/debug.c:53:19: error: 'c' undeclared (first use in
  this function)
    bio_set_dev(bio, c->cache->bdev);
                     ^
This patch fixes the regression by replacing c->cache->bdev by b->c->
cache->bdev.

Signed-off-by: Coly Li <colyli@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
---
 drivers/md/bcache/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 589a052efeb1..116edda845c3 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -50,7 +50,7 @@ void bch_btree_verify(struct btree *b)
 	v->keys.ops = b->keys.ops;
 
 	bio = bch_bbio_alloc(b->c);
-	bio_set_dev(bio, c->cache->bdev);
+	bio_set_dev(bio, b->c->cache->bdev);
 	bio->bi_iter.bi_sector	= PTR_OFFSET(&b->key, 0);
 	bio->bi_iter.bi_size	= KEY_SIZE(&v->key) << 9;
 	bio->bi_opf		= REQ_OP_READ | REQ_META;
-- 
2.26.2


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

* Re: [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave
  2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
                   ` (6 preceding siblings ...)
  2021-04-11 13:43 ` [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c Coly Li
@ 2021-04-11 14:40 ` Jens Axboe
  7 siblings, 0 replies; 13+ messages in thread
From: Jens Axboe @ 2021-04-11 14:40 UTC (permalink / raw)
  To: Coly Li; +Cc: linux-bcache, linux-block

On 4/11/21 7:43 AM, Coly Li wrote:
> Hi Jens,
> 
> This is the 1st wave of bcache for Linux v5.13.
> All the patches in this submission are all about code cleanup or
> minor fixes.
> 
> The 2nd wave patches are about the NVDIMM support on bcache which were
> held in previous merge window. The refined patches work as expected, and
> I am waiting Intel developers to post the update version with the fixes
> of the integration testing. Then I will post out the 2nd wave bcache
> patches for 5.13 merge window.
> 
> Thanks in advance for taking the 1st wave patches.

Applied, thanks.

-- 
Jens Axboe


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

* Re: [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c
  2021-04-11 13:43 ` [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c Coly Li
@ 2021-04-12  9:06   ` Christoph Hellwig
  2021-04-12  9:53     ` Coly Li
  0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-04-12  9:06 UTC (permalink / raw)
  To: Coly Li; +Cc: axboe, linux-bcache, linux-block, Christoph Hellwig

On Sun, Apr 11, 2021 at 09:43:16PM +0800, Coly Li wrote:
> The patch "bcache: remove PTR_CACHE" introduces a compiling failure in
> debug.c with following error message,
>   In file included from drivers/md/bcache/bcache.h:182:0,
>                    from drivers/md/bcache/debug.c:9:
>   drivers/md/bcache/debug.c: In function 'bch_btree_verify':
>   drivers/md/bcache/debug.c:53:19: error: 'c' undeclared (first use in
>   this function)
>     bio_set_dev(bio, c->cache->bdev);
>                      ^
> This patch fixes the regression by replacing c->cache->bdev by b->c->
> cache->bdev.

Why not fold this into the offending patch?

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

* Re: [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c
  2021-04-12  9:06   ` Christoph Hellwig
@ 2021-04-12  9:53     ` Coly Li
  2021-04-12 12:50       ` Jens Axboe
  0 siblings, 1 reply; 13+ messages in thread
From: Coly Li @ 2021-04-12  9:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, linux-bcache, linux-block

On 4/12/21 5:06 PM, Christoph Hellwig wrote:
> On Sun, Apr 11, 2021 at 09:43:16PM +0800, Coly Li wrote:
>> The patch "bcache: remove PTR_CACHE" introduces a compiling failure in
>> debug.c with following error message,
>>   In file included from drivers/md/bcache/bcache.h:182:0,
>>                    from drivers/md/bcache/debug.c:9:
>>   drivers/md/bcache/debug.c: In function 'bch_btree_verify':
>>   drivers/md/bcache/debug.c:53:19: error: 'c' undeclared (first use in
>>   this function)
>>     bio_set_dev(bio, c->cache->bdev);
>>                      ^
>> This patch fixes the regression by replacing c->cache->bdev by b->c->
>> cache->bdev.
> 
> Why not fold this into the offending patch?
> 

I don't know whether I can do it without authorization or agreement from
original author. And I see other maintainers handling similar situation
by either re-write whole patch or appending an extra fix.

If you have a suggested process, I can try it out next time for similar
situation.

Coly Li

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

* Re: [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c
  2021-04-12  9:53     ` Coly Li
@ 2021-04-12 12:50       ` Jens Axboe
  2021-04-12 13:13         ` Coly Li
  0 siblings, 1 reply; 13+ messages in thread
From: Jens Axboe @ 2021-04-12 12:50 UTC (permalink / raw)
  To: Coly Li, Christoph Hellwig; +Cc: linux-bcache, linux-block

On 4/12/21 3:53 AM, Coly Li wrote:
> On 4/12/21 5:06 PM, Christoph Hellwig wrote:
>> On Sun, Apr 11, 2021 at 09:43:16PM +0800, Coly Li wrote:
>>> The patch "bcache: remove PTR_CACHE" introduces a compiling failure in
>>> debug.c with following error message,
>>>   In file included from drivers/md/bcache/bcache.h:182:0,
>>>                    from drivers/md/bcache/debug.c:9:
>>>   drivers/md/bcache/debug.c: In function 'bch_btree_verify':
>>>   drivers/md/bcache/debug.c:53:19: error: 'c' undeclared (first use in
>>>   this function)
>>>     bio_set_dev(bio, c->cache->bdev);
>>>                      ^
>>> This patch fixes the regression by replacing c->cache->bdev by b->c->
>>> cache->bdev.
>>
>> Why not fold this into the offending patch?
>>
> 
> I don't know whether I can do it without authorization or agreement from
> original author. And I see other maintainers handling similar situation
> by either re-write whole patch or appending an extra fix.
> 
> If you have a suggested process, I can try it out next time for similar
> situation.

What I generally do is just add a line between the SOB's for cases
like this, ala:

commit 70aacfe66136809d7f080f89c492c278298719f4
Author: Pavel Begunkov <asml.silence@gmail.com>
Date:   Mon Mar 1 13:02:15 2021 +0000

    io_uring: kill sqo_dead and sqo submission halting
    
    As SQPOLL task doesn't poke into ->sqo_task anymore, there is no need to
    kill the sqo when the master task exits. Before it was necessary to
    avoid races accessing sqo_task->files with removing them.
    
    Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
    [axboe: don't forget to enable SQPOLL before exit, if started disabled]
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

-- 
Jens Axboe


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

* Re: [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c
  2021-04-12 12:50       ` Jens Axboe
@ 2021-04-12 13:13         ` Coly Li
  0 siblings, 0 replies; 13+ messages in thread
From: Coly Li @ 2021-04-12 13:13 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-bcache, Christoph Hellwig, linux-block

On 4/12/21 8:50 PM, Jens Axboe wrote:
> On 4/12/21 3:53 AM, Coly Li wrote:
>> On 4/12/21 5:06 PM, Christoph Hellwig wrote:
>>> On Sun, Apr 11, 2021 at 09:43:16PM +0800, Coly Li wrote:
>>>> The patch "bcache: remove PTR_CACHE" introduces a compiling failure in
>>>> debug.c with following error message,
>>>>   In file included from drivers/md/bcache/bcache.h:182:0,
>>>>                    from drivers/md/bcache/debug.c:9:
>>>>   drivers/md/bcache/debug.c: In function 'bch_btree_verify':
>>>>   drivers/md/bcache/debug.c:53:19: error: 'c' undeclared (first use in
>>>>   this function)
>>>>     bio_set_dev(bio, c->cache->bdev);
>>>>                      ^
>>>> This patch fixes the regression by replacing c->cache->bdev by b->c->
>>>> cache->bdev.
>>>
>>> Why not fold this into the offending patch?
>>>
>>
>> I don't know whether I can do it without authorization or agreement from
>> original author. And I see other maintainers handling similar situation
>> by either re-write whole patch or appending an extra fix.
>>
>> If you have a suggested process, I can try it out next time for similar
>> situation.
> 
> What I generally do is just add a line between the SOB's for cases
> like this, ala:
> 
> commit 70aacfe66136809d7f080f89c492c278298719f4
> Author: Pavel Begunkov <asml.silence@gmail.com>
> Date:   Mon Mar 1 13:02:15 2021 +0000
> 
>     io_uring: kill sqo_dead and sqo submission halting
>     
>     As SQPOLL task doesn't poke into ->sqo_task anymore, there is no need to
>     kill the sqo when the master task exits. Before it was necessary to
>     avoid races accessing sqo_task->files with removing them.
>     
>     Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>     [axboe: don't forget to enable SQPOLL before exit, if started disabled]
>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 

This is a new skill to me. Thanks for the hint, I will use such method
to handle similar situation next time.

Coly Li

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

end of thread, other threads:[~2021-04-12 13:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11 13:43 [PATCH 0/7] bcache patches for Linux 5.13 -- 1st wave Coly Li
2021-04-11 13:43 ` [PATCH 1/7] bcache: reduce redundant code in bch_cached_dev_run() Coly Li
2021-04-11 13:43 ` [PATCH 2/7] bcache: remove PTR_CACHE Coly Li
2021-04-11 13:43 ` [PATCH 3/7] bcache: use NULL instead of using plain integer as pointer Coly Li
2021-04-11 13:43 ` [PATCH 4/7] md: bcache: avoid -Wempty-body warnings Coly Li
2021-04-11 13:43 ` [PATCH 5/7] md: bcache: Trivial typo fixes in the file journal.c Coly Li
2021-04-11 13:43 ` [PATCH 6/7] bcache: Use 64-bit arithmetic instead of 32-bit Coly Li
2021-04-11 13:43 ` [PATCH 7/7] bcache: fix a regression of code compiling failure in debug.c Coly Li
2021-04-12  9:06   ` Christoph Hellwig
2021-04-12  9:53     ` Coly Li
2021-04-12 12:50       ` Jens Axboe
2021-04-12 13:13         ` Coly Li
2021-04-11 14:40 ` [PATCH 0/7] bcache patches for Linux 5.13 -- 1st 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).