Commit Graph

914 Commits

Author SHA1 Message Date
nakayama a6d8c9185d Avoid comparison is always false warning in gcc 3.3 w/ 64-bit size_t. 2003-05-17 01:44:39 +00:00
kristerw 07936511f0 The C language does not permit statements of the form
(X ? Y : Z) = 0;
even though gcc handles this by a stupid extension.

Transform these to correct C.

Approved by fvdl.
2003-05-15 20:25:31 +00:00
ragge 97fa6ef77b Add a missing ifdef DDB. 2003-05-07 18:49:29 +00:00
gmcgarry 835240b191 Print pid on error. From Greg A. Woods in PR#17393. 2003-05-04 01:52:18 +00:00
christos 7a96f65456 make sure we update fs_fsmnt. 2003-05-03 16:24:35 +00:00
perseant e18585deb2 Correct arguments to check_dirty, ensuring that all pages in a block are
written if any of them are dirty.  Pointed out by yamt.
2003-05-02 01:47:39 +00:00
perseant 100c8f971f Restrict the run of cluster blocks to on-disk contiguous blocks (back out
part of rev 1.115), to avoid writing over holes.  This is the lesser of two
evils, to be replaced soon.
2003-04-29 17:45:11 +00:00
yamt 3f3b3242de constify 'mastertemplate'. 2003-04-29 07:45:23 +00:00
yamt 982fbc7db4 add an assertion. 2003-04-29 07:44:04 +00:00
yamt b4d5e11ffe fix a comment. 2003-04-27 06:47:45 +00:00
yamt c2b802ff24 fix b_interlock lock/unlock mismatches. 2003-04-27 06:46:38 +00:00
perseant b691ba8a71 Don't change update time on block write; lets e.g. "tar xp" work properly. 2003-04-27 04:18:29 +00:00
fvdl 94e92b1bb3 Assign the right linkcount when renaming a directory. 2003-04-25 23:12:33 +00:00
gmcgarry 0645f99b01 More ufs2 merge fall-out. Pass the correct pointer to the dinode
for clearing.  Fixes PR#21241.
2003-04-24 08:05:35 +00:00
perseant ef3c60764c Make LFS work better (though still not "well") as an NFS-exported
filesystem (and other things that needed to be fixed before the tests
would complete), to wit:

* Include the fs ident in the filehandle; improve stale filehandle checks.

* Change definition of blksize() to use the on-dinode size instead of
  the inode's i_size, so that fsck_lfs will work properly again.

* Use b_interlock in lfs_vtruncbuf.

* Postpone dirop reclamation until after the seglock has been released,
  so that lfs_truncate is not called with the segment lock held.

* Don't loop in lfs_fsync(), just write everything and wait.

* Be more careful about the interlock/uobjlock in lfs_putpages: when we
  lose this lock, we have to resynchronize dirtiness of pages in each
  block.

* Be sure to always write indirect blocks and update metadata in
  lfs_putpages; fixes a bug that caused blocks to be accounted to the
  wrong segment.
2003-04-23 07:20:37 +00:00
tls 85c8cfb533 Correct use of MAXBSIZE where MAXPHYS was intended. This is a necessary
first step towards per-device MAXPHYS, and has the beneficial side effect
of allowing clustering to MAXPHYS even on systems that need to run with
a reduced MAXBSIZE to get more metadata buffers.
2003-04-23 00:55:17 +00:00
christos d864ba0136 fix lkm malloc lossage. 2003-04-22 17:14:12 +00:00
christos db7b52084a choose the smaller size of the two strings when memcpy'ing them. A better
fix would be to strncpy and null terminate? From enami.
2003-04-22 13:18:52 +00:00
christos a94b10edf1 PR/2996: Greg Oster: Fix comment to match reality. Names are padded to
four bytes, but the bytes are not null.
2003-04-19 22:02:39 +00:00
fvdl 0545901d27 configdirs was changed to an array of u_int8_t, so don't compare values
to 65535.
2003-04-17 09:32:43 +00:00
christos 80ecd573c0 PR/1796: John Kohl: statfs misbehaves under chrooted environments.
- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
  and factored out some of the vfsop statfs() code to copy_statfs_info(). This
  fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.
