Home | History | Annotate | Download | only in lfs
History log of /src/sys/ufs/lfs/lfs_rfw.c
RevisionDateAuthorComments
 1.39  14-Oct-2025  perseant Check the existing inode address against LFS_UNUSED_DADDR before checking
whether it is in the same segment, to prevent a byte undercount in segment 0
during roll forward. This was most often expressed in the fs/lfs/t_rfw rfw64
test case, though it affected both 32- and 64-bit LFSs equally.
 1.38  06-Oct-2025  perseant Don't stop recovery when we find a partial-segment with neither inodes nor
finfos. Under normal conditions, we should never be producing such a partial
segment. However, these do sometimes appear and they need not prevent us
from continuing.
 1.37  17-Sep-2025  perseant Add working in-kernel roll forward.
 1.36  05-Sep-2020  riastradh Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.35  17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.34  01-Jan-2019  hannken branches: 1.34.6;
Add "void *extra" argument to vcache_new() so a file system may
pass more information about the file to create.

Welcome to 8.99.30
 1.33  10-Dec-2018  maxv Remove unused mbuf.h includes.
 1.32  03-Oct-2015  dholland branches: 1.32.16; 1.32.18;
Use the new IINFO in the rfw code, eliminating hardwired 32-bit values.
 1.31  01-Sep-2015  dholland Use the lfs dinode accessors in place of the ufs-derived ones.
(Mostly.)

The ufs-derived ones are fake structure member macros, which are gross
and not very safe. Also, it seems that a lot of places in the lfs code
were using the ffsv1 branch of them unconditionally, and this way it's
guaranteed all those places have been updated.

Found while doing this: for non-devices, have getattr produce NODEV
in the rdev field instead of leaking the address of the first direct
block.
 1.30  19-Aug-2015  dholland Part two of dinodes; use the same union everywhere.
(previously the ufs-derived code had things set up slightly different)

Remove a bunch of associated mess.
 1.29  12-Aug-2015  dholland Hack up dinode usage to be 64 vs. 32 as needed. Part 1.

