Commit Graph

145 Commits

Author SHA1 Message Date
perseant 2f695b5476 Provide a resize_lfs(8), including kernel and cleaner support. The current
implementation requires the fs to be mounted while resizing.  Tested in both
directions, and everything appears to work happily, but ymmv.
2005-04-23 19:47:51 +00:00
xtraeme dc7d7d7780 Add missing flags to usage() 2005-03-30 21:28:30 +00:00
perseant 6e52bfc264 Various minor LFS improvements:
* Adapt lfs_cleanerd to use the fcntl call to get the Ifile filehandle,
  so it need not be in the namespace.
* Make lfs_cleanerd be more careful when there are very few available
  segments.
* Remove the Ifile from the filesystem namespace.  The cleaner now uses
  a fcntl call on the root inode to find the Ifile filehandle.
* Make lfs_cleanerd less verbose when the filesystem is unmounted.
2005-02-26 05:43:04 +00:00
christos 6bd1d6d4db Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
2004-04-21 01:05:31 +00:00
yamt e2e9c6ef96 fix debug output. 2003-12-17 09:13:41 +00:00
itojun 4698292ea9 realloc pedannt 2003-09-19 05:52:48 +00:00
itojun ba0ee95e6c realloc pedant 2003-09-19 05:50:41 +00:00
agc 8e6ab8837d Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22284, verified by myself.
2003-08-07 09:46:37 +00:00
itojun 6e7ade5e3e use bounded string ops. check malloc failure. asprintf is easier than
complicated strcat/strcpy combination.
2003-07-13 09:44:02 +00:00
fvdl 42614ed3f3 Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
2003-04-02 10:39:19 +00:00
perseant 5646727e5a Let the cleaner use LFCNRECLAIM to help empty segments along, if it
thinks it needs to clean and segments are tantalizingly lingering
in the "empty but dirty" state.
2003-03-02 04:38:20 +00:00
perseant 6f5626d112 Make fs-specific fcntl macros take three arguments (approved wrstuden).
Let LFS use fcntl for cleaner functions.
2003-02-25 23:12:06 +00:00
perseant d5bdd23d68 Convert lfs_cleanerd over to use the new ioctl calls instead of the
lfs syscalls.
2003-02-24 08:48:17 +00:00
perseant b397c875ae Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon.  To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:

* Create a writer daemon kernel thread whose purpose is to handle page
  writes for the pagedaemon, but which also takes over some of the
  functions of lfs_check().  This thread is started the first time an
  LFS is mounted.

* Add a "flags" parameter to GOP_SIZE.  Current values are
  GOP_SIZE_READ, meaning that the call should return the size of the
  in-core version of the file, and GOP_SIZE_WRITE, meaning that it
  should return the on-disk size.  One of GOP_SIZE_READ or
  GOP_SIZE_WRITE must be specified.

* Instead of using malloc(...M_WAITOK) for everything, reserve enough
  resources to get by and use malloc(...M_NOWAIT), using the reserves if
  necessary.  Use the pool subsystem for structures small enough that
  this is feasible.  This also obsoletes LFS_THROTTLE.

And a few that are not strictly necessary:

* Moves the LFS inode extensions off onto a separately allocated
  structure; getting closer to LFS as an LKM.  "Welcome to 1.6O."

* Unified GOP_ALLOC between FFS and LFS.

* Update LFS copyright headers to correct values.

* Actually cast to unsigned in lfs_shellsort, like the comment says.

* Keep track of which segments were empty before the previous
  checkpoint; any segments that pass two checkpoints both dirty and
  empty can be summarily cleaned.  Do this.  Right now lfs_segclean
  still works, but this should be turned into an effectless
  compatibility syscall.
2003-02-17 23:48:08 +00:00
fvdl 180fbdb32f Use int32_t for block adresses in segment summary structures. 2003-02-10 21:17:53 +00:00
perry 1f4ad37fe3 "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
2003-02-05 00:02:24 +00:00
mrg a9119e2a88 make this build on alpha after daddr_t->64bit 2003-01-28 08:34:17 +00:00
fvdl a3ff3a3038 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.
2003-01-24 21:55:02 +00:00
yamt c2484eff3b - fix memory leak.
- add more error checks.
- spaces -> tab
2002-12-15 08:38:17 +00:00
yamt ad4e5e5793 for -b, use ssize instead of segshift.
segshift is invalid for v2 filesystems.
2002-12-15 07:25:37 +00:00
yamt eef82bb71b fix a typo in previous.
PR 19278 from Ryo HAYASAKA.
2002-12-05 02:03:56 +00:00
christos 8f7c885f66 clean this up a bit. avoid annoying code duplication on opening files,
and make error messages consistent.
2002-11-29 17:15:46 +00:00
yamt 84677ad64e fix calculation bugs that prevents coalescing from working properly.
PR 19133.
2002-11-24 08:47:28 +00:00
wiz d6285bbf1d Begin new sentences on new lines.
Patch from Robert Elz (kre at munnari oz au).
2002-09-29 14:05:52 +00:00
lukem f794aa60bb Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path 2002-08-19 13:54:34 +00:00
perseant f4fea25c9f Note each type of failure in clean_inode and provide statistics on
failures as well as successes when a run of clean_all_inodes completes.

Explicitly cast to off_t in get_dinode and get_rawblock, to make sure we
read the right block.
2002-06-14 05:21:21 +00:00
perseant d6e1fa2b25 Don't try to coalesce files that have fewer than NDADDR blocks, due to
a potential problem with cleaning fragments at all.

Better sanity checks when selecting files to coalesce; in particular don't
shift too far left when comparing the number of discontinuities to the log2
of the number of total blocks.

Better log messages: note beginning of coalescing correctly; also take
the log message from add_segment out of "if (debug)" for symmetry with the
"finished segment" message.

Use lfs_bmapv to find the inode, rather than looking it up manually in
the ifile; this should give more up-to-date information, since trolling
through every inode in the fs could take some time.
2002-06-14 00:58:39 +00:00
perseant a558d1ec81 update lfs_cleanerd manual page for new -c option 2002-06-06 01:03:12 +00:00
perseant 8abab7cfc8 First stab at file coalescing. When the cleaner detects that it might
be digging itself deeper into a hole, it forks off a subprocess
that locates files with too many discontinuities and rewrites them, if
there is enough room.

Optionally the user can manually coaleasce files by running with "-c".

The recent change to lfs_markv is required for the coalescer to do anything.

All of "digging itself deeper", "too many discontinuities", and "enough room"
need to be better defined.
2002-06-06 00:56:49 +00:00
yamt b146f5d7f4 fix a reversed condition. 2002-05-03 04:43:57 +00:00
agc b86348d33b Cast arg to long, and print with %ld, so that this compiles on some of
the more esoteric architectures.
2002-04-30 15:21:55 +00:00
perseant da431b0f6d Correct my previous lfs_cleanerd commit so that it works properly on
v1 filesystems as well (use segtod instead of lfs_ssize / lfs_fsize).

Tested on i386.
2002-04-30 00:28:58 +00:00
yamt 1ea132ca5f remove one of duplicated "bfree" from debug message. 2002-04-29 19:50:05 +00:00
yamt 3c9c3c1b83 use errx instead of err in some places
in order to avoid "Undefined error: 0"
2002-04-29 19:03:15 +00:00
perseant c5f5fa476f Fix error in how much memory needed to be allocated to check data cksum
to proceed with adding segments.

Use fixed-width types to compute checksum, so LP64 machines can do it too.

Tested on alpha; test-compiled on arm32.
2002-04-26 04:34:41 +00:00
wiz 0e2b950705 Whitespace nits, sort SEE ALSO. 2002-01-15 02:23:17 +00:00
itojun da4f6b8247 daemon(3) should be used prior to file descriptor setups. 2002-01-11 05:18:11 +00:00
wiz 1fd7eeefcd "than" instead of "then". 2001-11-21 19:14:19 +00:00
perseant 0a9ceae750 fix printf format on alpha 2001-07-18 06:24:38 +00:00
perseant cfe2897c6e Handle segment 0 properly, if its offset is different from other segments
because of the disklabel.

Fix a problem with inode block handling that sometimes caused the wrong
blocks to be read, causing either cleaning failures or panics with v2 file
systems.
2001-07-18 05:46:43 +00:00
perseant 4e3fced95b Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default.  Changes for the v2 layout include:

- Segments of non-PO2 size and arbitrary block offset, so these can be
  matched to convenient physical characteristics of the partition (e.g.,
  stripe or track size and offset).

- Address by fragment instead of by disk sector, paving the way for
  non-512-byte-sector devices.  In theory fragments can be as large
  as you like, though in reality they must be smaller than MAXBSIZE in size.

