Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/newfs align buffers used for I/O to DEV_BSIZE so it's e...



details:   https://anonhg.NetBSD.org/src/rev/597a8cae2185
branches:  trunk
changeset: 1009224:597a8cae2185
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Apr 17 09:33:37 2020 +0000

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

diffstat:

 sbin/newfs/mkfs.c  |  16 +++++++++-------
 sbin/newfs/newfs.c |   7 ++++---
 2 files changed, 13 insertions(+), 10 deletions(-)

diffs (90 lines):

diff -r d4c834870ec9 -r 597a8cae2185 sbin/newfs/mkfs.c
--- a/sbin/newfs/mkfs.c Fri Apr 17 08:17:06 2020 +0000
+++ b/sbin/newfs/mkfs.c Fri Apr 17 09:33:37 2020 +0000
@@ -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 @@
                        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 @@
 
 #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 @@
 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 @@
 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;
diff -r d4c834870ec9 -r 597a8cae2185 sbin/newfs/newfs.c
--- a/sbin/newfs/newfs.c        Fri Apr 17 08:17:06 2020 +0000
+++ b/sbin/newfs/newfs.c        Fri Apr 17 09:33:37 2020 +0000
@@ -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 @@
 #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 @@
                } 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', "



Home | Main Index | Thread Index | Old Index