(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
 1.28  12-Aug-2015  dholland Provide 32-bit and 64-bit versions of FINFO.

This also entailed sorting out part of struct segment, as that
contains a pointer into the current FINFO data.
 1.27  12-Aug-2015  dholland Make 32-bit and 64-bit versions of SEGSUM.
Also fix some of the FINFO handling as it's closely entangled.
 1.26  12-Aug-2015  dholland Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
 1.25  02-Aug-2015  dholland Use accessor functions for the version field of the lfs superblock.
I thought at first maybe the cases that test the version should be
rolled into the accessors, but on the whole I think the conclusion on
that is no.
 1.24  28-Jul-2015  dholland Add a new lfs header file: lfs_accessors.h.

This contains all the accessor functions and macros out of lfs.h.
Add an include of lfs_accessors.h after all uses of lfs.h... except
for code that wants to define its own struct lfs-alike that the
accessors are supposed to play along with. For these, set STRUCT_LFS
and include lfs_accessors.h after the necessary structure has been
defined, so that lfs_accessors.h can emit functions in terms of it.
 1.23  24-Jul-2015  dholland More lfs superblock accessors.
(This changes the rest of the code over; all the accessors were
already added.)

The difference between this commit and the previous one is arbitrary,
but the previous one passed the regression tests on its own so I'm
keeping it separate to help with any bisections that might be needed
in the future.
 1.22  24-Jul-2015  dholland Switch to accessor functions for elements of the LFS on-disk
superblock. This will allow switching between 32/64 bit forms on the
fly; it will also allow handling LFS_EI reasonably tidily. (That
currently doesn't work on the superblock.)

It also gets rid of cpp abuse in the form of fake structure member
macros.

Also, instead of doing sleep/wakeup on &lfs_avail and &lfs_nextseg
inside the on-disk superblock, add extra elements to the in-memory
struct lfs for this. (XXX: these should be changed to condvars, but
not right now)

XXX: this migrates a structure needed by the lfs code in libsa (struct
salfs) into lfs.h, where it doesn't belong, but for the time being
this is necessary in order to allow the accessors (and the various
lfs macros and other goop that relies on them) to compile.
 1.21  16-Jul-2015  dholland Don't cast the return value of malloc.
 1.20  31-May-2015  hannken Change lfs from hash table to vcache.

- Change lfs_valloc() to return an inode number and version instead of
a vnode and move lfs_ialloc() and lfs_vcreate() to new lfs_init_vnode().

- Add lfs_valloc_fixed() to allocate a known inode, used by kernel
roll forward.

- Remove lfs_*ref(), these functions cannot coexist with vcache and
their commented behaviour is far away from their implementation.

- Add the cleaner lwp and blockinfo to struct ulfsmount so lfs_loadvnode()
may use hints from the cleaner.

- Remove vnode locks from ulfs_lookup() like we did with ufs_lookup().
 1.19  28-Mar-2015  maxv Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
 1.18  28-Jul-2013  dholland branches: 1.18.6;
Add lfs_kernel.h for declarations that don't need to be exposed to userland.

lfs currently has the following headers:
lfs.h - on-disk structures and stuff needed for userlevel tools
lfs_inode.h - additional restricted materials for userlevel tools
that operate the fs (newfs_lfs, fsck_lfs, lfs_cleanerd)
lfs_kernel.h - stuff needed only in the kernel

and the following legacy headers that are expected to be mopped up and
folded into one of the above:
lfs_extern.h - function prototypes
ulfs_bswap.h - endian-independent support
ulfs_dinode.h - now contains very little
ulfs_dirhash.h - dirhash support
ulfs_extattr.h - extattr support
ulfs_extern.h - more function prototypes
ulfs_inode.h - assorted kernel-only declarations
ulfs_quota.h - quota support
ulfs_quota1.h - more quota support
ulfs_quota2.h - more quota support
ulfs_quotacommon.h - more quota support
ulfsmount.h - legacy copy of ufsmount material
 1.17  18-Jun-2013  christos branches: 1.17.2;
Prefix most of the cpp macros with lfs_ and LFS_ to avoid conflicts with ffs.
This was done so that boot blocks that want to compile both FFS and LFS in
the same file work.
 1.16  08-Jun-2013  dholland Stick LFS_ in front of IFMT, IFIFO, IFREG, etc. so as not to conflict
with the UFS copies of these symbols. (Which themselves ought to have
UFS_ stuck on.)
 1.15  06-Jun-2013  dholland Split lfs from ufs step 4:

Massedit all ufs symbols to be "ulfs" instead, to make sure there are
no conflicts with ufs. Confirmed with grep.

(This required changing a few comments that maybe should have been
left alone to say "ulfs", but we'll survive that.)
 1.14  06-Jun-2013  dholland Split lfs from ufs, part 2:

Change all <ufs/ufs/foo.h> includes to <ufs/lfs/ulfs_foo.h>.
 1.13  22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.12  22-Feb-2009  ad branches: 1.12.12; 1.12.22;
PR kern/26878 FFSv2 + softdep = livelock (no free ram)
PR kern/16942 panic with softdep and quotas
PR kern/19565 panic: softdep_write_inodeblock: indirect pointer #1 mismatch
PR kern/26274 softdep panic: allocdirect_merge: ...
PR kern/26374 Long delay before non-root users can write to softdep partitions
PR kern/28621 1.6.x "vp != NULL" panic in ffs_softdep.c:4653 while unmounting a softdep (+quota) filesystem
PR kern/29513 FFS+Softdep panic with unfsck-able file-corruption
PR kern/31544 The ffs softdep code appears to fail to write dirty bits to disk
PR kern/31981 stopping scsi disk can cause panic (softdep)
PR kern/32116 kernel panic in softdep (assertion failure)
PR kern/32532 softdep_trackbufs deadlock
PR kern/37191 softdep: locking against myself
PR kern/40474 Kernel panic after remounting raid root with softdep

Retire softdep, pass 2. As discussed and later formally announced on the
mailing lists.
 1.11  16-May-2008  hannken branches: 1.11.6; 1.11.12;
Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.10  28-Apr-2008  martin branches: 1.10.2;
Remove clause 3 and 4 from TNF licenses
 1.9  02-Jan-2008  ad branches: 1.9.6; 1.9.8; 1.9.10;
Merge vmlocking2 to head.
 1.8  12-Dec-2007  he Make this build again, as part of sys/lkm/dev/vnd/:
- lfs_truncate() has lost its lwp argument.
- Cast from void* to char* before doing pointer arithmetic.
 1.7  12-Dec-2007  ad Fix a stray brelse() that got missed.
 1.6  12-Dec-2007  lukem defflag LFS_KERNEL_RFW (in opt_lfs.h).
Note: lfs_rfw.c doesn't compile if you define the option; locking API fallout?
 1.5  10-Oct-2007  ad branches: 1.5.4; 1.5.6; 1.5.8; 1.5.10;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.4  08-Oct-2007  ad Merge ffs locking & brelse changes from the vmlocking branch.
 1.3  01-Sep-2006  perseant branches: 1.3.4; 1.3.10; 1.3.16; 1.3.30; 1.3.32; 1.3.34;
Changes to help the roll-forward agent, to wit:

* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().

Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
 1.2  20-Jul-2006  perseant branches: 1.2.4;
Oops, commit the correct version of lfs_rfw.c. The roll-forward functionality
is known not to work in this version (as it did not previously) but it should
at least compile.
 1.1  20-Jul-2006  perseant Separate the (non-working) LFS kernel roll-forward code into its own file,
lfs_rfw.c.
 1.2.4.3  03-Sep-2006  yamt sync with head.
 1.2.4.2  11-Aug-2006  yamt sync with head
 1.2.4.1  20-Jul-2006  yamt file lfs_rfw.c was added on branch yamt-pdpolicy on 2006-08-11 15:47:37 +0000
 1.3.34.1  14-Oct-2007  yamt sync with head.
 1.3.32.2  09-Jan-2008  matt sync with HEAD
 1.3.32.1  06-Nov-2007  matt sync with HEAD
 1.3.30.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.16.3  24-Aug-2007  ad Sync with buffer cache locking changes. See buf.h/vfs_bio.c for details.
Some minor portions are incomplete and needs to be verified as a whole.
 1.3.16.2  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.3.16.1  13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.3.10.4  21-Jan-2008  yamt sync with head
 1.3.10.3  27-Oct-2007  yamt sync with head.
 1.3.10.2  30-Dec-2006  yamt sync with head.
 1.3.10.1  01-Sep-2006  yamt file lfs_rfw.c was added on branch yamt-lazymbuf on 2006-12-30 20:51:01 +0000
 1.3.4.2  09-Sep-2006  rpaulo sync with head
 1.3.4.1  01-Sep-2006  rpaulo file lfs_rfw.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 03:00:00 +0000
 1.5.10.2  02-Jan-2008  bouyer Sync with HEAD
 1.5.10.1  13-Dec-2007  bouyer Sync with HEAD
 1.5.8.1  13-Dec-2007  yamt sync with head.
 1.5.6.5  28-Dec-2007  ad Make it compile.
 1.5.6.4  26-Dec-2007  ad Sync with head.
 1.5.6.3  19-Dec-2007  ad Use a global lfs_lock.
 1.5.6.2  19-Dec-2007  ad Fix some more problems w/lfs on this branch.
 1.5.6.1  04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.5.4.1  18-Feb-2008  mjf Sync with HEAD.
 1.9.10.2  04-May-2009  yamt sync with head.
 1.9.10.1  16-May-2008  yamt sync with head.
 1.9.8.1  18-May-2008  yamt sync with head.
 1.9.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.10.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.12.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.6.1  03-Mar-2009  skrll Sync with HEAD.
 1.12.22.4  03-Dec-2017  jdolecek update from HEAD
 1.12.22.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.22.2  23-Jun-2013  tls resync from head
 1.12.22.1  25-Feb-2013  tls resync with head
 1.12.12.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.12.1  23-Jan-2013  yamt sync with head
 1.17.2.1  28-Aug-2013  rmind sync with head
 1.18.6.4  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.18.6.3  22-Sep-2015  skrll Sync with HEAD
 1.18.6.2  06-Jun-2015  skrll Sync with HEAD
 1.18.6.1  06-Apr-2015  skrll Sync with HEAD
 1.32.18.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.18.1  10-Jun-2019  christos Sync with HEAD
 1.32.16.2  18-Jan-2019  pgoyette Synch with HEAD
 1.32.16.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.34.6.1  17-Jan-2020  ad Sync with head.

RSS XML Feed