bcachefs: bch2_folio_set() -> for_each_btree_key_in_subvolume_upto
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c95285d17e
commit
093dd55d19
@ -182,18 +182,11 @@ static void __bch2_folio_set(struct folio *folio,
|
|||||||
int bch2_folio_set(struct bch_fs *c, subvol_inum inum,
|
int bch2_folio_set(struct bch_fs *c, subvol_inum inum,
|
||||||
struct folio **fs, unsigned nr_folios)
|
struct folio **fs, unsigned nr_folios)
|
||||||
{
|
{
|
||||||
struct btree_trans *trans;
|
|
||||||
struct btree_iter iter;
|
|
||||||
struct bkey_s_c k;
|
|
||||||
struct bch_folio *s;
|
|
||||||
u64 offset = folio_sector(fs[0]);
|
u64 offset = folio_sector(fs[0]);
|
||||||
unsigned folio_idx;
|
|
||||||
u32 snapshot;
|
|
||||||
bool need_set = false;
|
bool need_set = false;
|
||||||
int ret;
|
|
||||||
|
|
||||||
for (folio_idx = 0; folio_idx < nr_folios; folio_idx++) {
|
for (unsigned folio_idx = 0; folio_idx < nr_folios; folio_idx++) {
|
||||||
s = bch2_folio_create(fs[folio_idx], GFP_KERNEL);
|
struct bch_folio *s = bch2_folio_create(fs[folio_idx], GFP_KERNEL);
|
||||||
if (!s)
|
if (!s)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -203,18 +196,13 @@ int bch2_folio_set(struct bch_fs *c, subvol_inum inum,
|
|||||||
if (!need_set)
|
if (!need_set)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
folio_idx = 0;
|
unsigned folio_idx = 0;
|
||||||
trans = bch2_trans_get(c);
|
|
||||||
retry:
|
|
||||||
bch2_trans_begin(trans);
|
|
||||||
|
|
||||||
ret = bch2_subvolume_get_snapshot(trans, inum.subvol, &snapshot);
|
return bch2_trans_run(c,
|
||||||
if (ret)
|
for_each_btree_key_in_subvolume_upto(trans, iter, BTREE_ID_extents,
|
||||||
goto err;
|
POS(inum.inum, offset),
|
||||||
|
POS(inum.inum, U64_MAX),
|
||||||
for_each_btree_key_norestart(trans, iter, BTREE_ID_extents,
|
inum.subvol, BTREE_ITER_slots, k, ({
|
||||||
SPOS(inum.inum, offset, snapshot),
|
|
||||||
BTREE_ITER_slots, k, ret) {
|
|
||||||
unsigned nr_ptrs = bch2_bkey_nr_ptrs_fully_allocated(k);
|
unsigned nr_ptrs = bch2_bkey_nr_ptrs_fully_allocated(k);
|
||||||
unsigned state = bkey_to_sector_state(k);
|
unsigned state = bkey_to_sector_state(k);
|
||||||
|
|
||||||
@ -240,16 +228,8 @@ int bch2_folio_set(struct bch_fs *c, subvol_inum inum,
|
|||||||
|
|
||||||
if (folio_idx == nr_folios)
|
if (folio_idx == nr_folios)
|
||||||
break;
|
break;
|
||||||
}
|
0;
|
||||||
|
})));
|
||||||
offset = iter.pos.offset;
|
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
|
||||||
err:
|
|
||||||
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
|
||||||
goto retry;
|
|
||||||
bch2_trans_put(trans);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_bio_page_state_set(struct bio *bio, struct bkey_s_c k)
|
void bch2_bio_page_state_set(struct bio *bio, struct bkey_s_c k)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user