* Write superblock @sb to the @device. Do not wait for completion, all the
* folios we use for writing are locked.
*
- * Write @max_mirrors copies of the superblock, where 0 means default that fit
- * the expected device size at commit time. Note that max_mirrors must be
+ * Write @max_mirrors copies of the superblock. Note that max_mirrors must be
* same for write and wait phases.
*
* Return number of errors when folio is not found or submission fails.
atomic_set(&device->sb_write_errors, 0);
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
struct bio *bio;
int ret;
u64 bytenr;
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
return min_tolerated;
}
-int write_all_supers(struct btrfs_trans_handle *trans, int max_mirrors)
+int write_all_supers(struct btrfs_trans_handle *trans)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
struct list_head *head;
struct btrfs_device *dev;
struct btrfs_super_block *sb;
struct btrfs_dev_item *dev_item;
+ int max_mirrors;
int ret;
int do_barriers;
int max_errors;
do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);
- /*
- * max_mirrors == 0 indicates we're from commit_transaction,
- * not from fsync where the tree roots in fs_info have not
- * been consistent on disk.
- */
- if (max_mirrors == 0) {
+ if (trans->transaction->state < TRANS_STATE_UNBLOCKED) {
+ /* We are called from fsync. */
+ max_mirrors = 1;
+ } else {
+ /* We are called from transaction commit. */
+ max_mirrors = BTRFS_SUPER_MIRROR_MAX;
ret = backup_super_roots(fs_info);
if (ret < 0)
return ret;
int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
const struct btrfs_super_block *sb, int mirror_num);
int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount);
-int write_all_supers(struct btrfs_trans_handle *trans, int max_mirrors);
+int write_all_supers(struct btrfs_trans_handle *trans);
int btrfs_commit_super(struct btrfs_fs_info *fs_info);
struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
const struct btrfs_key *key);
btrfs_set_super_log_root(fs_info->super_for_commit, log_root_start);
btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level);
- ret = write_all_supers(trans, 1);
+ ret = write_all_supers(trans);
mutex_unlock(&fs_info->tree_log_mutex);
if (unlikely(ret)) {
btrfs_set_log_full_commit(trans);