diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-03-31 23:37:30 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:19 +0200 |
commit | 6bd1305735bc4346e0ca6cc0ff27517e8bab8f0d (patch) | |
tree | c4669543a1d97bfef05dd3f6e284d12f2e02986b /fs/bcachefs/dirent.c | |
parent | bcachefs: Caller now responsible for calling mark_key for gc (diff) | |
download | linux-6bd1305735bc4346e0ca6cc0ff27517e8bab8f0d.tar.xz linux-6bd1305735bc4346e0ca6cc0ff27517e8bab8f0d.zip |
bcachefs: Fsck locking improvements
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/dirent.c')
-rw-r--r-- | fs/bcachefs/dirent.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 672a94936179..4479a9f55ddf 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -329,17 +329,18 @@ out: return inum; } -int bch2_empty_dir(struct bch_fs *c, u64 dir_inum) +int bch2_empty_dir_trans(struct btree_trans *trans, u64 dir_inum) { - struct btree_trans trans; struct btree_iter *iter; struct bkey_s_c k; int ret = 0; - bch2_trans_init(&trans, c); + iter = bch2_trans_get_iter(trans, BTREE_ID_DIRENTS, + POS(dir_inum, 0), 0); + if (IS_ERR(iter)) + return PTR_ERR(iter); - for_each_btree_key(&trans, iter, BTREE_ID_DIRENTS, - POS(dir_inum, 0), 0, k) { + for_each_btree_key_continue(iter, 0, k) { if (k.k->p.inode > dir_inum) break; @@ -348,11 +349,17 @@ int bch2_empty_dir(struct bch_fs *c, u64 dir_inum) break; } } - bch2_trans_exit(&trans); + bch2_trans_iter_put(trans, iter); return ret; } +int bch2_empty_dir(struct bch_fs *c, u64 dir_inum) +{ + return bch2_trans_do(c, NULL, 0, + bch2_empty_dir_trans(&trans, dir_inum)); +} + int bch2_readdir(struct bch_fs *c, struct file *file, struct dir_context *ctx) { |