Module Name:    src
Committed By:   jdolecek
Date:           Fri Apr 17 09:33:37 UTC 2020

Modified Files:
        src/sbin/newfs: mkfs.c newfs.c

Log Message:
align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) device


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.115 -r1.116 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.128 src/sbin/newfs/mkfs.c:1.129
--- src/sbin/newfs/mkfs.c:1.128	Wed Feb  8 16:11:40 2017
+++ src/sbin/newfs/mkfs.c	Fri Apr 17 09:33:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.129 2020/04/17 09:33:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.129 2020/04/17 09:33:37 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -200,10 +200,12 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
-	if ((fsun = calloc(1, sizeof(*fsun))) == NULL)
+	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
-	if ((cgun = calloc(1, sizeof(*cgun))) == NULL)
+	memset(fsun, 0, sizeof(*fsun));
+	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
+	memset(cgun, 0, sizeof(*cgun));
 
 	fsi = fi;
 	fso = fo;
@@ -633,7 +635,7 @@ mkfs(const char *fsys, int fi, int fo,
 
 #ifndef NO_APPLE_UFS
 		if (isappleufs) {
-			struct appleufslabel appleufs;
+			struct appleufslabel appleufs __aligned(DEV_BSIZE);
 			ffs_appleufs_set(&appleufs, appleufs_volname,
 			    tv.tv_sec, 0);
 			wtfs(APPLEUFS_LABEL_OFFSET/sectorsize,
@@ -1034,7 +1036,7 @@ int
 fsinit(const struct timeval *tv, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
 {
 	union dinode node;
-	union Buffer buf;
+	union Buffer buf __aligned(DEV_BSIZE);
 	int i;
 	int qblocks = 0;
 	int qinos = 0;
@@ -1584,7 +1586,7 @@ static void
 zap_old_sblock(int sblkoff)
 {
 	static int cg0_data;
-	uint32_t oldfs[SBLOCKSIZE / 4];
+	uint32_t oldfs[SBLOCKSIZE / 4] __aligned(DEV_BSIZE);
 	static const struct fsm {
 		uint32_t	offset;
 		uint32_t	magic;

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.115 src/sbin/newfs/newfs.c:1.116
--- src/sbin/newfs/newfs.c:1.115	Wed Feb  8 16:11:40 2017
+++ src/sbin/newfs/newfs.c	Fri Apr 17 09:33:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: newfs.c,v 1.116 2020/04/17 09:33:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.116 2020/04/17 09:33:37 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -619,9 +619,10 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		if ((buf = calloc(1, bufsize)) == NULL)
+		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
+		memset(buf, 0, bufsize);
 		bufrem = fssize * sectorsize;
 		if (verbosity > 0)
 			printf( "Creating file system image in `%s', "

Reply via email to