History log of /freebsd-current/lib/libufs/type.c
Revision Date Author Comments
# a2f733ab 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

lib: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 772430dd 17-Nov-2023 Kirk McKusick <mckusick@FreeBSD.org>

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# b21582ee 30-Jul-2022 Kirk McKusick <mckusick@FreeBSD.org>

Add a flags parameter to the ffs_sbget() function that reads UFS superblocks.

Rather than trying to shoehorn flags into the requested superblock
address, create a separate flags parameter to the ffs_sbget()
function in sys/ufs/ffs/ffs_subr.c. The ffs_sbget() function is
used both in the kernel and in user-level utilities through export
to the sbget() function in the libufs(3) library (see sbget(3)
for details). The kernel uses ffs_sbget() when mounting UFS
filesystems, in the glabel(8) and gjournal(8) GEOM utilities,
and in the standalone library used when booting the system
from a UFS root filesystem.

The ffs_sbget() function reads the superblock located at the byte
offset specified by its sblockloc parameter. The value UFS_STDSB
may be specified for sblockloc to request that the standard
location for the superblock be read.

The two existing options are now flags:

UFS_NOHASHFAIL will note if the check hash is wrong but will still
return the superblock. This is used by the bootstrap code to
give the system a chance to come up so that fsck can be run to
correct the problem.

UFS_NOMSG indicates that superblock inconsistency error messages
should not be printed. It is used by programs like fsck that
want to print their own error message and programs like glabel(8)
that just want to know if a UFS filesystem exists on a partition.

One additional flag is added:

UFS_NOCSUM causes only the superblock itself to be returned, but does
not read in any auxiliary data structures like the cylinder group
summary information. It is used by clients like glabel(8) that
just want to check for possible filesystem types. Using UFS_NOCSUM
skips the superblock checks for csum data which allows superblocks
that have corrupted csum data to be read and used.

The validate_sblock() function checks that the superblock has not
been corrupted in a way that can crash or hang the system. Unless
the UFS_NOMSG flag is specified, it will print out any errors that
it finds. Prior to this commit, validate_sblock() returned as soon
as it found an inconsistency so would print at most one message.
It now does all its checks so when UFS_NOMSG has not been specified
will print out everything that it finds inconsistent.

Sponsored by: The FreeBSD Foundation


# 82e72f1d 24-Jul-2022 Kirk McKusick <mckusick@FreeBSD.org>

Add d_sblockloc to libufs(3) disk structure to allow options to be added.

By making the disk block parameter used by the libufs(3) sbread(3)
function visible, applications using sbread(3) can set their own
addition options such as using the STDSB_NOHASHFAIL request to
say that they want the superblock read to succeed even when
the superblock checkhash is incorrect.

While here also add an error message when a check-hash failure
is detected.


# d485c77f 18-Feb-2021 Konstantin Belousov <kib@FreeBSD.org>

Remove #define _KERNEL hacks from libprocstat

Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in
userspace, assuming that the consumer has an idea what it is for.
Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h,
sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the
same caveat.

Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h
being unusable in userspace, where it override struct buf with its own
definition. Instead, provide struct m_buf and struct m_vnode and adapt
code to use local variants.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D28679


# 92c839a1 23-Jun-2020 Kirk McKusick <mckusick@FreeBSD.org>

The libufs library needs to track and free the new fs_si structure
in addition to the fs_csp structure that it references.

PR: 247425
Sponsored by: Netflix


# 5613df4f 08-Apr-2018 Kirk McKusick <mckusick@FreeBSD.org>

The ufs_disk_write() function is used to upgrade a read-only descriptor
to a read-write descriptor. Do not close the read-only descriptor until
the read-write is successfully obtained. Before this fix, a failed upgrade
left no usable descriptor with which to work.


# 6a3fe713 26-Dec-2017 Kirk McKusick <mckusick@FreeBSD.org>

Missing disk close in libufs.


# 5e53a4f9 25-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

lib: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 113db2dd 24-Apr-2010 Jeff Roberson <jeff@FreeBSD.org>

- Merge soft-updates journaling from projects/suj/head into head. This
brings in support for an optional intent log which eliminates the need
for background fsck on unclean shutdown.

Sponsored by: iXsystems, Yahoo!, and Juniper.
With help from: McKusick and Peter Holm


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 990b6d05 11-Jun-2009 Juli Mallett <jmallett@FreeBSD.org>