- Use serial number and filesystem identifier to ensure that roll-forward
  doesn't get old data and think it's new.  Roll-forward is enabled for
  v2 filesystems, though not for v1 filesystems by default.

- The inode free list is now a tailq, paving the way for undelete (undelete
  is not yet implemented, but can be without further non-backwards-compatible
  changes to disk structures).

- Inode atime information is kept in the Ifile, instead of on the inode;
  that is, the inode is never written *just* because atime was changed.
  Because of this the inodes remain near the file data on the disk, rather
  than wandering all over as the disk is read repeatedly.  This speeds up
  repeated reads by a small but noticeable amount.

Other changes of note include:

- The ifile written by newfs_lfs can now be of arbitrary length, it is no
  longer restricted to a single indirect block.

- Fixed an old bug where ctime was changed every time a vnode was created.
  I need to look more closely to make sure that the times are only updated
  during write(2) and friends, not after-the-fact during a segment write,
  and certainly not by the cleaner.
2001-07-13 20:30:18 +00:00
christos 75ac9bb540 remove redundant declarations. 2001-02-04 22:12:47 +00:00
cgd 9cfe468c74 avoid C sequence point issues warned about by development version of gcc. 2001-01-16 02:41:17 +00:00
lukem 3f963260b9 be more consistent about syslog usage. now it's more like:
err		fatal errors
	warning		warnings
	info		status messages (-d), stats on SIGxxx
	debug		debug messages (-d), debug stats
2001-01-10 01:13:54 +00:00
joff d68ab23851 Don't qsort() by the segcreate field. Prevents potentially serious filesystem
corruption if the clock jumps backwards.
2001-01-09 04:31:18 +00:00
lukem de3e6adaf6 use more standard %ll_ in favour of %q_ 2001-01-04 17:24:35 +00:00
perseant 59ca5b76e4 Don't "compress" segment data if we were using mmap instead of malloc/copy
to read the segment.
2000-11-23 23:01:55 +00:00
perseant c019319ae3 Check for ENOENT return from lfs_{bmapv,markv} and do the right thing with it,
avoiding needless looping (possibly infinite looping) on certain kinds of
errors.

Get rid of erroneous free() in error return from add_segment.

Patch from Jesse Off <joff@gci-net.com> (PR #11547).
2000-11-22 22:17:39 +00:00
perseant 9683b76b99 Try to prevent running more than one active cleaner on a filesystem at a time.
Let lfs_cleanerd record its pid in /var/run like other daemons.  Make
mount_lfs not start another cleaner when updating the mount, unless it is
being upgraded from read-only to read-write; when downgrading to read-only,
kill the cleaner using the recorded pids.
2000-11-13 22:12:49 +00:00
perseant d5e76bbac2 Don't hold every segment that is being cleaned in memory in its entirety;
instead, if the segment doesn't have many live blocks, copy them to a
more appropriately sized chunk of memory and release the original.

This should prevent the cleaner from distending itself when cleaning many
segments with only one or two live blocks each, as when using the "-b" option.
2000-11-11 22:40:13 +00:00
hubertf dca9c22e0c in SEE also, xref newfs_lfs(8), sort entries and seperate by "," 2000-11-08 19:45:08 +00:00
perseant d9cc43d8a3 Fix memory leak described in PR #11094 (patch from Jesse Off
<joff@gci-net.com>).
2000-11-03 17:52:55 +00:00
perseant 9c7f8050f4 Various bug-fixes to LFS, to wit:
Kernel:

* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
  for writing.  Writes to the filesystem first reserve a maximum amount
  of blocks before their write is allowed to proceed; after the blocks
  are allocated the reserved total is reduced by a corresponding amount.

  If the lfs_reserve function cannot immediately reserve the requested
  number of blocks, the inode is unlocked, and the thread sleeps until
  the cleaner has made enough space available for the blocks to be
  reserved.  In this way large files can be written to the filesystem
  (or, smaller files can be written to a nearly-full but thoroughly
  clean filesystem) and the cleaner can still function properly.

* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
  is now merely a fs-creation parameter used to compute dlfs_avail and
  dlfs_bfree (and used by fsck_lfs(8) to check their accuracy).  Its
  former role is better assumed by a properly computed dlfs_avail.

* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
  This prevents a panic, but, if the cleaner is feeding the filesystem
  the wrong data, you are still in a world of hurt.

