Skip to contentSkip to conversation

bcache: remove nested function usage

PATCH New [email protected] 2 participants 5 messages Mar 18, 2014 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

This patch fixes up some crashes seen while running bcache with the ftrace function graph tracer.

#1 lore raw

PATCH 1/1 bcache: remove nested function usage

From: John Sheu <[email protected]>

Uninlined nested functions can cause crashes when using ftrace, as they don't follow the normal calling convention and confuse the ftrace function graph tracer as it examines the stack.

Also, nested functions are supported as a gcc extension, but may fail on other compilers (e.g. llvm).

---
 drivers/md/bcache/extents.c |  21 ++++----
 drivers/md/bcache/sysfs.c   | 122 ++++++++++++++++++++++----------------------
 2 files changed, 74 insertions(+), 69 deletions(-)
drivers/md/bcache/extents.c +12 -9
index 1a87d2bd..b2fa52ad 100644
@@ -468,6 +468,15 @@ static struct bkey *bch_extent_sort_fixup(struct btree_iter *iter,
 	return NULL;
 }
 
+void subtract_dirty(struct bkey *k,
+		    struct cache_set *c,
+		    uint64_t offset,
+		    int sectors)
+{
+	if (KEY_CACHED(k) && bch_extent_ptrs(k))
+		bcache_dev_sectors_dirty_add(c, KEY_INODE(k), offset, -sectors);
+}
+
 static bool bch_extent_insert_fixup(struct btree_keys *b,
 				    struct bkey *insert,
 				    struct btree_iter *iter,
@@ -475,13 +484,6 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 {
 	struct cache_set *c = container_of(b, struct btree, keys)->c;
 
-	void subtract_dirty(struct bkey *k, uint64_t offset, int sectors)
-	{
-		if (!KEY_CACHED(k) && bch_extent_ptrs(k))
-			bcache_dev_sectors_dirty_add(c, KEY_INODE(k),
-						     offset, -sectors);
-	}
-
 	uint64_t old_offset;
 	unsigned old_size, sectors_found = 0;
 
@@ -558,7 +560,8 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 
 			struct bkey *top;
 
-			subtract_dirty(k, KEY_START(insert), KEY_SIZE(insert));
+			subtract_dirty(k, c, KEY_START(insert),
+				       KEY_SIZE(insert));
 
 			if (bkey_written(b, k)) {
 				/*
@@ -608,7 +611,7 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 			}
 		}
 
-		subtract_dirty(k, old_offset, old_size - KEY_SIZE(k));
+		subtract_dirty(k, c, old_offset, old_size - KEY_SIZE(k));
 	}
 
 check_failed:
drivers/md/bcache/sysfs.c +62 -60

165 lines not on this page · raw message

Signature · 1 line
1.9.0.279.gdc9e3eb
author
#3 lore raw
Quoted 6 lines · Kent Overstreet
Quoted 2 lines · On Mon, Mar 17, 2014 at 10:50:58PM -0700, [email protected] wrote:

This patch fixes up some crashes seen while running bcache with the ftrace function graph tracer.

They need to be marked static once they're not nested

Whoops, forgot about subtract_dirty(). It is static in all the rest.

-John Sheu

#4 lore raw

PATCH 1/1 bcache: remove nested function usage

In reply to [email protected]

From: John Sheu <[email protected]>

Uninlined nested functions can cause crashes when using ftrace, as they don't follow the normal calling convention and confuse the ftrace function graph tracer as it examines the stack.

Also, nested functions are supported as a gcc extension, but may fail on other compilers (e.g. llvm).

---
 drivers/md/bcache/extents.c |  21 ++++----
 drivers/md/bcache/sysfs.c   | 122 ++++++++++++++++++++++----------------------
 2 files changed, 74 insertions(+), 69 deletions(-)
drivers/md/bcache/extents.c +12 -9
index 1a87d2bd..785345ac 100644
@@ -468,6 +468,15 @@ static struct bkey *bch_extent_sort_fixup(struct btree_iter *iter,
 	return NULL;
 }
 
+static void subtract_dirty(struct bkey *k,
+			   struct cache_set *c,
+			   uint64_t offset,
+			   int sectors)
+{
+	if (KEY_CACHED(k) && bch_extent_ptrs(k))
+		bcache_dev_sectors_dirty_add(c, KEY_INODE(k), offset, -sectors);
+}
+
 static bool bch_extent_insert_fixup(struct btree_keys *b,
 				    struct bkey *insert,
 				    struct btree_iter *iter,
@@ -475,13 +484,6 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 {
 	struct cache_set *c = container_of(b, struct btree, keys)->c;
 
-	void subtract_dirty(struct bkey *k, uint64_t offset, int sectors)
-	{
-		if (!KEY_CACHED(k) && bch_extent_ptrs(k))
-			bcache_dev_sectors_dirty_add(c, KEY_INODE(k),
-						     offset, -sectors);
-	}
-
 	uint64_t old_offset;
 	unsigned old_size, sectors_found = 0;
 
@@ -558,7 +560,8 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 
 			struct bkey *top;
 
-			subtract_dirty(k, KEY_START(insert), KEY_SIZE(insert));
+			subtract_dirty(k, c, KEY_START(insert),
+				       KEY_SIZE(insert));
 
 			if (bkey_written(b, k)) {
 				/*
@@ -608,7 +611,7 @@ static bool bch_extent_insert_fixup(struct btree_keys *b,
 			}
 		}
 
-		subtract_dirty(k, old_offset, old_size - KEY_SIZE(k));
+		subtract_dirty(k, c, old_offset, old_size - KEY_SIZE(k));
 	}
 
 check_failed:
drivers/md/bcache/sysfs.c +62 -60

165 lines not on this page · raw message

Signature · 1 line
1.9.0.279.gdc9e3eb