Skip to contentSkip to conversation

bcache: check return value of register_shrinker

PATCH Superseded Michael Lyle 2 participants 4 messages Nov 24, 2017 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcache: check return value of register_shrinker

This is now __must_check, so this kills a warning. Caller of bch_btree_cache_alloc in super.c appropriately checks return value so this is fully plumbed through.

---
 drivers/md/bcache/btree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +4 -1
index 11c5503d31dc..0c2b77e0194b 100644
@@ -807,7 +807,10 @@ int bch_btree_cache_alloc(struct cache_set *c)
 	c->shrink.scan_objects = bch_mca_scan;
 	c->shrink.seeks = 4;
 	c->shrink.batch = c->btree_pages * 2;
-	register_shrinker(&c->shrink);
+
+	if (register_shrinker(&c->shrink)) {
+		pr_warn("bcache: bch_btree_cache_alloc: could not register shrinker");
+	}
 
 	return 0;
 }
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 1/1 bcache: check return value of register_shrinker

register_shrinker is now __must_check, so check it to kill a warning. Caller of bch_btree_cache_alloc in super.c appropriately checks return value so this is fully plumbed through.

This V2 fixes checkpatch warnings and improves the commit description, as I was too hasty getting the previous version out.

---
 drivers/md/bcache/btree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +4 -1
index 11c5503d31dc..81e8dc3dbe5e 100644
@@ -807,7 +807,10 @@ int bch_btree_cache_alloc(struct cache_set *c)
 	c->shrink.scan_objects = bch_mca_scan;
 	c->shrink.seeks = 4;
 	c->shrink.batch = c->btree_pages * 2;
-	register_shrinker(&c->shrink);
+
+	if (register_shrinker(&c->shrink))
+		pr_warn("bcache: %s: could not register shrinker",
+				__func__);
 
 	return 0;
 }
Signature · 1 line
2.14.1
#2 lore raw

Just a note to everyone-- a quick Reviewed-by: would be appreciated from someone here on the bcache list because I'm hoping to get this sent off with a couple other things to Jens soon. -mpl

Quoted 29 lines · Michael Lyle

register_shrinker is now __must_check, so check it to kill a warning. Caller of bch_btree_cache_alloc in super.c appropriately checks return value so this is fully plumbed through.

This V2 fixes checkpatch warnings and improves the commit description, as I was too hasty getting the previous version out.

---
 drivers/md/bcache/btree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +4 -1
index 11c5503d31dc..81e8dc3dbe5e 100644
@@ -807,7 +807,10 @@ int bch_btree_cache_alloc(struct cache_set *c)
 	c->shrink.scan_objects = bch_mca_scan;
 	c->shrink.seeks = 4;
 	c->shrink.batch = c->btree_pages * 2;
-	register_shrinker(&c->shrink);
+
+	if (register_shrinker(&c->shrink))
+		pr_warn("bcache: %s: could not register shrinker",
+				__func__);
 
 	return 0;
 }
Reviewed-by
#3 lore raw
Quoted 31 lines · Michael Lyle

Just a note to everyone-- a quick Reviewed-by: would be appreciated from someone here on the bcache list because I'm hoping to get this sent off with a couple other things to Jens soon. -mpl

Quoted 26 lines · Michael Lyle

register_shrinker is now __must_check, so check it to kill a warning. Caller of bch_btree_cache_alloc in super.c appropriately checks return value so this is fully plumbed through.

This V2 fixes checkpatch warnings and improves the commit description, as I was too hasty getting the previous version out.

---
 drivers/md/bcache/btree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +4 -1
index 11c5503d31dc..81e8dc3dbe5e 100644
@@ -807,7 +807,10 @@ int bch_btree_cache_alloc(struct cache_set *c)
 	c->shrink.scan_objects = bch_mca_scan;
 	c->shrink.seeks = 4;
 	c->shrink.batch = c->btree_pages * 2;
-	register_shrinker(&c->shrink);
+
+	if (register_shrinker(&c->shrink))
+		pr_warn("bcache: %s: could not register shrinker",
+				__func__);
 
Quoted 2 lines

drivers/md/bcache/btree.c int bch_btree_cache_alloc(struct cache_set *c) · line 816

Quoted 2 lines
drivers/md/bcache/btree.c +0 -0
 	return 0;
 }
Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs