Home | History | Annotate | Download | only in ext2fs
History log of /src/sys/ufs/ext2fs/ext2fs_balloc.c
RevisionDateAuthorComments
 1.43  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.42  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.41  13-Aug-2016  christos branches: 1.41.14; 1.41.16;
KNF, no functional changes...
 1.40  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.39  23-Jun-2013  dholland branches: 1.39.10;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.38  23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.37  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.36  20-Dec-2012  hannken Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
 1.35  21-Nov-2012  jakllsch Write support for the Ext4 Read-only Compatible Feature "huge_file".

Primarily, this feature extends the inode block count field to 48 bits.
Additionally, this feature allows this field to be represented in file
system block size units rather than DEV_BSIZE units.
 1.34  19-Oct-2009  bouyer branches: 1.34.12; 1.34.22;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.33  16-May-2008  hannken 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.32  08-Oct-2007  ad branches: 1.32.18; 1.32.20; 1.32.22; 1.32.24;
Merge ffs locking & brelse changes from the vmlocking branch.
 1.31  16-Nov-2006  christos branches: 1.31.8; 1.31.22; 1.31.24; 1.31.26;
__unused removal on arguments; approved by core.
 1.30  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.29  14-May-2006  elad branches: 1.29.8; 1.29.10;
integrate kauth.
 1.28  11-Dec-2005  christos branches: 1.28.4; 1.28.6; 1.28.8; 1.28.10; 1.28.12;
merge ktrace-lwp.
 1.27  02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.26  30-Aug-2005  xtraeme branches: 1.26.2;
* Remove __P()
* Use ANSI function declarations on ext2fs and mfs
 1.25  26-Feb-2005  perry branches: 1.25.4;
nuke trailing whitespace
 1.24  14-Feb-2005  chs fix typoe in previous.
 1.23  09-Feb-2005  ws Add support for large files (>2GB).
Like Linux, automagically convert old filesystem to use this,
if they are already at revision 1.
For revision 0, just punt (unlike Linux; makes me a bit too nervous.)

There should be an option to fsck_ext2fs to upgrade revision 0 to revision 1.

Reviewd by Manuel (bouyer@).
 1.22  22-Mar-2004  bouyer branches: 1.22.8; 1.22.10;
Fix disclaimer in my copyright. Pointed out by Thomas Klausner.
 1.21  05-Oct-2003  bouyer Remove references to University of California from my copyright notices.
 1.20  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19  24-Jan-2003  fvdl branches: 1.19.2;
Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.18  26-Sep-2002  jdolecek use ufs_balloc_range() rather than local (mostly identical, but with some
bugs) ext2fs variant
 1.17  05-May-2002  chs use the correct size when zeroing an array.
 1.16  26-Jan-2002  chs fix an error case.
 1.15  30-Nov-2001  chs pick up changes from ufs_balloc_range().
 1.14  10-Nov-2001  chs track some changes in the ufs code:
update UVM's notion of the file size in *_write() rather than
*_balloc().
 1.13  08-Nov-2001  lukem add RCSID
 1.12  26-Oct-2001  lukem remove #include <ufs/ufs/quota.h> where it was just to appease
<ufs/ufs/inode.h>, since the latter now includes the former. leave the former
in source that obviously uses specific bits of it (for completeness.)
 1.11  15-Sep-2001  chs branches: 1.11.2;
a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
 1.10  04-Jul-2001  chs branches: 1.10.2; 1.10.4;
in ext2fs_balloc_range(), clear PG_RDONLY on pages which now have backing store.
 1.9  30-May-2001  mrg use _KERNEL_OPT
 1.8  10-Dec-2000  chs branches: 1.8.2;
redo ext2fs_balloc_range(), accounting for differences between ext2fs and ffs.
 1.7  27-Nov-2000  chs Initial integration of the Unified Buffer Cache project.
 1.6  28-Jun-2000  mrg remove include of <vm/vm.h> and <uvm/uvm_extern.h>
 1.5  28-May-2000  mycroft Pull in indirect block unwind code from FFS.
 1.4  30-Mar-2000  augustss branches: 1.4.2;
Remove register declarations.
 1.3  01-Mar-1998  fvdl branches: 1.3.10; 1.3.14; 1.3.20;
Merge with Lite2 + local changes
 1.2  09-Oct-1997  bouyer Add byte-swapping functions (bswap16, bswap32, bswap64) to libkern.
Only assembly version for i386 bswap16 and bswap32 for now (bswap64 uses
bswap32). Contribution of assembly versions of these are welcome.
Add byte-swapping of ext2fs metadata for big-endian systems.
Tested on i386 and sparc.
 1.1  11-Jun-1997  bouyer branches: 1.1.4;
The ext2fs layer, based on the ffs/ufs one. Uses a few functions from
sys/ufs/ufs/
 1.1.4.1  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.20.1  21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.3.14.3  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.3.14.2  08-Dec-2000  bouyer Sync with HEAD.
 1.3.14.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.10.1  06-Aug-1999  chs UBCify.
 1.4.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.8  18-Oct-2002  nathanw Catch up to -current.
 1.8.2.7  20-Jun-2002  nathanw Catch up to -current.
 1.8.2.6  28-Feb-2002  nathanw Catch up to -current.
 1.8.2.5  08-Jan-2002  nathanw Catch up to -current.
 1.8.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.8.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.8.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.8.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.10.4.1  01-Oct-2001  fvdl Catch up with -current.
 1.10.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.2  11-Feb-2002  jdolecek Sync w/ -current.
 1.10.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.19.2.6  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.5  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.4  15-Feb-2005  skrll Sync with HEAD.
 1.19.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1  03-Aug-2004  skrll Sync with HEAD
 1.22.10.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.10.1  12-Feb-2005  yamt sync with head.
 1.22.8.1  29-Apr-2005  kent sync with -current
 1.25.4.3  27-Oct-2007  yamt sync with head.
 1.25.4.2  30-Dec-2006  yamt sync with head.
 1.25.4.1  21-Jun-2006  yamt sync with head.
 1.26.2.1  20-Oct-2005  yamt adapt ufs.
 1.28.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.10.2  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.28.10.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.28.8.1  24-May-2006  yamt sync with head.
 1.28.6.1  01-Jun-2006  kardel Sync with head.
 1.28.4.1  09-Sep-2006  rpaulo sync with head
 1.29.10.2  10-Dec-2006  yamt sync with head.
 1.29.10.1  22-Oct-2006  yamt sync with head
 1.29.8.1  18-Nov-2006  ad Sync with head.
 1.31.26.1  14-Oct-2007  yamt sync with head.
 1.31.24.1  06-Nov-2007  matt sync with HEAD
 1.31.22.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.31.8.2  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.31.8.1  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.32.24.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.32.22.2  11-Mar-2010  yamt sync with head
 1.32.22.1  04-May-2009  yamt sync with head.
 1.32.20.1  18-May-2008  yamt sync with head.
 1.32.18.1  02-Jun-2008  mjf Sync with HEAD.
 1.34.22.3  03-Dec-2017  jdolecek update from HEAD
 1.34.22.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.22.1  25-Feb-2013  tls resync with head
 1.34.12.3  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.34.12.2  23-Jan-2013  yamt sync with head
 1.34.12.1  16-Jan-2013  yamt sync with (a bit old) head
 1.39.10.2  05-Oct-2016  skrll Sync with HEAD
 1.39.10.1  06-Apr-2015  skrll Sync with HEAD
 1.41.16.1  10-Jun-2019  christos Sync with HEAD
 1.41.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)

RSS XML Feed