Skip to content

Commit b897b14

Browse files
author
Kent Overstreet
committed
bcachefs: fix bch2_get_acl() transaction restart handling
bch2_acl_from_disk() uses allocate_dropping_locks, and can thus return a transaction restart - this wasn't handled. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 09e913f commit b897b14

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

fs/bcachefs/acl.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
281281
struct xattr_search_key search = X_SEARCH(acl_to_xattr_type(type), "", 0);
282282
struct btree_trans *trans = bch2_trans_get(c);
283283
struct btree_iter iter = { NULL };
284-
struct bkey_s_c_xattr xattr;
285284
struct posix_acl *acl = NULL;
286285
struct bkey_s_c k;
287286
int ret;
@@ -290,28 +289,27 @@ struct posix_acl *bch2_get_acl(struct mnt_idmap *idmap,
290289

291290
ret = bch2_hash_lookup(trans, &iter, bch2_xattr_hash_desc,
292291
&hash, inode_inum(inode), &search, 0);
293-
if (ret) {
294-
if (!bch2_err_matches(ret, ENOENT))
295-
acl = ERR_PTR(ret);
296-
goto out;
297-
}
292+
if (ret)
293+
goto err;
298294

299295
k = bch2_btree_iter_peek_slot(&iter);
300296
ret = bkey_err(k);
301-
if (ret) {
302-
acl = ERR_PTR(ret);
303-
goto out;
304-
}
297+
if (ret)
298+
goto err;
305299

306-
xattr = bkey_s_c_to_xattr(k);
300+
struct bkey_s_c_xattr xattr = bkey_s_c_to_xattr(k);
307301
acl = bch2_acl_from_disk(trans, xattr_val(xattr.v),
308-
le16_to_cpu(xattr.v->x_val_len));
302+
le16_to_cpu(xattr.v->x_val_len));
303+
ret = PTR_ERR_OR_ZERO(acl);
304+
err:
305+
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
306+
goto retry;
309307

310-
if (!IS_ERR(acl))
308+
if (ret)
309+
acl = !bch2_err_matches(ret, ENOENT) ? ERR_PTR(ret) : NULL;
310+
311+
if (!IS_ERR_OR_NULL(acl))
311312
set_cached_acl(&inode->v, type, acl);
312-
out:
313-
if (bch2_err_matches(PTR_ERR_OR_ZERO(acl), BCH_ERR_transaction_restart))
314-
goto retry;
315313

316314
bch2_trans_iter_exit(trans, &iter);
317315
bch2_trans_put(trans);

0 commit comments

Comments
 (0)