* Cleanup: remove explicit references of DEV_BSIZE in favor of
  btodb()/dbtob().

lfs_cleanerd:

* Make -n mean "send N segments' blocks through a single call to
  lfs_markv".  Previously it had meant "clean N segments though N calls
  to lfs_markv, before looking again to see if more need to be cleaned".
  The new behavior gives better packing of direct data on disk with as
  little metadata as possible, largely alleviating the problem that the
  cleaner can consume more disk through inefficient use of metadata than
  it frees by moving dirty data away from clean "holes" to produce
  entirely clean segments.

* Make -b mean "read as many segments as necessary to write N segments
  of dirty data back to disk", rather than its former meaning of "read
  as many segments as necessary to free N segments worth of space".  The
  new meaning, combined with the new -n behavior described above,
  further aids in cleaning storage efficiency as entire segments can be
  written at once, using as few blocks as possible for segment summaries
  and inode blocks.

* Make the cleaner take note of segments which could not be cleaned due
  to error, and not attempt to clean them until they are entirely free
  of dirty blocks.  This prevents the case in which a cleanerd running
  with -n 1 and without -b (formerly the default) would spin trying
  repeatedly to clean a corrupt segment, while the remaining space
  filled and deadlocked the filesystem.

* Update the lfs_cleanerd manual page to describe all the options,
  including the changes mentioned here (in particular, the -b and -n
  flags were previously undocumented).

fsck_lfs:

* Check, and optionally fix, lfs_avail (to an exact figure) and
  lfs_bfree (within a margin of error) in pass 5.

newfs_lfs:

* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.

* Add a warning if the sgs disklabel field is 16 (the default for FFS'
  cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).

* Change the calculation of lfs_avail and lfs_bfree, corresponding to
  the kernel changes mentioned above.

mount_lfs:

* Add -N and -b options to pass corresponding -n and -b options to
  lfs_cleanerd.

* Default to calling lfs_cleanerd with "-b -n 4".


