Skip to content

Commit

Permalink
bcachefs: BCH_SB_MEMBER_INVALID
Browse files Browse the repository at this point in the history
Create a sentinal value for "invalid device".

This is needed for removing devices that have stripes on them (force
removing, without evacuating); we need a sentinal value for the stripe
pointers to the device being removed.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Sep 4, 2024
1 parent 7f12a96 commit 53f6619
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fs/bcachefs/replicas.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ int bch2_replicas_entry_validate(struct bch_replicas_entry_v1 *r,
}

for (unsigned i = 0; i < r->nr_devs; i++)
if (!bch2_member_exists(sb, r->devs[i])) {
if (r->devs[i] != BCH_SB_MEMBER_INVALID &&
!bch2_member_exists(sb, r->devs[i])) {
prt_printf(err, "invalid device %u in entry ", r->devs[i]);
goto bad;
}
Expand Down
3 changes: 2 additions & 1 deletion fs/bcachefs/sb-members.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

void bch2_dev_missing(struct bch_fs *c, unsigned dev)
{
bch2_fs_inconsistent(c, "pointer to nonexistent device %u", dev);
if (dev != BCH_SB_MEMBER_INVALID)
bch2_fs_inconsistent(c, "pointer to nonexistent device %u", dev);
}

void bch2_dev_bucket_missing(struct bch_fs *c, struct bpos bucket)
Expand Down
5 changes: 5 additions & 0 deletions fs/bcachefs/sb-members_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
#define BCH_SB_MEMBERS_MAX 64

/*
* Sentinal value - indicates a device that does not exist
*/
#define BCH_SB_MEMBER_INVALID 255

#define BCH_MIN_NR_NBUCKETS (1 << 6)

#define BCH_IOPS_MEASUREMENTS() \
Expand Down

0 comments on commit 53f6619

Please sign in to comment.