mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-28 03:42:04 +01:00
772430dd67
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
121 lines
2.6 KiB
Groff
121 lines
2.6 KiB
Groff
.\" Author: Juli Mallett <jmallett@FreeBSD.org>
|
|
.\" Date: June 04, 2003
|
|
.\" Description:
|
|
.\" Manual page for libufs functions:
|
|
.\" ufs_disk_close(3)
|
|
.\" ufs_disk_fillout(3)
|
|
.\" ufs_disk_fillout_blank(3)
|
|
.\" ufs_disk_write(3)
|
|
.\"
|
|
.\" This file is in the public domain.
|
|
.\"
|
|
.Dd November 17, 2023
|
|
.Dt UFS_DISK_CLOSE 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm ufs_disk_close ,
|
|
.Nm ufs_disk_fillout ,
|
|
.Nm ufs_disk_fillout_blank ,
|
|
.Nm ufs_disk_write
|
|
.Nd open and close userland UFS disks
|
|
.Sh LIBRARY
|
|
.Lb libufs
|
|
.Sh SYNOPSIS
|
|
.In sys/param.h
|
|
.In sys/mount.h
|
|
.In ufs/ufs/ufsmount.h
|
|
.In ufs/ufs/dinode.h
|
|
.In ufs/ffs/fs.h
|
|
.In libufs.h
|
|
.Ft int
|
|
.Fn ufs_disk_close "struct uufsd *disk"
|
|
.Ft int
|
|
.Fn ufs_disk_fillout "struct uufsd *disk" "const char *name"
|
|
.Ft int
|
|
.Fn ufs_disk_fillout_blank "struct uufsd *disk" "const char *name"
|
|
.Ft int
|
|
.Fn ufs_disk_write "struct uufsd *disk"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn ufs_disk_close
|
|
function closes a disk and frees internal memory related to it.
|
|
It does not free the
|
|
.Fa disk
|
|
structure.
|
|
.Pp
|
|
The
|
|
.Fn ufs_disk_fillout
|
|
and
|
|
.Fn ufs_disk_fillout_blank
|
|
functions open a disk specified by
|
|
.Fa name
|
|
and populate the structure pointed to by
|
|
.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 specified
|
|
.Fa name
|
|
may be either a mountpoint, a device name or a filesystem image.
|
|
The
|
|
.Fn ufs_disk_fillout
|
|
function assumes there is a valid superblock and will fail if not,
|
|
whereas the
|
|
.Fn ufs_disk_fillout_blank
|
|
function makes no assumptions of that sort.
|
|
.Pp
|
|
The
|
|
.Fn ufs_disk_write
|
|
function attempts to re-open a disk as writable if it is not currently.
|
|
.Sh ERRORS
|
|
The function
|
|
.Fn ufs_disk_close
|
|
has no failure points.
|
|
.Pp
|
|
The function
|
|
.Fn ufs_disk_fillout
|
|
may fail for any of the reasons
|
|
.Fn ufs_disk_fillout_blank
|
|
might, as well as for any reason
|
|
.Xr sbread 3
|
|
might.
|
|
.Pp
|
|
The
|
|
.Fn ufs_disk_fillout_blank
|
|
may fail and set
|
|
.Va errno
|
|
for any of the errors specified for the library functions
|
|
.Xr open 2 ,
|
|
.Xr strdup 3 .
|
|
Additionally, it may follow the
|
|
.Xr libufs 3
|
|
error methodologies in situations where no device could be found to
|
|
open.
|
|
.Pp
|
|
The function
|
|
.Fn ufs_disk_write
|
|
may fail and set
|
|
.Va errno
|
|
for any of the errors specified for the library functions
|
|
.Xr open 2
|
|
and
|
|
.Xr stat 2 .
|
|
Namely, it will fail if the disk in question may not be written to.
|
|
.Sh SEE ALSO
|
|
.Xr open 2 ,
|
|
.Xr getfsfile 3 ,
|
|
.Xr libufs 3 ,
|
|
.Xr sbread 3
|
|
.Sh HISTORY
|
|
These functions first appeared as part of
|
|
.Xr libufs 3
|
|
in
|
|
.Fx 5.0 .
|
|
.Sh AUTHORS
|
|
.An Juli Mallett Aq Mt jmallett@FreeBSD.org
|