2003-04-16 21:44:18 +00:00
yamt aa51f25824 ufs_rwXX: cast to unsigned even without FFS_EI to avoid
possible nasty signed vs unsigned problems.
2003-04-16 14:27:03 +00:00
yamt 1963d34b78 use bswap32 and bswap64 correctly.
(fs_pendingblocks and fs_pendinginodes)
2003-04-16 14:20:25 +00:00
fvdl d0152b0231 ffs_reclaim may be called while the dinode pointer in the inode structure
is still NULL (in the case of an error in ffs_vget). Check for this
condition before doing a pool_put.
2003-04-16 07:38:25 +00:00
fvdl ba400f9233 Don't cache buffers used when finding the superblock, it can lead to
seeing bogus data for the first cg with certain block/frag sizes.
From enami tsugutomo.
2003-04-12 10:35:58 +00:00
fvdl 9e0b0abaa7 Use variables for some cg accesses; makes things more readable and more
similar to FreeBSD. No functional change.
2003-04-12 10:33:17 +00:00
fvdl 4cdcaab92d Remove diagnostic ufs_vinit check, this isn't quite the right place for it;
it'll be reinstated elsewhere.
2003-04-11 14:13:28 +00:00
fvdl 64f0bf8882 Adjust diagnostic check for bad mode field; only the VNON case should
matter. From Enami.
2003-04-11 10:36:33 +00:00
enami b0715b0b82 Make ffs_cg_swap() works even if same chunk is passed as new and old cg.
This is necessary to prevent newfs from dumping core when it is asked to
create a UFS1 file system of non-native endian.
2003-04-11 10:20:35 +00:00
fvdl bf82cd91c6 Add diagnostic check to ufs_vinit in order to catch bad mode fields in
inodes early.
2003-04-10 20:22:04 +00:00
fvdl 63ab1add00 Initialize the 'mirror' i_flags fiels in struct inode to 0. 2003-04-10 20:03:40 +00:00
fvdl 2758e6ad60 Remove some leftover diagnostic checks. 2003-04-10 20:02:36 +00:00
simonb 761de7345c '#if 0' out a variable that is currently only used in other '#if 0'd out
code.
2003-04-10 04:15:38 +00:00
thorpej 24a4b8faa6 Use PAGE_SIZE rather than NBPG. 2003-04-09 00:28:28 +00:00
fvdl 85d5aca005 Actually get an ext2fs_dinode structure from the pool before using it. 2003-04-05 14:01:56 +00:00
fvdl 4f33a6f2e1 * Use the old and new time fields in the superblock as well as a few others
to determine if this filesystem was mounted by an older kernel after
  having been mounted by a newer one, to avoid some summary mismatches.
* Reinstate support for 4.2 cylinder groups (read-only, as it was before).
2003-04-05 13:37:36 +00:00
he f8cf57f9b0 Remember to prefix the manually-swapped FS magic numbers with 0x. 2003-04-05 11:12:42 +00:00
drochner 42b749318f adapt to struct inode change (in UVMHIST code) 2003-04-04 13:39:58 +00:00
fvdl 7847218fc1 FreeBSD revision 1.135:
When removing the last item from a non-empty worklist, the worklist
tail pointer must be updated.
2003-04-03 19:28:07 +00:00
fvdl 7d31e8f0d9 Avoid truncation of values in some macros that shift 64 bit values.
From FreeBSD.
2003-04-03 16:07:09 +00:00
he a1cf02e789 In the inode, i_din.e2fs_din is now a pointer, so there is no longer
a need to take the address here.
2003-04-02 22:38:22 +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
yamt 0296b9ddb2 add assertions and a debug check. 2003-04-01 14:58:43 +00:00
yamt 418bd96252 lfs_strategy is used only for read. 2003-04-01 14:31:50 +00:00
fvdl e80c0648b1 The modified flag must be cleared before the last sbupdate call in
unmount, because ffs_flushfiles or softdep_flushfiles may have
modified the filesystem (despite VFS_SYNC having been called first).
2003-03-31 21:02:12 +00:00
fvdl 691b2fa7db The checkpoint loop always used (multiples of) lfs_sepb as the number
of segments to mark. However, this may be much more than lfs_nseg.

