diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-03-09 00:24:39 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-03-09 00:27:27 +0100 |
| commit | d217f6e5082fab342267df3430ca6b9f2e399c93 (patch) | |
| tree | 994e7667472ac542dbb6a11d17a7331c3916e47f /src | |
| parent | b13cbdce2fe1c4790f0737a75ac49aa1b826eb66 (diff) | |
Use writebytes when writing group descriptors.
This may be faster but I should test it. The code is cleaner and
should be equivalent, as far as I can see.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ext4_mkfs.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/ext4_mkfs.c b/src/ext4_mkfs.c index 123a38d..a62e4cf 100644 --- a/src/ext4_mkfs.c +++ b/src/ext4_mkfs.c @@ -368,8 +368,6 @@ static int write_bgroups(struct ext4_fs *fs, struct ext4_blockdev *bd, struct fs int r = EOK; - struct ext4_block b; - for (uint32_t i = 0; i < aux_info->groups; i++) { uint64_t bg_start_block = aux_info->first_data_block + aux_info->first_data_block + i * info->blocks_per_group; @@ -381,24 +379,7 @@ static int write_bgroups(struct ext4_fs *fs, struct ext4_blockdev *bd, struct fs } /* Group descriptors */ - uint32_t remaining = aux_info->groups * dsc_size; - for (uint32_t j = 0; j < aux_info->bg_desc_blocks; j++) { - r = ext4_block_get_noread(bd, &b, bg_start_block + blk_off + j); - if (r != EOK) { - free(all_bg_desc); - return r; - } - uint32_t this_time = remaining < block_size ? remaining : block_size; - memcpy(b.data, ((char *) all_bg_desc) + j * block_size, this_time); - memset(b.data + this_time, 0, block_size - this_time); - remaining -= this_time; - ext4_bcache_set_dirty(b.buf); - r = ext4_block_set(bd, &b); - if (r != EOK) { - free(all_bg_desc); - return r; - } - } + ext4_block_writebytes(bd, (bg_start_block + blk_off) * block_size, all_bg_desc, aux_info->groups * dsc_size); blk_off += aux_info->bg_desc_blocks; |
