Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_ffs align buffers used for I/O to DEV_BSIZE so it'...
details: https://anonhg.NetBSD.org/src/rev/cfcfb8020431
branches: trunk
changeset: 971190:cfcfb8020431
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Fri Apr 17 09:42:27 2020 +0000
description:
align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device
diffstat:
sbin/fsck_ffs/inode.c | 6 +++---
sbin/fsck_ffs/setup.c | 21 ++++++++++++---------
sbin/fsck_ffs/utilities.c | 10 +++++-----
3 files changed, 20 insertions(+), 17 deletions(-)
diffs (143 lines):
diff -r 735fd346b4b8 -r cfcfb8020431 sbin/fsck_ffs/inode.c
--- a/sbin/fsck_ffs/inode.c Fri Apr 17 09:33:37 2020 +0000
+++ b/sbin/fsck_ffs/inode.c Fri Apr 17 09:42:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $ */
+/* $NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $");
#endif
#endif /* not lint */
@@ -463,7 +463,7 @@
partialsize = inobufsize;
}
if (inodebuf == NULL &&
- (inodebuf = malloc((unsigned)inobufsize)) == NULL)
+ (inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
errexit("Cannot allocate space for inode buffer");
}
diff -r 735fd346b4b8 -r cfcfb8020431 sbin/fsck_ffs/setup.c
--- a/sbin/fsck_ffs/setup.c Fri Apr 17 09:33:37 2020 +0000
+++ b/sbin/fsck_ffs/setup.c Fri Apr 17 09:42:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $ */
+/* $NetBSD: setup.c,v 1.103 2020/04/17 09:42:27 jdolecek Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#else
-__RCSID("$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $");
+__RCSID("$NetBSD: setup.c,v 1.103 2020/04/17 09:42:27 jdolecek Exp $");
#endif
#endif /* not lint */
@@ -126,10 +126,10 @@
lfdir = 0;
initbarea(&sblk);
initbarea(&asblk);
- sblk.b_un.b_buf = malloc(SBLOCKSIZE);
- sblock = malloc(SBLOCKSIZE);
- asblk.b_un.b_buf = malloc(SBLOCKSIZE);
- altsblock = malloc(SBLOCKSIZE);
+ sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+ sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+ asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+ altsblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL ||
sblock == NULL || altsblock == NULL)
errexit("Cannot allocate space for superblock");
@@ -458,12 +458,14 @@
* read in the summary info.
*/
asked = 0;
- sblock->fs_csp = (struct csum *)calloc(1, sblock->fs_cssize);
+ sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
+ sblock->fs_cssize);
if (sblock->fs_csp == NULL) {
pwarn("cannot alloc %u bytes for summary info\n",
sblock->fs_cssize);
goto badsblabel;
}
+ memset(sblock->fs_csp, 0, sblock->fs_cssize);
for (i = 0, j = 0; i < sblock->fs_cssize; i += sblock->fs_bsize, j++) {
size = sblock->fs_cssize - i < sblock->fs_bsize ?
sblock->fs_cssize - i : sblock->fs_bsize;
@@ -492,12 +494,13 @@
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
- blockmap = calloc((unsigned)bmapsize, sizeof (char));
+ blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
if (blockmap == NULL) {
pwarn("cannot alloc %u bytes for blockmap\n",
(unsigned)bmapsize);
goto badsblabel;
}
+ memset(blockmap, 0, bmapsize);
inostathead = calloc((unsigned)(sblock->fs_ncg),
sizeof(struct inostatlist));
if (inostathead == NULL) {
@@ -526,7 +529,7 @@
(unsigned)(numdirs * sizeof(struct inoinfo *)));
goto badsblabel;
}
- cgrp = malloc(sblock->fs_cgsize);
+ cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
if (cgrp == NULL) {
pwarn("cannot alloc %u bytes for cylinder group\n",
sblock->fs_cgsize);
diff -r 735fd346b4b8 -r cfcfb8020431 sbin/fsck_ffs/utilities.c
--- a/sbin/fsck_ffs/utilities.c Fri Apr 17 09:33:37 2020 +0000
+++ b/sbin/fsck_ffs/utilities.c Fri Apr 17 09:42:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utilities.c,v 1.65 2017/02/08 16:11:40 rin Exp $ */
+/* $NetBSD: utilities.c,v 1.66 2020/04/17 09:42:27 jdolecek Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
#else
-__RCSID("$NetBSD: utilities.c,v 1.65 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.66 2020/04/17 09:42:27 jdolecek Exp $");
#endif
#endif /* not lint */
@@ -135,13 +135,13 @@
char *bufp;
pbp = pdirbp = (struct bufarea *)0;
- bufp = malloc((unsigned int)sblock->fs_bsize);
+ bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
if (bufp == 0)
errexit("cannot allocate buffer pool");
cgblk.b_un.b_buf = bufp;
initbarea(&cgblk);
#ifndef NO_APPLE_UFS
- bufp = malloc((unsigned int)APPLEUFS_LABEL_SIZE);
+ bufp = aligned_alloc(DEV_BSIZE, (unsigned int)APPLEUFS_LABEL_SIZE);
if (bufp == 0)
errexit("cannot allocate buffer pool");
appleufsblk.b_un.b_buf = bufp;
@@ -153,7 +153,7 @@
bufcnt = MINBUFS;
for (i = 0; i < bufcnt; i++) {
bp = malloc(sizeof(struct bufarea));
- bufp = malloc((unsigned int)sblock->fs_bsize);
+ bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
if (bp == NULL || bufp == NULL) {
if (i >= MINBUFS) {
if (bp)
Home |
Main Index |
Thread Index |
Old Index