diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-15 20:37:23 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-21 13:27:10 -0500 |
commit | 46bf2e9cc745996ca56e56ed816e60d07811bd9a (patch) | |
tree | 94858ccb5646f0629924d68761471e24b67433df /fs/bcachefs/fs-io.c | |
parent | 1a5039041b376f545dfc11d89af77cc720217b44 (diff) | |
download | linux-stable-46bf2e9cc745996ca56e56ed816e60d07811bd9a.tar.gz linux-stable-46bf2e9cc745996ca56e56ed816e60d07811bd9a.tar.bz2 linux-stable-46bf2e9cc745996ca56e56ed816e60d07811bd9a.zip |
bcachefs: Fix excess transaction restarts in __bchfs_fallocate()
drop_locks_do() should not be used in a fastpath without first trying
the do in nonblocking mode - the unlock and relock will cause excessive
transaction restarts and potentially livelocking with other threads that
are contending for the same locks.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r-- | fs/bcachefs/fs-io.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 98bd5babab19..dc52918d06ef 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -675,8 +675,11 @@ static int __bchfs_fallocate(struct bch_inode_info *inode, int mode, bch2_i_sectors_acct(c, inode, "a_res, i_sectors_delta); - drop_locks_do(trans, - (bch2_mark_pagecache_reserved(inode, hole_start, iter.pos.offset), 0)); + if (bch2_mark_pagecache_reserved(inode, &hole_start, + iter.pos.offset, true)) + drop_locks_do(trans, + bch2_mark_pagecache_reserved(inode, &hole_start, + iter.pos.offset, false)); bkey_err: bch2_quota_reservation_put(c, inode, "a_res); if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) |