bcachefs: fiemap: Fix a lockdep splat

As with the previous patch, we generally can't hold btree locks while
copying to userspace, as that may incur a page fault and require
mmap_lock.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-06-19 21:12:05 -04:00
parent a5b696ee6e
commit a83e108fc1

View File

@ -943,6 +943,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
cur.k->k.p.offset += cur.k->k.size;
if (have_extent) {
bch2_trans_unlock(&trans);
ret = bch2_fill_extent(c, info,
bkey_i_to_s_c(prev.k), 0);
if (ret)
@ -961,9 +962,11 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
goto retry;
if (!ret && have_extent)
if (!ret && have_extent) {
bch2_trans_unlock(&trans);
ret = bch2_fill_extent(c, info, bkey_i_to_s_c(prev.k),
FIEMAP_EXTENT_LAST);
}
bch2_trans_exit(&trans);
bch2_bkey_buf_exit(&cur, c);