diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-07-25 01:50:40 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:09 +0200 |
commit | 8b3e9bd65f61dde939538452cbb2a608bc562d34 (patch) | |
tree | 57914926543d42d97d092e75618ed32d4cb8ba37 /fs/bcachefs/xattr.c | |
parent | bcachefs: traverse_all() is responsible for clearing should_be_locked (diff) | |
download | linux-8b3e9bd65f61dde939538452cbb2a608bc562d34.tar.xz linux-8b3e9bd65f61dde939538452cbb2a608bc562d34.zip |
bcachefs: Always check for transaction restarts
On transaction restart iterators won't be locked anymore - make sure
we're always checking for errors.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/xattr.c')
-rw-r--r-- | fs/bcachefs/xattr.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c index d7160e8cdc07..bf4164f98743 100644 --- a/fs/bcachefs/xattr.c +++ b/fs/bcachefs/xattr.c @@ -124,6 +124,7 @@ static int bch2_xattr_get_trans(struct btree_trans *trans, struct bch_inode_info struct bch_hash_info hash = bch2_hash_info_init(trans->c, &inode->ei_inode); struct btree_iter *iter; struct bkey_s_c_xattr xattr; + struct bkey_s_c k; int ret; iter = bch2_hash_lookup(trans, bch2_xattr_hash_desc, &hash, @@ -134,7 +135,12 @@ static int bch2_xattr_get_trans(struct btree_trans *trans, struct bch_inode_info if (ret) goto err; - xattr = bkey_s_c_to_xattr(bch2_btree_iter_peek_slot(iter)); + k = bch2_btree_iter_peek_slot(iter); + ret = bkey_err(k); + if (ret) + goto err; + + xattr = bkey_s_c_to_xattr(k); ret = le16_to_cpu(xattr.v->x_val_len); if (buffer) { if (ret > size) |