Allow libufs(3) functions to operate on a regular file. This makes it possible to
use almost anything that uses libufs(3) against a file as an unprivileged user, e.g.
tunefs(8) and dumpfs(8) against a makefs(8)-created image.

Prodded by: kensmith


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# fa1abc31 15-Mar-2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>

The ufs_disk_fillout(3) can take special device name (with or without /dev/
prefix) as an argument and mount point path. At the end it has to find
device name file system is stored on, which means when mount point path is
given, it tries to look into /etc/fstab and find special device
corresponding to the given mount point. This is not perfect, because it
doesn't handle the case when file system is mounted by hand and mount point
is given as an argument.

I found this problem while trying to use snapinfo(8), which passes mount
points to the ufs_disk_fillout(3) function, but I had file system mounted
manually, so snapinfo(8) was exiting with the error below:

ufs_disk_fillout: No such file or directory

I modified libufs(3) to handle those arguments (the order is important):

1. special device with /dev/ prefix
2. special device without /dev/ prefix
3. mount point listed in /etc/fstab, directory exists
4. mount point listed in /etc/fstab, directory doesn't exist
5. mount point of a file system mounted by hand


# b52f85e7 09-Jun-2003 Juli Mallett <jmallett@FreeBSD.org>

Remove ufs_disk_ctor and ufs_disk_dtor, they never came to fruition. I do
not know of any software using them, and there is no "published API" for
libufs, as it were.


# 1081253f 09-Jun-2003 Juli Mallett <jmallett@FreeBSD.org>

Reduce diffs with code in Perforce:
Parenthesise return values.


# 7a51271b 27-Mar-2003 Juli Mallett <jmallett@FreeBSD.org>

Close the disk file descriptor that is RO before trying to open the
new one, and do not fall back to the RO fd. There was a bug here
in that the RO fd was never closed, if the RDRW open succeeded, but
this code is bogus anyway, and it breaks newfs of floppies, at least
for me, due to "Device busy." Anything that wants to fall back is
doing something significantly odd that it should have some more complex
code on its end.


# 9e4789cc 29-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

Missing "return 0"

Big pointy hat to: jmallett
Spotted by: peter


# 7dc95357 29-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

API for opening (and tracking) writable file descriptors per disk.


# d934deef 23-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

API to fillout a blank disk. For e.g. newfs.


# cc3dd528 18-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

Store not only the current cylinder group in the series (i.e. next that needs
to be read in) but also the last cylinder group in the series (i.e. what is
stored in the structure).


# 22ec2ef3 18-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

Add facility to read one, or a string of, cylinger groups.


# 65612858 18-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

Hunt for a disk to operate on, if we're passed a partition mountpoint, etc.

Concept reviewed by: phk


# 49b2a686 17-Jan-2003 Juli Mallett <jmallett@FreeBSD.org>

Nuke dumb error reporting code, people can just use disk::d_error. Unify the
DEBUG and d_error initialisation into an ERROR macro, which can both trace and
set the d_error field. Much a more meaningful thing, I should say.


# 8b8cd355 22-Oct-2002 Juli Mallett <jmallett@FreeBSD.org>

Add the concept of a per-disk error string, and a function which prints it
along with the errno, if one is set.


# e079a00a 11-Aug-2002 Juli Mallett <jmallett@FreeBSD.org>

Initialise disk->d_ufs so that in sblock.c it's always initialised
(unless someone tries to use libufs support functions without using
_fillout or _ctor to construct a uufsd.)

Obtained from: jmallett_libufs Perforce branch.


# cf6c0643 11-Jul-2002 Juli Mallett <jmallett@FreeBSD.org>

Fill out (zero) and fill in (when doing getino()) the minimum and maximum
inodes in our inoblock (disk->d_ino{min,max}) appropriately.


# 585e5402 01-Jul-2002 Juli Mallett <jmallett@FreeBSD.org>

In getino, have our DEBUG message in the unhandled case mention that it
does not know what sort of UFS filesystem this is.

Add some DEBUG(NULL)'s to function entry points.


# 20938dbf 30-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Add libufs, a library for dealing with UFS filesystems from userland to
the build. It is here to compartmentalise functionality currently duplicated
in many notable programs in the base system. It currently handles block
reads and writes, as well as reading and writing of the filesystem superblock,
and the reading/lookup of inode data. It supports both UFS and UFS2. I
will be maintaining it, and porting programs to use it, however for now, it
is simply being built as part of world.