summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/move.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-09 12:21:45 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:50 -0400
commitd94189ad568f6cbd80d372cf7aa6e4898b6c5c17 (patch)
tree4e23dbd00746c19092bcdb8604903cab7049a83b /fs/bcachefs/move.c
parentdd81a060eb0680e09d133b81db54b90442c32b5e (diff)
downloadlinux-stable-d94189ad568f6cbd80d372cf7aa6e4898b6c5c17.tar.gz
linux-stable-d94189ad568f6cbd80d372cf7aa6e4898b6c5c17.tar.bz2
linux-stable-d94189ad568f6cbd80d372cf7aa6e4898b6c5c17.zip
bcachefs: Debug mode for c->writes references
This adds a debug mode where we split up the c->writes refcount into distinct refcounts for every codepath that takes a reference, and adds sysfs code to print the value of each ref. This will make it easier to debug shutdown hangs due to refcount leaks. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/move.c')
-rw-r--r--fs/bcachefs/move.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 65c3af1b2e11..46677ad911cd 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -57,7 +57,7 @@ static void move_free(struct moving_io *io)
bch2_data_update_exit(&io->write);
wake_up(&ctxt->wait);
- percpu_ref_put(&c->writes);
+ bch2_write_ref_put(c, BCH_WRITE_REF_move);
kfree(io);
}
@@ -250,7 +250,7 @@ static int bch2_move_extent(struct btree_trans *trans,
return 0;
}
- if (!percpu_ref_tryget_live(&c->writes))
+ if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_move))
return -BCH_ERR_erofs_no_writes;
/* write path might have to decompress data: */
@@ -319,7 +319,7 @@ err_free_pages:
err_free:
kfree(io);
err:
- percpu_ref_put(&c->writes);
+ bch2_write_ref_put(c, BCH_WRITE_REF_move);
trace_and_count(c, move_extent_alloc_mem_fail, k.k);
return ret;
}