Skip to content

Commit 3858aa4

Browse files
author
Kent Overstreet
committed
bcachefs: ptr_stale() -> dev_ptr_stale()
Signed-off-by: Kent Overstreet <[email protected]>
1 parent 302c980 commit 3858aa4

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ struct bch_dev {
573573
* Buckets:
574574
* Per-bucket arrays are protected by c->mark_lock, bucket_lock and
575575
* gc_lock, for device resize - holding any is sufficient for access:
576-
* Or rcu_read_lock(), but only for ptr_stale():
576+
* Or rcu_read_lock(), but only for dev_ptr_stale():
577577
*/
578578
struct bucket_array __rcu *buckets_gc;
579579
struct bucket_gens __rcu *bucket_gens;

fs/bcachefs/btree_gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ static int gc_btree_gens_key(struct btree_trans *trans,
12571257
bkey_for_each_ptr(ptrs, ptr) {
12581258
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev);
12591259

1260-
if (ptr_stale(ca, ptr) > 16) {
1260+
if (dev_ptr_stale(ca, ptr) > 16) {
12611261
percpu_up_read(&c->mark_lock);
12621262
goto update;
12631263
}

fs/bcachefs/buckets.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,19 @@ static inline int gen_after(u8 a, u8 b)
170170
return r > 0 ? r : 0;
171171
}
172172

173+
static inline u8 dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr)
174+
{
175+
return gen_after(*bucket_gen(ca, PTR_BUCKET_NR(ca, ptr)), ptr->gen);
176+
}
177+
173178
/**
174-
* ptr_stale() - check if a pointer points into a bucket that has been
179+
* dev_ptr_stale() - check if a pointer points into a bucket that has been
175180
* invalidated.
176181
*/
177-
static inline u8 ptr_stale(struct bch_dev *ca,
178-
const struct bch_extent_ptr *ptr)
182+
static inline u8 dev_ptr_stale(struct bch_dev *ca, const struct bch_extent_ptr *ptr)
179183
{
180-
u8 ret;
181-
182184
rcu_read_lock();
183-
ret = gen_after(*bucket_gen(ca, PTR_BUCKET_NR(ca, ptr)), ptr->gen);
185+
u8 ret = dev_ptr_stale_rcu(ca, ptr);
184186
rcu_read_unlock();
185187

186188
return ret;

fs/bcachefs/ec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static void ec_block_endio(struct bio *bio)
714714
bch2_blk_status_to_str(bio->bi_status)))
715715
clear_bit(ec_bio->idx, ec_bio->buf->valid);
716716

717-
if (ptr_stale(ca, ptr)) {
717+
if (dev_ptr_stale(ca, ptr)) {
718718
bch_err_ratelimited(ca->fs,
719719
"error %s stripe: stale pointer after io",
720720
bio_data_dir(bio) == READ ? "reading from" : "writing to");
@@ -738,7 +738,7 @@ static void ec_block_io(struct bch_fs *c, struct ec_stripe_buf *buf,
738738
: BCH_DATA_parity;
739739
int rw = op_is_write(opf);
740740

741-
if (ptr_stale(ca, ptr)) {
741+
if (dev_ptr_stale(ca, ptr)) {
742742
bch_err_ratelimited(c,
743743
"error %s stripe: stale pointer",
744744
rw == READ ? "reading from" : "writing to");

fs/bcachefs/extents.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
132132
if (!ret && !p.ptr.cached)
133133
ret = -EIO;
134134

135-
if (p.ptr.cached && ptr_stale(ca, &p.ptr))
135+
if (p.ptr.cached && dev_ptr_stale(ca, &p.ptr))
136136
continue;
137137

138138
f = failed ? dev_io_failures(failed, p.ptr.dev) : NULL;
@@ -874,7 +874,7 @@ bool bch2_bkey_has_target(struct bch_fs *c, struct bkey_s_c k, unsigned target)
874874
bkey_for_each_ptr(ptrs, ptr)
875875
if (bch2_dev_in_target(c, ptr->dev, target) &&
876876
(!ptr->cached ||
877-
!ptr_stale(bch2_dev_bkey_exists(c, ptr->dev), ptr)))
877+
!dev_ptr_stale(bch2_dev_bkey_exists(c, ptr->dev), ptr)))
878878
return true;
879879

880880
return false;
@@ -981,7 +981,7 @@ bool bch2_extent_normalize(struct bch_fs *c, struct bkey_s k)
981981
{
982982
bch2_bkey_drop_ptrs(k, ptr,
983983
ptr->cached &&
984-
ptr_stale(bch2_dev_bkey_exists(c, ptr->dev), ptr));
984+
dev_ptr_stale(bch2_dev_bkey_exists(c, ptr->dev), ptr));
985985

986986
return bkey_deleted(k.k);
987987
}
@@ -1005,7 +1005,7 @@ void bch2_extent_ptr_to_text(struct printbuf *out, struct bch_fs *c, const struc
10051005
prt_str(out, " cached");
10061006
if (ptr->unwritten)
10071007
prt_str(out, " unwritten");
1008-
if (bucket_valid(ca, b) && ptr_stale(ca, ptr))
1008+
if (bucket_valid(ca, b) && dev_ptr_stale_rcu(ca, ptr))
10091009
prt_printf(out, " stale");
10101010
}
10111011
rcu_read_unlock();

fs/bcachefs/io_read.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static void bch2_read_endio(struct bio *bio)
697697
}
698698

699699
if (((rbio->flags & BCH_READ_RETRY_IF_STALE) && race_fault()) ||
700-
ptr_stale(ca, &rbio->pick.ptr)) {
700+
dev_ptr_stale(ca, &rbio->pick.ptr)) {
701701
trace_and_count(c, read_reuse_race, &rbio->bio);
702702

703703
if (rbio->flags & BCH_READ_RETRY_IF_STALE)
@@ -841,7 +841,7 @@ int __bch2_read_extent(struct btree_trans *trans, struct bch_read_bio *orig,
841841
*/
842842
if ((flags & BCH_READ_IN_RETRY) &&
843843
!pick.ptr.cached &&
844-
unlikely(ptr_stale(ca, &pick.ptr))) {
844+
unlikely(dev_ptr_stale(ca, &pick.ptr))) {
845845
read_from_stale_dirty_pointer(trans, k, pick.ptr);
846846
bch2_mark_io_failure(failed, &pick);
847847
goto retry_pick;

0 commit comments

Comments
 (0)