summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyeongseok.kim <hyeongseok@gmail.com>2020-03-30 16:22:42 +0900
committerhyeongseok.kim <hyeongseok@gmail.com>2020-04-08 09:28:23 +0900
commit41c6a50a702f1a8d0e2f2337520a5b815fb55d9f (patch)
tree4d555410b44e3bff30af80e70a9833f6004f1b02
parent07723d7610873a82ab9ec4c28a85e439713963be (diff)
downloadnewfs_msdos-41c6a50a702f1a8d0e2f2337520a5b815fb55d9f.tar.gz
set bdev->bd_block_size to reduce formatting time
When bdev->bd_block_size is bigger than bytesPerSec, e.g. 1024 bytes, block write should read first to sync-up the mapped block. This fix could prevent unnecessary read by temporarily change bd_block_size to bytesPerSec size while flushing fat data. bd_block_size would be reconfigured again at open() or mount() time. Test: newfs_msdos -A /dev/<foo> (/dev/block/sdh1) [2TB disk / 32kb cluster] : FAT#1/#2 476879KiB/512 bytes to write, before : 476864 read I/Os (each 1024 bytes) : takes 180 seconds after : 0 read I/Os : takes 20 seconds Bug: 152893650 Change-Id: Idaa8d73e056cf740647345457ef9061c429f35a7 Signed-off-by: hyeongseok.kim <hyeongseok@gmail.com>
-rw-r--r--mkfs_msdos.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mkfs_msdos.c b/mkfs_msdos.c
index 04afc84..0ef30f2 100644
--- a/mkfs_msdos.c
+++ b/mkfs_msdos.c
@@ -640,6 +640,12 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
warn("sigaction SIGINFO");
goto done;
}
+
+#if defined(__linux__)
+ if (ioctl(fd, BLKBSZSET, &bpb.bpbBytesPerSec))
+ printf("BLKBSZSET to %u failed\n", bpb.bpbBytesPerSec);
+#endif
+
for (lsn = 0; lsn < dir + (fat == 32 ? bpb.bpbSecPerClust : rds); lsn++) {
if (got_siginfo) {
fprintf(stderr,"%s: writing sector %u of %u (%u%%)\n",