Commit Graph

28 Commits

Author SHA1 Message Date
Xin LI
f89d207279 Separate kernel crc32() implementation to its own header (gsb_crc32.h) and
rename the source to gsb_crc32.c.

This is a prerequisite of unifying kernel zlib instances.

PR:		229763
Submitted by:	Yoshihiro Ota <ota at j.email.ne.jp>
Differential Revision:	https://reviews.freebsd.org/D20193
2019-06-17 19:49:08 +00:00
Kirk McKusick
9fc5d538fc In preparation for adding inode check-hashes, clean up and
document the libufs interface for fetching and storing inodes.
The undocumented getino / putino interface has been replaced
with a new getinode / putinode interface.

Convert the utilities that had been using the undocumented
interface to use the new documented interface.

No functional change (as for now the libufs library does not
do inode check-hashes).

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix
2018-11-13 21:40:56 +00:00
Kirk McKusick
dffce2150e Refactoring of reading and writing of the UFS/FFS superblock.
Specifically reading is done if ffs_sbget() and writing is done
in ffs_sbput(). These functions are exported to libufs via the
sbget() and sbput() functions which then used in the various
filesystem utilities. This work is in preparation for adding
subperblock check hashes.

No functional change intended.

Reviewed by: kib
2018-01-26 00:58:32 +00:00
Kirk McKusick
72f854ce8f Correct fsck journal-recovery code to update a cylinder-group
check-hash after making changes to the cylinder group. The problem
was that the journal-recovery code was calling the libufs bwrite()
function instead of the cgput() function. The cgput() function updates
the cylinder-group check-hash before writing the cylinder group.

This change required the additions of the cgget() and cgput() functions
to the libufs API to avoid a gratuitous bcopy of every cylinder group
to be read or written. These new functions have been added to the
libufs manual pages. This was the first opportunity that I have had
to use and document the use of the EDOOFUS error code.

Reviewed by: kib
Reported by: emaste and others
2018-01-17 17:58:24 +00:00
Kirk McKusick
75e3597abb Continuing efforts to provide hardening of FFS, this change adds a
check hash to cylinder groups. If a check hash fails when a cylinder
group is read, no further allocations are attempted in that cylinder
group until it has been fixed by fsck. This avoids a class of
filesystem panics related to corrupted cylinder group maps. The
hash is done using crc32c.

Check hases are added only to UFS2 and not to UFS1 as UFS1 is primarily
used in embedded systems with small memories and low-powered processors
which need as light-weight a filesystem as possible.

Specifics of the changes:

sys/sys/buf.h:
    Add BX_FSPRIV to reserve a set of eight b_xflags that may be used
    by individual filesystems for their own purpose. Their specific
    definitions are found in the header files for each filesystem
    that uses them. Also add fields to struct buf as noted below.

sys/kern/vfs_bio.c:
    It is only necessary to compute a check hash for a cylinder
    group when it is actually read from disk. When calling bread,
    you do not know whether the buffer was found in the cache or
    read. So a new flag (GB_CKHASH) and a pointer to a function to
    perform the hash has been added to breadn_flags to say that the
    function should be called to calculate a hash if the data has
    been read. The check hash is placed in b_ckhash and the B_CKHASH
    flag is set to indicate that a read was done and a check hash
    calculated. Though a rather elaborate mechanism, it should
    also work for check hashing other metadata in the future. A
    kernel internal API change was to change breada into a static
    fucntion and add flags and a function pointer to a check-hash
    function.

sys/ufs/ffs/fs.h:
    Add flags for types of check hashes; stored in a new word in the
    superblock. Define corresponding BX_ flags for the different types
    of check hashes. Add a check hash word in the cylinder group.

sys/ufs/ffs/ffs_alloc.c:
    In ffs_getcg do the dance with breadn_flags to get a check hash and
    if one is provided, check it.

sys/ufs/ffs/ffs_vfsops.c:
    Copy across the BX_FFSTYPES flags in background writes.
    Update the check hash when writing out buffers that need them.

sys/ufs/ffs/ffs_snapshot.c:
    Recompute check hash when updating snapshot cylinder groups.

sys/libkern/crc32.c:
lib/libufs/Makefile:
lib/libufs/libufs.h:
lib/libufs/cgroup.c:
    Include libkern/crc32.c in libufs and use it to compute check
    hashes when updating cylinder groups.

Four utilities are affected:

sbin/newfs/mkfs.c:
    Add the check hashes when building the cylinder groups.

sbin/fsck_ffs/fsck.h:
sbin/fsck_ffs/fsutil.c:
    Verify and update check hashes when checking and writing cylinder groups.

sbin/fsck_ffs/pass5.c:
    Offer to add check hashes to existing filesystems.
    Precompute check hashes when rebuilding cylinder group
    (although this will be done when it is written in fsutil.c
    it is necessary to do it early before comparing with the old
    cylinder group)

