Skip to content

Commit 1f73cb4

Browse files
author
Kent Overstreet
committed
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>
1 parent 72350ee commit 1f73cb4

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

fs/bcachefs/inode.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -327,22 +327,20 @@ int bch2_inode_unpack(struct bkey_s_c k,
327327
: bch2_inode_unpack_slowpath(k, unpacked);
328328
}
329329

330-
int bch2_inode_peek_nowarn(struct btree_trans *trans,
331-
struct btree_iter *iter,
332-
struct bch_inode_unpacked *inode,
333-
subvol_inum inum, unsigned flags)
330+
int __bch2_inode_peek(struct btree_trans *trans,
331+
struct btree_iter *iter,
332+
struct bch_inode_unpacked *inode,
333+
subvol_inum inum, unsigned flags,
334+
bool warn)
334335
{
335-
struct bkey_s_c k;
336336
u32 snapshot;
337-
int ret;
338-
339-
ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot);
337+
int ret = __bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot, warn);
340338
if (ret)
341339
return ret;
342340

343-
k = bch2_bkey_get_iter(trans, iter, BTREE_ID_inodes,
344-
SPOS(0, inum.inum, snapshot),
345-
flags|BTREE_ITER_cached);
341+
struct bkey_s_c k = bch2_bkey_get_iter(trans, iter, BTREE_ID_inodes,
342+
SPOS(0, inum.inum, snapshot),
343+
flags|BTREE_ITER_cached);
346344
ret = bkey_err(k);
347345
if (ret)
348346
return ret;
@@ -357,20 +355,12 @@ int bch2_inode_peek_nowarn(struct btree_trans *trans,
357355

358356
return 0;
359357
err:
358+
if (warn)
359+
bch_err_msg(trans->c, ret, "looking up inum %llu:%llu:", inum.subvol, inum.inum);
360360
bch2_trans_iter_exit(trans, iter);
361361
return ret;
362362
}
363363

364-
int bch2_inode_peek(struct btree_trans *trans,
365-
struct btree_iter *iter,
366-
struct bch_inode_unpacked *inode,
367-
subvol_inum inum, unsigned flags)
368-
{
369-
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
370-
bch_err_msg(trans->c, ret, "looking up inum %llu:%llu:", inum.subvol, inum.inum);
371-
return ret;
372-
}
373-
374364
int bch2_inode_write_flags(struct btree_trans *trans,
375365
struct btree_iter *iter,
376366
struct bch_inode_unpacked *inode,

fs/bcachefs/inode.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,26 @@ struct bkey_i *bch2_inode_to_v3(struct btree_trans *, struct bkey_i *);
9797

9898
void bch2_inode_unpacked_to_text(struct printbuf *, struct bch_inode_unpacked *);
9999

100-
int bch2_inode_peek_nowarn(struct btree_trans *, struct btree_iter *,
101-
struct bch_inode_unpacked *, subvol_inum, unsigned);
102-
int bch2_inode_peek(struct btree_trans *, struct btree_iter *,
103-
struct bch_inode_unpacked *, subvol_inum, unsigned);
100+
int __bch2_inode_peek(struct btree_trans *, struct btree_iter *,
101+
struct bch_inode_unpacked *, subvol_inum, unsigned, bool);
102+
103+
static inline int bch2_inode_peek_nowarn(struct btree_trans *trans,
104+
struct btree_iter *iter,
105+
struct bch_inode_unpacked *inode,
106+
subvol_inum inum, unsigned flags)
107+
{
108+
return __bch2_inode_peek(trans, iter, inode, inum, flags, false);
109+
}
110+
111+
static inline int bch2_inode_peek(struct btree_trans *trans,
112+
struct btree_iter *iter,
113+
struct bch_inode_unpacked *inode,
114+
subvol_inum inum, unsigned flags)
115+
{
116+
return __bch2_inode_peek(trans, iter, inode, inum, flags, true);
117+
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
118+
return ret;
119+
}
104120

105121
int bch2_inode_write_flags(struct btree_trans *, struct btree_iter *,
106122
struct bch_inode_unpacked *, enum btree_iter_update_trigger_flags);

fs/bcachefs/subvolume.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ int bch2_snapshot_get_subvol(struct btree_trans *trans, u32 snapshot,
332332
bch2_subvolume_get(trans, le32_to_cpu(snap.subvol), true, 0, subvol);
333333
}
334334

335-
int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
336-
u32 *snapid)
335+
int __bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
336+
u32 *snapid, bool warn)
337337
{
338338
struct btree_iter iter;
339339
struct bkey_s_c_subvolume subvol;
@@ -344,7 +344,8 @@ int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
344344
BTREE_ITER_cached|BTREE_ITER_with_updates,
345345
subvolume);
346346
ret = bkey_err(subvol);
347-
bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
347+
348+
bch2_fs_inconsistent_on(warn && bch2_err_matches(ret, ENOENT), trans->c,
348349
"missing subvolume %u", subvolid);
349350

350351
if (likely(!ret))
@@ -353,6 +354,12 @@ int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
353354
return ret;
354355
}
355356

357+
int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
358+
u32 *snapid)
359+
{
360+
return __bch2_subvolume_get_snapshot(trans, subvolid, snapid, true);
361+
}
362+
356363
static int bch2_subvolume_reparent(struct btree_trans *trans,
357364
struct btree_iter *iter,
358365
struct bkey_s_c k,

fs/bcachefs/subvolume.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ int bch2_subvolume_trigger(struct btree_trans *, enum btree_id, unsigned,
2626
int bch2_subvol_has_children(struct btree_trans *, u32);
2727
int bch2_subvolume_get(struct btree_trans *, unsigned,
2828
bool, int, struct bch_subvolume *);
29+
int __bch2_subvolume_get_snapshot(struct btree_trans *, u32,
30+
u32 *, bool);
2931
int bch2_subvolume_get_snapshot(struct btree_trans *, u32, u32 *);
3032

3133
int bch2_subvol_is_ro_trans(struct btree_trans *, u32);

0 commit comments

Comments
 (0)