From: Kent Overstreet Date: Mon, 3 Oct 2022 20:39:49 +0000 (-0400) Subject: bcachefs: bch2_trans_locked() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=13bc41a7151a6af26107240fbdd2562d95adad44;p=linux.git bcachefs: bch2_trans_locked() Useful debugging function. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 1be7c8883101f..2e94cd2657e9c 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -207,6 +207,7 @@ void bch2_path_put(struct btree_trans *, struct btree_path *, bool); int bch2_trans_relock(struct btree_trans *); void bch2_trans_unlock(struct btree_trans *); +bool bch2_trans_locked(struct btree_trans *); static inline bool trans_was_restarted(struct btree_trans *trans, u32 restart_count) { diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index b79543ae5eebc..ad6e364980f36 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -666,6 +666,16 @@ void bch2_trans_unlock(struct btree_trans *trans) __bch2_btree_path_unlock(trans, path); } +bool bch2_trans_locked(struct btree_trans *trans) +{ + struct btree_path *path; + + trans_for_each_path(trans, path) + if (path->nodes_locked) + return true; + return false; +} + /* Debug */ #ifdef CONFIG_BCACHEFS_DEBUG