[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]
2000-09-09 04:49:54 +00:00
perseant f184685d10 cleaner changes corrseponding to kernel changes 2000-07-04 22:36:17 +00:00
perseant 9a38f49c57 User-level changes corrseponding to my latest kernel changes.
newfs_lfs gives lfs_minfreeseg a value of 1/8 of the total segments on
the disk, based on rough empirical data, but this should be refined in
the future.
2000-07-03 01:49:11 +00:00
perseant bbc8485d45 Make sure to segunmap segments on error in lfs_bmapv or lfs_markv. Prevents
a memory leak of by default 1 Mb per error.  May fix PR #9149.
2000-06-21 01:58:52 +00:00
perseant d244493927 Take care of memory leaks 2000-01-18 08:02:30 +00:00
perseant fcb8440e38 If the child cleaner dies repeatedly without doing anything, give up. Uses
similar logic to inetd to identify such looping.
1999-11-09 20:33:37 +00:00
perseant 2750b8620f Make datobyte do its arithmetic explicitly in 64 bits, so that segments
beyond the first 2G of disk can be cleaned.
1999-11-09 01:06:39 +00:00
perseant 64846ce5dc Don't complain that we can't fstat the Ifile, if it's because the filesystem
has been unmounted.  (I.e., don't give errors every time an LFS is unmounted.)
1999-10-07 18:26:58 +00:00
soren 30d18a154c Remove extraneous colons and newlines from perror(3) arguments. 1999-09-30 12:35:52 +00:00
perseant 193a2fa9f0 Remove partial-segment timestamp optimization from lfs_segmapv. If "time"
is not monotonically increasing (e.g. clock is slaved to another system)
the optimization will result in segments being treated as corrupt
(uncleanable).  If enough such "bad" segments were created, the cleaner would
clean continuously, and after some time the system would panic with "no
clean segments".

(Legitimately old partial-segments are relatively rare, and will have their
blocks culled by lfs_bmapv.)
1999-08-25 00:14:13 +00:00
tron cf71eb8d35 Correct wrong conversion specifications in calls to syslog(3). 1999-06-16 16:34:29 +00:00
perseant 0486add127 The cleaner now marks empty segments clean without having to read their
contents, a substantial optimization if the work load is right: if enough
empty segments are available, the cleaner never has to read or write *any*
blocks except those on the Ifile.  When the cleaner wakes up it marks all
empty segments clean before deciding whether any further segments need to
be cleaned.

Fixed overflow bugs in the cleaner's handling of the cost/benefit metric
for empty segments.
1999-06-15 22:33:48 +00:00
garbled f124765044 More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages.  Many more to
come.
1999-03-22 18:25:43 +00:00
drochner 8f59d4063a work around egcs prints format warning on alpha
(XXX bad fix, but egcs doesn't like a "quad_t" here)
1999-03-14 11:43:25 +00:00
drochner 8ae646e9ae work around printf format warnings on alpha 1999-03-14 11:39:28 +00:00
perseant 2c952176c1 Cleaner changes corresponding to in-kernel LFS changes. In particular, the
cleaner understands fragments; and it knows to change bi_bp to reflect a
change in bi_daddr, if lfs_bmapv says that there is one.
1999-03-10 00:57:16 +00:00
ross ee65bcaa99 Cast quad_t and off_t objects to (long long) for printing with %q.
(Fix a sort-of-LP64 egcs printf warning.)

It's unfortunate that off_t and quad_t don't print with %q. I wonder
what would happen if alpha changed these from long -> long long? It's
the same actual size in bits either way.
1998-10-15 00:29:51 +00:00
christos 977a282bd1 PR/6248: Konrad Schroder: lfs_cleanerd could use syslog() for notices,
instead of err()/warn()
1998-10-07 15:00:34 +00:00
christos e044377a39 PR/6249: Konrad Schroder lfs_cleanerd uses wrong units when computing which
segments to clean
1998-10-07 14:57:30 +00:00
christos 2e885feacf PR/6247: Konrad Schroder: lfs_cleanerd overflows char register counting live
bytes
1998-10-07 14:56:22 +00:00
pk 547e652f5d type fixes, in part from PR#6032 1998-09-11 21:21:29 +00:00
perry bfd526219d bzero->memset, bcopy->memcpy, bcmp->memcmp 1998-08-10 02:57:23 +00:00
hubertf 80a44df7c2 use correct getopt parameters, as per PR 5480 from Konrad Schroder <perseant@hhhh.org> 1998-05-22 02:21:00 +00:00
kleink 2efb2aaff6 Need <time.h> for ctime() prototype. 1998-04-01 14:39:56 +00:00
kleink d868740f80 Need <time.h> for time() and ctime() prototypes. 1998-04-01 14:37:45 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
mycroft 4462053ab3 Fill in missing (default) mmap(2) flags. 1998-02-20 09:27:18 +00:00
perry 6982982f8d macroize BSD, NetBSD, FreeBSD and misc cleanup 1998-02-06 05:39:31 +00:00
lukem dc3678728d use CPPFLAGS instead of CFLAGS 1997-10-22 05:45:08 +00:00
enami 7eda8e3153 Fix usage of .Nm. 1997-10-20 02:05:33 +00:00
enami 80b4fe5249 No need to decalre optind. 1997-10-20 02:04:03 +00:00
mrg 2268d2dfb3 merge lite-2 Makefiles (rcsids), and turn on WARNS for all of libexec. 1997-10-08 09:07:11 +00:00
enami 42eb13e478 Compare a return value of getopt() against -1 instead of EOF. 1997-10-08 00:56:46 +00:00
mrg ad681f7eae WARNS?=1. RCS ids. 1997-10-07 13:44:03 +00:00
mrg 3d8d628a25 WARNS?=1. RCS ids. 1997-10-07 13:39:56 +00:00
mikel a7d3a434b9 avoid void pointer arithmetic 1997-08-01 06:33:39 +00:00
cgd c917dfb5b2 Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
	.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
	.Dd "month day, year"
which is what these pages did.
1997-05-29 01:48:05 +00:00
pk 37d70219e5 * NULL => 0 (Arne Juul; PR#3629)
* Nuke spacoids.
1997-05-17 19:35:14 +00:00
tls eec1ea6c3f Import from 4.4BSD-Lite2 1997-04-29 20:07:31 +00:00
cgd ae9172d6cd specify man pages the new way. 1994-12-22 09:57:51 +00:00
mycroft 8f58e94ed3 Import original 4.4-Lite version. 1994-09-24 00:41:59 +00:00
deraadt 1a69335ad4 do not need -I/sys 1994-08-03 20:46:47 +00:00
mycroft 2cf76ce530 From 4.4-Lite, with local changes. 1994-06-08 18:42:09 +00:00