block_size is in bytes, not sectors, so when calling round_up(),
we could start rounding up by a way too large size and then overflow
outside the area that migrate allocated for us.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
this gets us back down to a single fd for opening block devices, which
means we can use O_EXCL.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This adds a new option to cmd_fsck for using the kernel implementation
of fsck instead of userspace, via the BCH_IOCTL_FSCK_OFFLINE ioctl.
This isn't intended for normal usage - mainly for testing and debugging
purposes, and for when the kernel version of bcachefs better matches the
on disk format version.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Although glibc also provides basename(3) from <string.h>, this is
non-standard whereas it is available from <libgen.h> portably.
Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Erasure coding can't create stripes across devices with different bucket
sizes - therefore, format shouldn't pick different bucket sizes for
different devices.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
bch_sb.features is an array of __le64. Convert the native endian format
of the features mask appropriately. This causes a bcachefs format to
produce an unmountable fs when run from a big endian system.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
In bch2_format(): recompute mi after each sb modification:
its location in memory may have changed due to reallocation.
This fixes an issue where labels were not assigned (because
they were written to an undefined part of the heap instead of
the superblock).
Signed-off-by: Wessel Dankers <wsl@fruit.je>
The option code has been switching to keeping things in display units -
bytes - and this transitions more libbcachefs.c code to bytes as well,
to match, and also fixes device add.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
It was incorrectly failing when we did have enough space for the
superblocks - >= should have been >. Also, give it a better error
message.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Disk labels used to be called groups - not all uses had been converted.
This renames --group to --label, and --label to --fs_label
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This is a fixup for d3dc47271b Add format options for --no-initialize
and specifying the metadata version
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
While metadata_target was an option in bcachefs and the fs driver knows about it,
it was never parsed by the bcachefs format command.
This commit fixes the issue
This adds a new list mode to "bcachefs list", for printing out nodes as
they exist on disk (before being merge sorted). Also some improvements
to fsck return values.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>