mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Ensure I/O buffers in libufs(3) are 128-byte aligned.
Various disk controllers require their buffers to be aligned to a cache-line size (128 bytes). For buffers allocated in structures, ensure that they are 128-byte aligned. Use aligned_malloc to allocate memory to ensure that the returned memory is 128-byte aligned. While we are here, we replace the dynamically allocated inode buffer with a buffer allocated in the uufsd structure just as the superblock and cylinder group buffers do. This can be removed if/when the kernel is fixed. Because this problem has existed on one I/O subsystem or another since the 1990's, we are probably stuck with dealing with it forever. The problem most recent showed up in Azure, see: https://reviews.freebsd.org/D41728 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267654 Before these fixes were applied, it was confirmed that the changes in this commit also fixed the issue in Azure. Reviewed-by: Warner Losh, kib Tested-by: Souradeep Chakrabarti of Microsoft (earlier version) PR: 267654 Differential Revision: https://reviews.freebsd.org/D41724
This commit is contained in:
parent
415c1c748d
commit
772430dd67
|
@ -2,7 +2,7 @@
|
||||||
PACKAGE= ufs
|
PACKAGE= ufs
|
||||||
LIB= ufs
|
LIB= ufs
|
||||||
SHLIBDIR?= /lib
|
SHLIBDIR?= /lib
|
||||||
SHLIB_MAJOR= 7
|
SHLIB_MAJOR= 8
|
||||||
|
|
||||||
SRCS= block.c cgroup.c gsb_crc32.c inode.c sblock.c type.c ffs_subr.c
|
SRCS= block.c cgroup.c gsb_crc32.c inode.c sblock.c type.c ffs_subr.c
|
||||||
SRCS+= ffs_tables.c
|
SRCS+= ffs_tables.c
|
||||||
|
|
|
@ -57,19 +57,10 @@ bread(struct uufsd *disk, ufs2_daddr_t blockno, void *data, size_t size)
|
||||||
|
|
||||||
ERROR(disk, NULL);
|
ERROR(disk, NULL);
|
||||||
|
|
||||||
p2 = data;
|
BUF_MALLOC(&p2, data, size);
|
||||||
/*
|
if (p2 == NULL) {
|
||||||
* XXX: various disk controllers require alignment of our buffer
|
ERROR(disk, "allocate bounce buffer");
|
||||||
* XXX: which is stricter than struct alignment.
|
goto fail;
|
||||||
* XXX: Bounce the buffer if not 64 byte aligned.
|
|
||||||
* XXX: this can be removed if/when the kernel is fixed
|
|
||||||
*/
|
|
||||||
if (((intptr_t)data) & 0x3f) {
|
|
||||||
p2 = malloc(size);
|
|
||||||
if (p2 == NULL) {
|
|
||||||
ERROR(disk, "allocate bounce buffer");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cnt = pread(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize));
|
cnt = pread(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize));
|
||||||
if (cnt == -1) {
|
if (cnt == -1) {
|
||||||
|
@ -101,7 +92,7 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
|
||||||
{
|
{
|
||||||
ssize_t cnt;
|
ssize_t cnt;
|
||||||
int rv;
|
int rv;
|
||||||
void *p2 = NULL;
|
void *p2;
|
||||||
|
|
||||||
ERROR(disk, NULL);
|
ERROR(disk, NULL);
|
||||||
|
|
||||||
|
@ -110,24 +101,15 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
|
||||||
ERROR(disk, "failed to open disk for writing");
|
ERROR(disk, "failed to open disk for writing");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
BUF_MALLOC(&p2, data, size);
|
||||||
/*
|
if (p2 == NULL) {
|
||||||
* XXX: various disk controllers require alignment of our buffer
|
ERROR(disk, "allocate bounce buffer");
|
||||||
* XXX: which is stricter than struct alignment.
|
return (-1);
|
||||||
* XXX: Bounce the buffer if not 64 byte aligned.
|
|
||||||
* XXX: this can be removed if/when the kernel is fixed
|
|
||||||
*/
|
|
||||||
if (((intptr_t)data) & 0x3f) {
|
|
||||||
p2 = malloc(size);
|
|
||||||
if (p2 == NULL) {
|
|
||||||
ERROR(disk, "allocate bounce buffer");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
memcpy(p2, data, size);
|
|
||||||
data = p2;
|
|
||||||
}
|
}
|
||||||
cnt = pwrite(disk->d_fd, data, size, (off_t)(blockno * disk->d_bsize));
|
if (p2 != data)
|
||||||
if (p2 != NULL)
|
memcpy(p2, data, size);
|
||||||
|
cnt = pwrite(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize));
|
||||||
|
if (p2 != data)
|
||||||
free(p2);
|
free(p2);
|
||||||
if (cnt == -1) {
|
if (cnt == -1) {
|
||||||
ERROR(disk, "write error to block device");
|
ERROR(disk, "write error to block device");
|
||||||
|
@ -137,7 +119,6 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
|
||||||
ERROR(disk, "short write to block device");
|
ERROR(disk, "short write to block device");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (cnt);
|
return (cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,18 +62,10 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum)
|
||||||
ERROR(disk, "inode number out of range");
|
ERROR(disk, "inode number out of range");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
inoblock = disk->d_inoblock;
|
inoblock = (caddr_t)&disk->d_inos[0];
|
||||||
min = disk->d_inomin;
|
min = disk->d_inomin;
|
||||||
max = disk->d_inomax;
|
max = disk->d_inomax;
|
||||||
|
|
||||||
if (inoblock == NULL) {
|
|
||||||
inoblock = malloc(fs->fs_bsize);
|
|
||||||
if (inoblock == NULL) {
|
|
||||||
ERROR(disk, "unable to allocate inode block");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
disk->d_inoblock = inoblock;
|
|
||||||
}
|
|
||||||
if (inum >= min && inum < max)
|
if (inum >= min && inum < max)
|
||||||
goto gotit;
|
goto gotit;
|
||||||
bread(disk, fsbtodb(fs, ino_to_fsba(fs, inum)), inoblock,
|
bread(disk, fsbtodb(fs, ino_to_fsba(fs, inum)), inoblock,
|
||||||
|
@ -107,14 +99,10 @@ putinode(struct uufsd *disk)
|
||||||
struct fs *fs;
|
struct fs *fs;
|
||||||
|
|
||||||
fs = &disk->d_fs;
|
fs = &disk->d_fs;
|
||||||
if (disk->d_inoblock == NULL) {
|
|
||||||
ERROR(disk, "No inode block allocated");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (disk->d_ufs == 2)
|
if (disk->d_ufs == 2)
|
||||||
ffs_update_dinode_ckhash(fs, disk->d_dp.dp2);
|
ffs_update_dinode_ckhash(fs, disk->d_dp.dp2);
|
||||||
if (bwrite(disk, fsbtodb(fs, ino_to_fsba(&disk->d_fs, disk->d_inomin)),
|
if (bwrite(disk, fsbtodb(fs, ino_to_fsba(&disk->d_fs, disk->d_inomin)),
|
||||||
disk->d_inoblock, disk->d_fs.fs_bsize) <= 0)
|
(caddr_t)&disk->d_inos[0], disk->d_fs.fs_bsize) <= 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,13 @@
|
||||||
#ifndef __LIBUFS_H__
|
#ifndef __LIBUFS_H__
|
||||||
#define __LIBUFS_H__
|
#define __LIBUFS_H__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Various disk controllers require their buffers to be aligned to the size
|
||||||
|
* of a cache line. The LIBUFS_BUFALIGN defines the required alignment size.
|
||||||
|
* The alignment must be a power of 2.
|
||||||
|
*/
|
||||||
|
#define LIBUFS_BUFALIGN 128
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* libufs structures.
|
* libufs structures.
|
||||||
*/
|
*/
|
||||||
|
@ -42,39 +49,51 @@ union dinodep {
|
||||||
* userland ufs disk.
|
* userland ufs disk.
|
||||||
*/
|
*/
|
||||||
struct uufsd {
|
struct uufsd {
|
||||||
const char *d_name; /* disk name */
|
|
||||||
int d_ufs; /* decimal UFS version */
|
|
||||||
int d_fd; /* raw device file descriptor */
|
|
||||||
long d_bsize; /* device bsize */
|
|
||||||
ufs2_daddr_t d_sblock; /* superblock location */
|
|
||||||
struct fs_summary_info *d_si; /* Superblock summary info */
|
|
||||||
caddr_t d_inoblock; /* inode block */
|
|
||||||
uint32_t d_inomin; /* low ino, not ino_t for ABI compat */
|
|
||||||
uint32_t d_inomax; /* high ino, not ino_t for ABI compat */
|
|
||||||
union dinodep d_dp; /* pointer to currently active inode */
|
|
||||||
union {
|
union {
|
||||||
struct fs d_fs; /* filesystem information */
|
struct fs d_fs; /* filesystem information */
|
||||||
char d_sb[MAXBSIZE]; /* superblock as buffer */
|
char d_sb[SBLOCKSIZE]; /* superblock as buffer */
|
||||||
} d_sbunion;
|
} d_sbunion __aligned(LIBUFS_BUFALIGN);
|
||||||
union {
|
union {
|
||||||
struct cg d_cg; /* cylinder group */
|
struct cg d_cg; /* cylinder group */
|
||||||
char d_buf[MAXBSIZE]; /* cylinder group storage */
|
char d_buf[MAXBSIZE]; /* cylinder group storage */
|
||||||
} d_cgunion;
|
} d_cgunion __aligned(LIBUFS_BUFALIGN);
|
||||||
int d_ccg; /* current cylinder group */
|
union {
|
||||||
int d_lcg; /* last cylinder group (in d_cg) */
|
union dinodep d_ino[1]; /* inode block */
|
||||||
|
char d_inos[MAXBSIZE]; /* inode block as buffer */
|
||||||
|
} d_inosunion __aligned(LIBUFS_BUFALIGN);
|
||||||
|
const char *d_name; /* disk name */
|
||||||
const char *d_error; /* human readable disk error */
|
const char *d_error; /* human readable disk error */
|
||||||
|
ufs2_daddr_t d_sblock; /* superblock location */
|
||||||
|
struct fs_summary_info *d_si; /* Superblock summary info */
|
||||||
|
union dinodep d_dp; /* pointer to currently active inode */
|
||||||
|
ino_t d_inomin; /* low ino */
|
||||||
|
ino_t d_inomax; /* high ino */
|
||||||
off_t d_sblockloc; /* where to look for the superblock */
|
off_t d_sblockloc; /* where to look for the superblock */
|
||||||
int d_lookupflags; /* flags to superblock lookup */
|
int64_t d_bsize; /* device bsize */
|
||||||
int d_mine; /* internal flags */
|
int64_t d_lookupflags; /* flags to superblock lookup */
|
||||||
#define d_fs d_sbunion.d_fs
|
int64_t d_mine; /* internal flags */
|
||||||
#define d_sb d_sbunion.d_sb
|
int32_t d_ccg; /* current cylinder group */
|
||||||
#define d_cg d_cgunion.d_cg
|
int32_t d_ufs; /* decimal UFS version */
|
||||||
|
int32_t d_fd; /* raw device file descriptor */
|
||||||
|
int32_t d_lcg; /* last cylinder group (in d_cg) */
|
||||||
};
|
};
|
||||||
|
#define d_inos d_inosunion.d_inos
|
||||||
|
#define d_fs d_sbunion.d_fs
|
||||||
|
#define d_cg d_cgunion.d_cg
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* libufs macros (internal, non-exported).
|
* libufs macros (internal, non-exported).
|
||||||
*/
|
*/
|
||||||
#ifdef _LIBUFS
|
#ifdef _LIBUFS
|
||||||
|
/*
|
||||||
|
* Ensure that the buffer is aligned to the I/O subsystem requirements.
|
||||||
|
*/
|
||||||
|
#define BUF_MALLOC(newbufpp, data, size) { \
|
||||||
|
if (data != NULL && (((intptr_t)data) & (LIBUFS_BUFALIGN - 1)) == 0) \
|
||||||
|
*newbufpp = (void *)data; \
|
||||||
|
else \
|
||||||
|
*newbufpp = aligned_alloc(LIBUFS_BUFALIGN, size); \
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Trace steps through libufs, to be used at entry and erroneous return.
|
* Trace steps through libufs, to be used at entry and erroneous return.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -228,7 +228,8 @@ use_pread(void *devfd, off_t loc, void **bufp, int size)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = *(int *)devfd;
|
fd = *(int *)devfd;
|
||||||
if ((*bufp = malloc(size)) == NULL)
|
BUF_MALLOC(bufp, NULL, size);
|
||||||
|
if (*bufp == NULL)
|
||||||
return (ENOSPC);
|
return (ENOSPC);
|
||||||
if (pread(fd, *bufp, size, loc) != size)
|
if (pread(fd, *bufp, size, loc) != size)
|
||||||
return (EIO);
|
return (EIO);
|
||||||
|
|
|
@ -61,10 +61,6 @@ ufs_disk_close(struct uufsd *disk)
|
||||||
ERROR(disk, NULL);
|
ERROR(disk, NULL);
|
||||||
close(disk->d_fd);
|
close(disk->d_fd);
|
||||||
disk->d_fd = -1;
|
disk->d_fd = -1;
|
||||||
if (disk->d_inoblock != NULL) {
|
|
||||||
free(disk->d_inoblock);
|
|
||||||
disk->d_inoblock = NULL;
|
|
||||||
}
|
|
||||||
if (disk->d_mine & MINE_NAME) {
|
if (disk->d_mine & MINE_NAME) {
|
||||||
free((char *)(uintptr_t)disk->d_name);
|
free((char *)(uintptr_t)disk->d_name);
|
||||||
disk->d_name = NULL;
|
disk->d_name = NULL;
|
||||||
|
@ -155,10 +151,16 @@ again: if ((ret = stat(name, &st)) < 0) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (((uintptr_t)disk & ~(LIBUFS_BUFALIGN - 1)) != (uintptr_t)disk) {
|
||||||
|
ERROR(disk, "uufsd structure must be aligned to "
|
||||||
|
"LIBUFS_BUFALIGN byte boundry, see ufs_disk_fillout(3)");
|
||||||
|
close(fd);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
disk->d_bsize = 1;
|
disk->d_bsize = 1;
|
||||||
disk->d_ccg = 0;
|
disk->d_ccg = 0;
|
||||||
disk->d_fd = fd;
|
disk->d_fd = fd;
|
||||||
disk->d_inoblock = NULL;
|
|
||||||
disk->d_inomin = 0;
|
disk->d_inomin = 0;
|
||||||
disk->d_inomax = 0;
|
disk->d_inomax = 0;
|
||||||
disk->d_lcg = 0;
|
disk->d_lcg = 0;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
.\"
|
.\"
|
||||||
.\" This file is in the public domain.
|
.\" This file is in the public domain.
|
||||||
.\"
|
.\"
|
||||||
.Dd June 4, 2003
|
.Dd November 17, 2023
|
||||||
.Dt UFS_DISK_CLOSE 3
|
.Dt UFS_DISK_CLOSE 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -51,6 +51,13 @@ functions open a disk specified by
|
||||||
.Fa name
|
.Fa name
|
||||||
and populate the structure pointed to by
|
and populate the structure pointed to by
|
||||||
.Fa disk .
|
.Fa disk .
|
||||||
|
The structure referenced by the
|
||||||
|
.Fa disk
|
||||||
|
pointer must be aligned to at least the alignment specified by
|
||||||
|
.Dv LIBUFS_ALIGN
|
||||||
|
that is defined in the
|
||||||
|
.Lb libufs.h
|
||||||
|
header file.
|
||||||
The disk is opened read-only.
|
The disk is opened read-only.
|
||||||
The specified
|
The specified
|
||||||
.Fa name
|
.Fa name
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <libufs.h>
|
||||||
|
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
|
@ -424,6 +425,20 @@ Malloc(size_t size)
|
||||||
break;
|
break;
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Allocate a block of memory to be used as an I/O buffer.
|
||||||
|
* Ensure that the buffer is aligned to the I/O subsystem requirements.
|
||||||
|
*/
|
||||||
|
static inline void*
|
||||||
|
Balloc(size_t size)
|
||||||
|
{
|
||||||
|
void *retval;
|
||||||
|
|
||||||
|
while ((retval = aligned_alloc(LIBUFS_BUFALIGN, size)) == NULL)
|
||||||
|
if (flushentry() == 0)
|
||||||
|
break;
|
||||||
|
return (retval);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrapper for calloc() that flushes the cylinder group cache to try
|
* Wrapper for calloc() that flushes the cylinder group cache to try
|
||||||
|
|
|
@ -58,7 +58,6 @@ static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libufs.h>
|
|
||||||
|
|
||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ bufinit(void)
|
||||||
initbarea(&failedbuf, BT_UNKNOWN);
|
initbarea(&failedbuf, BT_UNKNOWN);
|
||||||
failedbuf.b_errs = -1;
|
failedbuf.b_errs = -1;
|
||||||
failedbuf.b_un.b_buf = NULL;
|
failedbuf.b_un.b_buf = NULL;
|
||||||
if ((cgblk.b_un.b_buf = Malloc((unsigned int)sblock.fs_bsize)) == NULL)
|
if ((cgblk.b_un.b_buf = Balloc((unsigned int)sblock.fs_bsize)) == NULL)
|
||||||
errx(EEXIT, "Initial malloc(%d) failed", sblock.fs_bsize);
|
errx(EEXIT, "Initial malloc(%d) failed", sblock.fs_bsize);
|
||||||
initbarea(&cgblk, BT_CYLGRP);
|
initbarea(&cgblk, BT_CYLGRP);
|
||||||
numbufs = cachelookups = cachereads = 0;
|
numbufs = cachelookups = cachereads = 0;
|
||||||
|
@ -211,7 +210,7 @@ allocbuf(const char *failreason)
|
||||||
char *bufp;
|
char *bufp;
|
||||||
|
|
||||||
bp = (struct bufarea *)Malloc(sizeof(struct bufarea));
|
bp = (struct bufarea *)Malloc(sizeof(struct bufarea));
|
||||||
bufp = Malloc((unsigned int)sblock.fs_bsize);
|
bufp = Balloc((unsigned int)sblock.fs_bsize);
|
||||||
if (bp == NULL || bufp == NULL) {
|
if (bp == NULL || bufp == NULL) {
|
||||||
errx(EEXIT, "%s", failreason);
|
errx(EEXIT, "%s", failreason);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
@ -241,7 +240,7 @@ cglookup(int cg)
|
||||||
if ((unsigned) cg >= sblock.fs_ncg)
|
if ((unsigned) cg >= sblock.fs_ncg)
|
||||||
errx(EEXIT, "cglookup: out of range cylinder group %d", cg);
|
errx(EEXIT, "cglookup: out of range cylinder group %d", cg);
|
||||||
if (cgbufs == NULL) {
|
if (cgbufs == NULL) {
|
||||||
cgbufs = calloc(sblock.fs_ncg, sizeof(struct bufarea));
|
cgbufs = Calloc(sblock.fs_ncg, sizeof(struct bufarea));
|
||||||
if (cgbufs == NULL)
|
if (cgbufs == NULL)
|
||||||
errx(EEXIT, "Cannot allocate cylinder group buffers");
|
errx(EEXIT, "Cannot allocate cylinder group buffers");
|
||||||
}
|
}
|
||||||
|
@ -250,7 +249,7 @@ cglookup(int cg)
|
||||||
return (cgbp);
|
return (cgbp);
|
||||||
cgp = NULL;
|
cgp = NULL;
|
||||||
if (flushtries == 0)
|
if (flushtries == 0)
|
||||||
cgp = Malloc((unsigned int)sblock.fs_cgsize);
|
cgp = Balloc((unsigned int)sblock.fs_cgsize);
|
||||||
if (cgp == NULL) {
|
if (cgp == NULL) {
|
||||||
if (sujrecovery)
|
if (sujrecovery)
|
||||||
errx(EEXIT,"Ran out of memory during journal recovery");
|
errx(EEXIT,"Ran out of memory during journal recovery");
|
||||||
|
@ -966,7 +965,7 @@ blzero(int fd, ufs2_daddr_t blk, long size)
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return;
|
return;
|
||||||
if (zero == NULL) {
|
if (zero == NULL) {
|
||||||
zero = calloc(ZEROBUFSIZE, 1);
|
zero = Balloc(ZEROBUFSIZE);
|
||||||
if (zero == NULL)
|
if (zero == NULL)
|
||||||
errx(EEXIT, "cannot allocate buffer pool");
|
errx(EEXIT, "cannot allocate buffer pool");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <libufs.h>
|
|
||||||
|
|
||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
|
|
||||||
|
@ -646,7 +645,7 @@ setinodebuf(int cg, ino_t inosused)
|
||||||
inobufsize = blkroundup(&sblock,
|
inobufsize = blkroundup(&sblock,
|
||||||
MAX(INOBUFSIZE, sblock.fs_bsize));
|
MAX(INOBUFSIZE, sblock.fs_bsize));
|
||||||
initbarea(&inobuf, BT_INODES);
|
initbarea(&inobuf, BT_INODES);
|
||||||
if ((inobuf.b_un.b_buf = Malloc((unsigned)inobufsize)) == NULL)
|
if ((inobuf.b_un.b_buf = Balloc((unsigned)inobufsize)) == NULL)
|
||||||
errx(EEXIT, "cannot allocate space for inode buffer");
|
errx(EEXIT, "cannot allocate space for inode buffer");
|
||||||
}
|
}
|
||||||
fullcnt = inobufsize / ((sblock.fs_magic == FS_UFS1_MAGIC) ?
|
fullcnt = inobufsize / ((sblock.fs_magic == FS_UFS1_MAGIC) ?
|
||||||
|
|
|
@ -59,7 +59,6 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
|
||||||
#include <fstab.h>
|
#include <fstab.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <libufs.h>
|
|
||||||
#include <mntopts.h>
|
#include <mntopts.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -45,7 +45,6 @@ static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libufs.h>
|
|
||||||
|
|
||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libufs.h>
|
|
||||||
|
|
||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
|
|
||||||
|
@ -214,7 +213,7 @@ setup(char *dev)
|
||||||
sbdirty();
|
sbdirty();
|
||||||
}
|
}
|
||||||
if (snapcnt > 0 && copybuf == NULL) {
|
if (snapcnt > 0 && copybuf == NULL) {
|
||||||
copybuf = Malloc(sblock.fs_bsize);
|
copybuf = Balloc(sblock.fs_bsize);
|
||||||
if (copybuf == NULL)
|
if (copybuf == NULL)
|
||||||
errx(EEXIT, "cannot allocate space for snapshot "
|
errx(EEXIT, "cannot allocate space for snapshot "
|
||||||
"copy buffer");
|
"copy buffer");
|
||||||
|
@ -501,7 +500,7 @@ sblock_init(void)
|
||||||
fsmodified = 0;
|
fsmodified = 0;
|
||||||
lfdir = 0;
|
lfdir = 0;
|
||||||
initbarea(&sblk, BT_SUPERBLK);
|
initbarea(&sblk, BT_SUPERBLK);
|
||||||
sblk.b_un.b_buf = Malloc(SBLOCKSIZE);
|
sblk.b_un.b_buf = Balloc(SBLOCKSIZE);
|
||||||
if (sblk.b_un.b_buf == NULL)
|
if (sblk.b_un.b_buf == NULL)
|
||||||
errx(EEXIT, "cannot allocate space for superblock");
|
errx(EEXIT, "cannot allocate space for superblock");
|
||||||
dev_bsize = secsize = DEV_BSIZE;
|
dev_bsize = secsize = DEV_BSIZE;
|
||||||
|
@ -530,7 +529,7 @@ calcsb(char *dev, int devfd, struct fs *fs)
|
||||||
*/
|
*/
|
||||||
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1)
|
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1)
|
||||||
return (0);
|
return (0);
|
||||||
fsrbuf = Malloc(secsize);
|
fsrbuf = Balloc(secsize);
|
||||||
if (fsrbuf == NULL)
|
if (fsrbuf == NULL)
|
||||||
errx(EEXIT, "calcsb: cannot allocate recovery buffer");
|
errx(EEXIT, "calcsb: cannot allocate recovery buffer");
|
||||||
if (blread(devfd, fsrbuf,
|
if (blread(devfd, fsrbuf,
|
||||||
|
@ -573,7 +572,7 @@ chkrecovery(int devfd)
|
||||||
rdsize = sblock.fs_fsize;
|
rdsize = sblock.fs_fsize;
|
||||||
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1 ||
|
if (ioctl(devfd, DIOCGSECTORSIZE, &secsize) == -1 ||
|
||||||
rdsize % secsize != 0 ||
|
rdsize % secsize != 0 ||
|
||||||
(fsrbuf = Malloc(rdsize)) == NULL ||
|
(fsrbuf = Balloc(rdsize)) == NULL ||
|
||||||
blread(devfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
|
blread(devfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
|
||||||
rdsize) != 0) {
|
rdsize) != 0) {
|
||||||
free(fsrbuf);
|
free(fsrbuf);
|
||||||
|
@ -612,7 +611,7 @@ saverecovery(int readfd, int writefd)
|
||||||
if (sblock.fs_magic != FS_UFS2_MAGIC ||
|
if (sblock.fs_magic != FS_UFS2_MAGIC ||
|
||||||
ioctl(readfd, DIOCGSECTORSIZE, &secsize) == -1 ||
|
ioctl(readfd, DIOCGSECTORSIZE, &secsize) == -1 ||
|
||||||
rdsize % secsize != 0 ||
|
rdsize % secsize != 0 ||
|
||||||
(fsrbuf = Malloc(rdsize)) == NULL ||
|
(fsrbuf = Balloc(rdsize)) == NULL ||
|
||||||
blread(readfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
|
blread(readfd, fsrbuf, (SBLOCK_UFS2 - rdsize) / dev_bsize,
|
||||||
rdsize) != 0) {
|
rdsize) != 0) {
|
||||||
printf("RECOVERY DATA COULD NOT BE CREATED\n");
|
printf("RECOVERY DATA COULD NOT BE CREATED\n");
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <libufs.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
|
@ -2274,7 +2273,7 @@ suj_add_block(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, int frags)
|
||||||
static void
|
static void
|
||||||
suj_read(void)
|
suj_read(void)
|
||||||
{
|
{
|
||||||
uint8_t block[1 * 1024 * 1024];
|
uint8_t block[1 * 1024 * 1024] __aligned(LIBUFS_BUFALIGN);
|
||||||
struct suj_seg *seg;
|
struct suj_seg *seg;
|
||||||
struct jsegrec *recn;
|
struct jsegrec *recn;
|
||||||
struct jsegrec *rec;
|
struct jsegrec *rec;
|
||||||
|
|
Loading…
Reference in a new issue