sbin/dumpfs/dumpfs.c
    Print out the new check hash flag(s)

sbin/fsdb/Makefile:
    Needs to add libufs now used by pass5.c imported from fsck_ffs.

Reviewed by: kib
Tested by: Peter Holm (pho)
2017-09-22 12:45:15 +00:00
Enji Cooper
8d8d6de65e Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones
This implifies pathing in make/displayed output

MFC after:    3 weeks
Sponsored by: Dell EMC Isilon
2017-01-20 04:30:05 +00:00
Glen Barber
a70cba9582 First pass through library packaging.
Sponsored by:	The FreeBSD Foundation
2016-02-04 21:16:35 +00:00
Warner Losh
111ff432de Remove the stray DEBUG_FLAGS=-g line that snuck in with the
soft-updates journaling project merge in r207141.
2015-05-21 14:36:11 +00:00
Konstantin Belousov
7596eb4872 Bump shared libraries version numbers in preparation for 9.0.
This time, only libraries which ABI has been changed compared to
stable/8, are bumped.

ABI analysis done by:	Gleb Kurtsou
Approved by:	re (kensmith)
2011-08-28 09:26:48 +00:00
Jeff Roberson
113db2dddb - 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
2010-04-24 07:05:35 +00:00
Warner Losh
3d28af0246 Back to WARNS=3. The breakage wasn't what I thought it was :( 2010-02-11 07:09:04 +00:00
Warner Losh
178a1e6959 Increased warnings weren't tested on ARM. Bump warnings back down to
0 until it can be properly tested by those raising the warnings.
Remember: make universe is required when changing the WARNS level.
2010-02-11 04:45:08 +00:00
Ed Schouten
daaf575910 Build lib/ with WARNS=6 by default.
Similar to libexec/, do the same with lib/. Make WARNS=6 the norm and
lower it when needed.

I'm setting WARNS?=0 for secure/. It seems secure/ includes the
Makefile.inc provided by lib/. I'm not going to touch that directory.
Most of the code there is contributed anyway.
2010-01-02 09:58:07 +00:00
Poul-Henning Kamp
20a0f65b77 Add a berase() function which uses ioctl(DIOCGDELETE) to erase a slab
of the disk.
2007-12-16 18:02:37 +00:00
Pawel Jakub Dawidek
cf4652e74b Implement cgwrite1(3) function which stored a given cylinder group on disk.
Sponsored by:	home.pl
2006-10-31 21:21:48 +00:00
Giorgos Keramidas
727fbe7709 minor style.Makefile(5) fixes:
- WARNS before CFLAGS
- CFLAGS -DXXX before -IXXX

Approved by:	ru
2005-09-26 06:23:43 +00:00
Tom Rhodes
90f8e1e33a Disconnect getino.3 and remove MLINK I added.
Discussed with:	jmallett
2005-08-31 07:44:45 +00:00
Tom Rhodes
849aee62b2 Hook getino.3 up to the build and link it to putino.3.
PR:	83820
2005-08-25 10:22:29 +00:00
David E. O'Brien
4f4a104ee8 style.Makefile(5) 2003-08-18 15:25:39 +00:00
Gordon Tetlow
41d8423f71 Stage 3 of dynamic root support. Make all the libraries needed to run
binaries in /bin and /sbin installed in /lib. Only the versioned files
reside in /lib, the .so symlink continues to live /usr/lib so the
toolchain doesn't need to be modified.
2003-08-17 08:28:46 +00:00
Juli Mallett
e78ea9f724 Commit rudimentary libufs manual pages, except for that for
getino(3)/putino(3), inode.c has been reworked in Perforce to the point
where a manual page may not be accurate.  Certainly putino(3) has not
even been merged back yet.

These will need a lot of improvement for most applications, but they
document the API enough to get someone on their feet, most likely.  The
best documentation still exists in the form of libufs(3) consumers in the
base system.
2003-06-09 09:59:11 +00:00
Juli Mallett
9e8f2a17ec WARNS ?= 2, so idiocy like 1.12 of type.c doesn't have to happen again. 2003-01-30 00:11:01 +00:00
Juli Mallett
22ec2ef3bb Add facility to read one, or a string of, cylinger groups. 2003-01-19 01:31:26 +00:00
Juli Mallett
49b2a6863b 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.
2003-01-18 04:22:14 +00:00
Juli Mallett
8b8cd35523 Add the concept of a per-disk error string, and a function which prints it
along with the errno, if one is set.
2002-10-22 19:25:58 +00:00
Ruslan Ermilov
93c163325e No need to explicitly set NOMAN here.
Reviewed by:	jmallett
2002-07-03 06:25:28 +00:00
Juli Mallett
a7a88ab828 DEBUG is a knob that means something else in FreeBSD, use LIBUFS_DEBUG to
turn on tracing.
2002-07-01 18:20:48 +00:00
Juli Mallett
20938dbf84 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.
2002-07-01 01:45:03 +00:00