Originally this wasn't a big problem, since only the structures in the
diskblock were changed, but nowadays there's a mirror of the segflags
in the in-core superblock. This problem caused the code to walk
way past the end of that allocated area, causing memory corruption
in other kernel structures. So, use lfs_nseg as the maximum, as it should be.

While here, simplify the loop; it had become an obfuscated piece of
code overtime.
2003-03-28 22:39:42 +00:00
perseant 3f7016035a Add a sleeper count, to prevent the cleaner from panicing the kernel
when the filesystem is unmounted, relocking the Ifile when its lock is
draining.  (We can't use vfs_busy() since the process is sleeping for a
good long time.)  Clean up / organize lfs.h, while I'm here.

In lfs_update_single, assert that disk addresses are either negative, or
are still positive when converted to int32_t, to prevent recurrence of a
negative/positive block problem.
2003-03-28 08:03:38 +00:00
perseant 17bba97d2e Unlock ifile inode during streamlined VOP_INACTIVE. 2003-03-22 21:31:41 +00:00
dsl bd99e3429d Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
2003-03-21 23:11:19 +00:00
fvdl 543510a84d LFS likes to store negative values in the dinode block pointers, so
make sure to cast the value back to int32_t after it was changed
by ufs_rw32, before passing it to blkptrtodb.
2003-03-21 15:46:32 +00:00
perseant 78dff1cfa3 KNF (space after keywords). 2003-03-21 06:26:36 +00:00
perseant a37f4cf7ec Use VONWORKLST as a heuristic for vnode emptiness, rather than exhaustively
checking the memq.

Take greater care not to dirty the Ifile vnode when unmounting the filesystem.
This should fix a "(vp->v_flag & VONWORKLST) == 0" assertion panic in vgonel
that could occur when unmounting.

Do not allow the Ifile to be mapped for writing.
2003-03-21 06:16:53 +00:00
yamt e8d83a0b17 make this compilable with DIAGNOSTIC and without DEBUG.
fix PR 20827 from FUKAUMI Naoki.
2003-03-21 06:09:08 +00:00
yamt a8e8f3ea02 lfs_writevnodes:
in the case of "starting over", kick lfs_writeseg
in order to avoid deadlock in check_dirty.
2003-03-20 14:17:21 +00:00
yamt 91ce94db76 fix "more than one fragment" panics;
direct and indirect block pointers are not valid in the case of shortlinks.
while i'm here, move duplicated code in lfs_vget/fastvget into a new
function, lfs_vinit.
2003-03-20 14:11:46 +00:00
perseant 12a78a5a7e Don't break out of Ifile-writing loop in lfs_segwrite until nothing is left.
Note however that blocks can be added to the Ifile even when the segment
block is held because of inodes' atime.  Do not panic with "dirty blocks"
if these blocks are present.
2003-03-20 06:51:17 +00:00
perseant c364d884f6 Hold the segment lock during truncation to prevent indirect blocks from
being written by lfs_updatemeta while lfs_truncate is also writing them,
a bug pointed out by YAMAMOTO Takashi <yamt@netbsd.org>.
2003-03-20 06:47:38 +00:00
perseant 20f569dad0 Remember to destroy lfs_inoext_pool when closing up the LFS subsystem. 2003-03-18 07:53:56 +00:00
perseant 1d23f2f4ea Add write-behind to lfs_write(). 2003-03-15 07:24:37 +00:00
perseant b105ddb1d6 Make LFS LKM versions of ufs_makeinode and ufs_mkdir fail correctly.
Note dependency of lfs_vnops.o on ufs_readwrite.c.
2003-03-15 07:20:22 +00:00
perseant ea03a1ac09 Add simple_lock protection for lfs_seglock and lfs_subsys_pages; these will
be expanded to cover other per-fs and subsystem-wide data as well.

