From 43de721a33b214b253c07672c4c6ba7548f2d3e7 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 13 Jul 2022 06:03:21 -0400 Subject: bcachefs: Unlock in bch2_trans_begin() if we've held locks more than 10us We try to ensure we never hold btree locks for too long - bcachefs tries to be soft realtime. This adds a check when restarting a transaction, where a transaction restart is cheap - if we've been holding locks for too long, drop and retake them. Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_types.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/bcachefs/btree_types.h') diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index 2eb8cc11aec4..b184ec512499 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -382,10 +382,13 @@ struct btree_trans_commit_hook { #define BTREE_TRANS_MEM_MAX (1U << 16) +#define BTREE_TRANS_MAX_LOCK_HOLD_TIME_NS 10000 + struct btree_trans { struct bch_fs *c; const char *fn; struct list_head list; + u64 last_begin_time; struct btree *locking; unsigned locking_path_idx; struct bpos locking_pos; -- cgit v1.2.3