mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
bcachefs: Add warn param to subvol_get_snapshot, peek_inode
These shouldn't always be fatal errors - logged op resume, in particular, and we want it as a parameter there. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
72350ee0ea
commit
1f73cb4d34
@ -327,22 +327,20 @@ int bch2_inode_unpack(struct bkey_s_c k,
|
|||||||
: bch2_inode_unpack_slowpath(k, unpacked);
|
: bch2_inode_unpack_slowpath(k, unpacked);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_inode_peek_nowarn(struct btree_trans *trans,
|
int __bch2_inode_peek(struct btree_trans *trans,
|
||||||
struct btree_iter *iter,
|
struct btree_iter *iter,
|
||||||
struct bch_inode_unpacked *inode,
|
struct bch_inode_unpacked *inode,
|
||||||
subvol_inum inum, unsigned flags)
|
subvol_inum inum, unsigned flags,
|
||||||
|
bool warn)
|
||||||
{
|
{
|
||||||
struct bkey_s_c k;
|
|
||||||
u32 snapshot;
|
u32 snapshot;
|
||||||
int ret;
|
int ret = __bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot, warn);
|
||||||
|
|
||||||
ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
k = bch2_bkey_get_iter(trans, iter, BTREE_ID_inodes,
|
struct bkey_s_c k = bch2_bkey_get_iter(trans, iter, BTREE_ID_inodes,
|
||||||
SPOS(0, inum.inum, snapshot),
|
SPOS(0, inum.inum, snapshot),
|
||||||
flags|BTREE_ITER_cached);
|
flags|BTREE_ITER_cached);
|
||||||
ret = bkey_err(k);
|
ret = bkey_err(k);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -357,20 +355,12 @@ int bch2_inode_peek_nowarn(struct btree_trans *trans,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
|
if (warn)
|
||||||
|
bch_err_msg(trans->c, ret, "looking up inum %llu:%llu:", inum.subvol, inum.inum);
|
||||||
bch2_trans_iter_exit(trans, iter);
|
bch2_trans_iter_exit(trans, iter);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_inode_peek(struct btree_trans *trans,
|
|
||||||
struct btree_iter *iter,
|
|
||||||
struct bch_inode_unpacked *inode,
|
|
||||||
subvol_inum inum, unsigned flags)
|
|
||||||
{
|
|
||||||
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
|
|
||||||
bch_err_msg(trans->c, ret, "looking up inum %llu:%llu:", inum.subvol, inum.inum);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bch2_inode_write_flags(struct btree_trans *trans,
|
int bch2_inode_write_flags(struct btree_trans *trans,
|
||||||
struct btree_iter *iter,
|
struct btree_iter *iter,
|
||||||
struct bch_inode_unpacked *inode,
|
struct bch_inode_unpacked *inode,
|
||||||
|
@ -97,10 +97,26 @@ struct bkey_i *bch2_inode_to_v3(struct btree_trans *, struct bkey_i *);
|
|||||||
|
|
||||||
void bch2_inode_unpacked_to_text(struct printbuf *, struct bch_inode_unpacked *);
|
void bch2_inode_unpacked_to_text(struct printbuf *, struct bch_inode_unpacked *);
|
||||||
|
|
||||||
int bch2_inode_peek_nowarn(struct btree_trans *, struct btree_iter *,
|
int __bch2_inode_peek(struct btree_trans *, struct btree_iter *,
|
||||||
struct bch_inode_unpacked *, subvol_inum, unsigned);
|
struct bch_inode_unpacked *, subvol_inum, unsigned, bool);
|
||||||
int bch2_inode_peek(struct btree_trans *, struct btree_iter *,
|
|
||||||
struct bch_inode_unpacked *, subvol_inum, unsigned);
|
static inline int bch2_inode_peek_nowarn(struct btree_trans *trans,
|
||||||
|
struct btree_iter *iter,
|
||||||
|
struct bch_inode_unpacked *inode,
|
||||||
|
subvol_inum inum, unsigned flags)
|
||||||
|
{
|
||||||
|
return __bch2_inode_peek(trans, iter, inode, inum, flags, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int bch2_inode_peek(struct btree_trans *trans,
|
||||||
|
struct btree_iter *iter,
|
||||||
|
struct bch_inode_unpacked *inode,
|
||||||
|
subvol_inum inum, unsigned flags)
|
||||||
|
{
|
||||||
|
return __bch2_inode_peek(trans, iter, inode, inum, flags, true);
|
||||||
|
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int bch2_inode_write_flags(struct btree_trans *, struct btree_iter *,
|
int bch2_inode_write_flags(struct btree_trans *, struct btree_iter *,
|
||||||
struct bch_inode_unpacked *, enum btree_iter_update_trigger_flags);
|
struct bch_inode_unpacked *, enum btree_iter_update_trigger_flags);
|
||||||
|
@ -332,8 +332,8 @@ int bch2_snapshot_get_subvol(struct btree_trans *trans, u32 snapshot,
|
|||||||
bch2_subvolume_get(trans, le32_to_cpu(snap.subvol), true, 0, subvol);
|
bch2_subvolume_get(trans, le32_to_cpu(snap.subvol), true, 0, subvol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
|
int __bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
|
||||||
u32 *snapid)
|
u32 *snapid, bool warn)
|
||||||
{
|
{
|
||||||
struct btree_iter iter;
|
struct btree_iter iter;
|
||||||
struct bkey_s_c_subvolume subvol;
|
struct bkey_s_c_subvolume subvol;
|
||||||
@ -344,7 +344,8 @@ int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
|
|||||||
BTREE_ITER_cached|BTREE_ITER_with_updates,
|
BTREE_ITER_cached|BTREE_ITER_with_updates,
|
||||||
subvolume);
|
subvolume);
|
||||||
ret = bkey_err(subvol);
|
ret = bkey_err(subvol);
|
||||||
bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
|
|
||||||
|
bch2_fs_inconsistent_on(warn && bch2_err_matches(ret, ENOENT), trans->c,
|
||||||
"missing subvolume %u", subvolid);
|
"missing subvolume %u", subvolid);
|
||||||
|
|
||||||
if (likely(!ret))
|
if (likely(!ret))
|
||||||
@ -353,6 +354,12 @@ int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
|
||||||
|
u32 *snapid)
|
||||||
|
{
|
||||||
|
return __bch2_subvolume_get_snapshot(trans, subvolid, snapid, true);
|
||||||
|
}
|
||||||
|
|
||||||
static int bch2_subvolume_reparent(struct btree_trans *trans,
|
static int bch2_subvolume_reparent(struct btree_trans *trans,
|
||||||
struct btree_iter *iter,
|
struct btree_iter *iter,
|
||||||
struct bkey_s_c k,
|
struct bkey_s_c k,
|
||||||
|
@ -26,6 +26,8 @@ int bch2_subvolume_trigger(struct btree_trans *, enum btree_id, unsigned,
|
|||||||
int bch2_subvol_has_children(struct btree_trans *, u32);
|
int bch2_subvol_has_children(struct btree_trans *, u32);
|
||||||
int bch2_subvolume_get(struct btree_trans *, unsigned,
|
int bch2_subvolume_get(struct btree_trans *, unsigned,
|
||||||
bool, int, struct bch_subvolume *);
|
bool, int, struct bch_subvolume *);
|
||||||
|
int __bch2_subvolume_get_snapshot(struct btree_trans *, u32,
|
||||||
|
u32 *, bool);
|
||||||
int bch2_subvolume_get_snapshot(struct btree_trans *, u32, u32 *);
|
int bch2_subvolume_get_snapshot(struct btree_trans *, u32, u32 *);
|
||||||
|
|
||||||
int bch2_subvol_is_ro_trans(struct btree_trans *, u32);
|
int bch2_subvol_is_ro_trans(struct btree_trans *, u32);
|
||||||
|
Loading…
Reference in New Issue
Block a user