Fix a case of IN_MODIFIED being set without updating lfs_uinodes, resulting
in a "lfs_uinodes < 0" panic.

Fix a deadlock in lfs_putpages arising from the need to busy all pages in a
block; unbusy any that had already been busied before starting over.
2003-03-15 06:58:49 +00:00
kristerw ea98786439 SO C requires a statement after a label. 2003-03-15 02:27:18 +00:00
kristerw f73d0d2d8c ffs_gop_alloc() is not used any more. Remove it.
OK:ed by Konrad Schroder.
2003-03-15 01:10:18 +00:00
perseant ec13062af8 - Get rid of unused #ifdefs LFS_NO_PAGEMOVE and LFS_MALLOC_SUMMARY (both
always true) and accompanying dead code.

- When constructing write clusters in lfs_writeseg, if the block we are
  about to add is itself a cluster from GOP_WRITE, don't put a cluster
  in a cluster, just write the GOP_WRITE cluster on its own.  This seems
  to represent a slight performance gain on my test machine.

- Charge someone's rusage for writes on LFSes.  It's difficult to tell
  who the "right" process to charge is; just charge whoever triggered
  the write.
2003-03-11 02:47:39 +00:00
perseant a46b9ccf95 Only #define LFS if not already defined. 2003-03-08 23:18:54 +00:00
perseant 0493be6ba8 Take away "#ifdef LFS_UBC". 2003-03-08 22:14:31 +00:00
perseant 8feb2c22f5 Take away "#ifdef LFS_UBC". 2003-03-08 21:46:04 +00:00
perseant 4b4f884b89 Add an lfs_strategy() that checks to make sure we're not trying to read
where the cleaner is trying to write, instead of tying up the "live"
buffers (or pages).

Fix a bug in the LFS_UBC case where oversized buffers would not be
checksummed correctly, causing uncleanable segments.

Make sure that wakeup(fs->lfs_iocount) is done if fs->lfs_iocount is 1
as well as 0, since we wait in some places for it to drop to 1.

Activate all pages that make it into lfs_gop_write without the segment
lock held, since they must have been dirtied very recently, even if
PG_DELWRI is not set.
2003-03-08 02:55:47 +00:00
perseant d51fdbef63 Make sure we hold the uobjlock when checking for dirty pages, in lfs_vflush.
Note that pages can become dirty without our knowing it, anyway; don't
panic if that happens.
2003-03-04 19:19:43 +00:00
perseant 003cfbd545 Don't add dirty blocks to the ifile in lfs_segunlock, if we're trying to
unmount the filesystem.  This avoids a "dirty blocks" panic.
2003-03-04 19:15:26 +00:00
perseant 958a4c008c Don't force all truncations to be synchronous 2003-03-04 19:10:35 +00:00
perseant 9192f047ac Account SEGUSE_ACTIVE correctly so that the automatic segment cleaning
actually happens.

