From 3304c90beca961b1bc8ae291015d4064bc3ce203 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 13 Apr 2025 08:39:02 -0400 Subject: format_opts.no_sb_at_end Add an option for controlling whether we create a third redundant superblock at the end of the device. For image files that are going to immediately be resized, we want to skip this. Signed-off-by: Kent Overstreet --- c_src/libbcachefs.c | 2 +- c_src/libbcachefs.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'c_src') diff --git a/c_src/libbcachefs.c b/c_src/libbcachefs.c index 2abf488d..eb99535f 100644 --- a/c_src/libbcachefs.c +++ b/c_src/libbcachefs.c @@ -315,7 +315,7 @@ struct bch_sb *bch2_format(struct bch_opt_strs fs_opt_strs, * means we're being run from the migrate tool and we could be * overwriting existing data if we write to the end of the disk: */ - if (i->sb_offset == BCH_SB_SECTOR) { + if (i->sb_offset == BCH_SB_SECTOR && !opts.no_sb_at_end) { struct bch_sb_layout *l = &sb.sb->layout; u64 backup_sb = size_sectors - (1 << l->sb_max_size_bits); diff --git a/c_src/libbcachefs.h b/c_src/libbcachefs.h index defdbe2b..6e9de138 100644 --- a/c_src/libbcachefs.h +++ b/c_src/libbcachefs.h @@ -43,6 +43,7 @@ struct format_opts { bool encrypted; char *passphrase; char *source; + bool no_sb_at_end; }; static inline unsigned bcachefs_kernel_version(void) -- cgit v1.2.3