Add a new fcntl call that will write the minimum necessary to checkpoint
(i.e., for on-disk directory structure to be consistent, not including
updates to file data) so that the cleaner can clean segments more quickly
without sacrificing three-way commit for cleaning.
2003-03-02 04:34:30 +00:00
yamt 32a79f1dd0 use pid_t for pid. 2003-03-01 11:20:21 +00:00
perseant cfc73a5fa9 Be careful to always zero pages on truncation/fragment extension,
in the case where the filesystem block size is larger than PAGE_SIZE.
2003-03-01 05:07:51 +00:00
perseant daeb6c37d1 Make lfs_truncate handle file extension correctly, in the LFS_UBC case. 2003-02-28 07:37:56 +00:00
perseant c418e0c4d6 Fix a clrbuf() on an uninitialized pointer. 2003-02-28 07:36:32 +00:00
perseant a94f9407dc Quell a hasty panic in lfs_truncate: on-inode disk addresses can be
different between the beginning and end of the call.
2003-02-28 04:37:07 +00:00
perseant 0b114d4e21 Do roundup and offset arithmetic in 64 bits, to allow >=2G files. 2003-02-27 07:10:27 +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
thorpej eb14e86676 Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it.  This fixes a few places where either b_dep or b_interlock were
not properly initialized.
2003-02-25 20:35:31 +00:00
yamt 2bad134129 fix simplelocks 2003-02-25 13:47:44 +00:00
perseant 95137c8477 Add lfs_ioctl vnode op, with ioctls to take over cleaner system call
functionality (not including segment clean, since that is now done
automatically as checkpoints happen).
2003-02-24 08:42:49 +00:00
simonb 2a4457bd46 Remove assigned-to but not used variable. 2003-02-23 03:32:55 +00:00
perseant 3ab94fed93 Fix a buffer overflow bug in the LFS_UBC case that manifested itself
either as a mysterious UVM error or as "panic: dirty bufs".  Verify
maximum size in lfs_malloc.

Teach lfs_updatemeta and lfs_shellsort about oversized cluster blocks from
lfs_gop_write.

When unwiring pages in lfs_gop_write, deactivate them, under the theory
that the pagedaemon wanted to free them last we knew.
2003-02-23 00:22:33 +00:00
yamt 1dd4645db4 fix simple_lock/unlock mismatches. 2003-02-22 01:52:25 +00:00
perseant fdf4bfe002 Tabify, and fix some comment alignment problems. 2003-02-20 04:27:23 +00:00
yamt 5f444770aa add debug code to lfs_free. 2003-02-19 12:58:53 +00:00
yamt 65fda8e404 workaround for "another flush is..." infinity loop in writerd.
if we're writerd, sleep in lfs_flush until another writer goes away
instead of busy loop in writed.
2003-02-19 12:49:10 +00:00
yamt d9a4f81d1c wire the pages instead of just dequeue'ing them.
advised by Chuck Silvers.
2003-02-19 12:22:51 +00:00
yamt 18e00c1196 init b_interlock. 2003-02-19 12:18:59 +00:00
yamt 2be86f2ff8 acquire v_interlock before calling VOP_PUTPAGES. 2003-02-19 12:02:38 +00:00
yamt 0ad89cf93e init b_interlock. 2003-02-19 12:01:17 +00:00
soren 3291a4522e Make libsa compile again. 2003-02-18 14:58:31 +00:00
perseant e61877243d Make it compile again, grr.... 2003-02-18 02:00:08 +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
perseant 83adb24145 Allow negative values other than UNASSIGNED to be returned from ufs_bmap;
fixes a bug introduced in the 64-bit daddr_t conversion, that manifests
itself in LFS with kernels compiled with the FFS_EI option.
2003-02-09 03:26:59 +00:00
pk 338f31f581 Make the buffer cache code MP-safe. 2003-02-05 21:38:38 +00:00
perseant 14c17e57b4 Don't call a dirop within a dirop: if lfs_rename is actually deleting
a link, call lfs_remove directly before starting dirop rather than
having ufs_rename do it.
2003-02-03 00:32:35 +00:00
tron f1eeaa9020 Only use MALLOC_DECLARE() in kernel namespace. 2003-02-01 18:34:14 +00:00
thorpej b193480908 Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant.  Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
2003-02-01 06:23:35 +00:00