Commit Graph

838 Commits

Author SHA1 Message Date
kre
65dda4ca5a Sprinkle in a pinch of const, not too much, just enough
to add a little strength without affecting the overall balance...
2017-02-09 04:37:35 +00:00
hannken
958c9321b9 Fix a bug introduced with Rev. 1.294: use LK_NOWAIT when called with MNT_LAZY. 2016-12-27 10:54:38 +00:00
hannken
3a541ed229 Fix a "slight tweak" from Rev. 1.121: bap1/bap2 must be valid
before using BAP_ASSIGN().

Prevents NULL pointer dereference when "lastbn >= 0".
2016-11-11 10:50:16 +00:00
jdolecek
f9c82ee8e7 disable discard when log is enabled to preserve log consistency promise
PR kern/50725
2016-11-10 22:19:23 +00:00
jdolecek
86e8a3aae2 during truncate with wapbl, register deallocation for upper indirect block
before recursing into lower blocks, to make sure that it will be removed after
all its referenced blocks are removed

fixes 'ffs_blkfree_common: freeing free block' panic triggered by
ufs_truncate_retry() when just the upper indirect block registration failed,
code tried to free the lower blocks again after wapbl flush

problem found by hannken@, thank you
2016-11-10 20:56:32 +00:00
jdolecek
6730f31e00 ffs_indirtrunc(): for !wapbl, restore rev 1.117 behavior of writing the zeroed
(indirect) block before freeing the referenced blocks; it's necessary for
fsck to recover the filesystem, if system goes down during truncate

patch courtesy of hannken@ with only sligh tweaks
2016-11-10 19:10:05 +00:00
jdolecek
d16cae2351 fix broken test for partial truncate, introduced in rev 1.118
PR kern/51601 kern/51602
2016-11-07 21:14:23 +00:00
jdolecek
84ac775fb4 reduce diff vs 1.117, no functional change 2016-11-07 21:05:38 +00:00
christos
805187f5b9 Tidy up panic messages, no functional change. 2016-10-30 15:01:46 +00:00
jdolecek
b695bc874e reorganize ffs_truncate()/ffs_indirtrunc() to be able to partially
succeed; change wapbl_register_deallocation() to return EAGAIN
rather than panic when code hits the limit

callers changed to either loop calling ffs_truncate() using new
utility ufs_truncate_retry() if their semantics requires it, or
just ignore the failure; remove ufs_wapbl_truncate()

this fixes possible user-triggerable panic during truncate, and
resolves WAPBL performance issue with truncates of large files

PR kern/47146 and kern/49175
2016-10-28 20:38:12 +00:00
jdolecek
3c9f488da8 revert 1.141 - the second ffs_truncate() can't really fail
requested by hannken@
2016-10-21 19:28:03 +00:00
jdolecek
e1aea9a285 allow also the snapshot_setup()'s call to ffs_truncate() fail, the code
should simply reuse the file blocks in that case; also make sure the
ffs_truncate() call is run within transaction if log is on
2016-10-20 20:17:46 +00:00
jdolecek
7470816b2a add assertion to ensure ffs_cgupdate() is always called from
within a WAPBL transaction (if logging is on)
2016-10-20 19:31:32 +00:00
christos
44548039a1 use __func__ and print the filesystem we are printing the message for. 2016-10-02 19:02:57 +00:00
jdolecek
16c7d9d735 allocate wapbl dealloc registration structures via pool, so that there is more
flexibility with limit handling
2016-10-01 13:15:45 +00:00
jdolecek
8de0ca1330 wapbl_remove_log(): add missing break; harmless, fallthrough just printed
extra debug message
2016-10-01 13:06:20 +00:00
jdolecek
9a0d9b14e1 adjust ffs_realloccg() so that the logic about allocating full
contiguous block for future fragment expansion doesn't need to
UFS_WAPBL_REGISTER_DEALLOCATION() or ffs_blkfree(); the free blocks
are now immediatelly available for use by the expanding file in further i/o

primary driver is safe removal of the deallocation registration and
hence failure point, but this also fixes degenerate case for wapbl,
and similar also for discard - if the file would be actually expanded
before wapbl commit, or before discard queue would be processed,
the filesystem would not yet see the contiguous free blocks, and
would be forced to allocate another fragment elsewhere
2016-09-25 17:14:59 +00:00
jdolecek
ae4b9ec77b fix typo in #ifdef notyet part 2016-09-25 11:45:39 +00:00
jdolecek
7b230d53d8 fix swapped KASSERT() 2016-09-24 21:00:54 +00:00
jdolecek
f082cd3f0b i/o optimization for wapbl flush - only sync superblock and cgs when
they were actually changed
2016-09-24 20:59:51 +00:00
martin
f0b8f9c13b From Michael Plass:
The superblock field that distinguishes between 4.2BSD and 4.4BSD
inodes is really only relevant on a UFS1 file system. Make sure that
it is a UFS1 fs before using fs_old_inodefmt.

Note that the NetBSD newfs and mkfs utilities initialize fs_old_inodefmt
even for UFS2, so problems were apparent only on file systems created
by other operating systems, for example, FreeBSD.
2016-07-28 08:24:58 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
christos
bd61e9ff20 Relax the dup alloc tests to not include the on-disk data for ffsv2, since
nothing checks that the lazy-initialized inodes are correct and if they happen
to get corrupted, there is no way to fix them.
2016-06-19 22:41:31 +00:00
maxv
313bb650e2 uaf 2016-05-07 11:59:08 +00:00
christos
7c83b624ee We need to check if the inode is initialized for ffsv2 when we translate a
filehandle to a vnode. This can come from nfs and it could be out of range.
In that case we read garbage from the disk, end up trying to free bogus data
when we put the vnode back and we crash.
XXX: pullup-7
2015-12-23 23:31:28 +00:00
pgoyette
4873380492 If file system ffs is built with WAPBL defined, make sure that the
module depends on the wapbl module.

No impact to users of built-in ffs file system code, as the WAPBL
#define will cause inclusion of the code in the kernel.

A standard build of the modular ffs file system code will #define
WAPBL, so the module will only work on a kernel which was also
built with WAPBL defined (or, once I commit it, with a dynamically-
loaded wapbl module).
2015-11-15 01:39:23 +00:00
maxv
0bd06ee797 Fix PR 50070. From hannken@. 2015-10-22 11:31:31 +00:00
riastradh
6625d44d90 Need wapbl transaction around ffs_blkfree_cg. Fixes wapbl+discard. 2015-08-12 14:52:35 +00:00
mlelstv
7454f7165e don't crash when printing error messages when there are no credentials.
don't abuse the printed uid to log the inode number.

The printing/logging of error messages should be simplified.
2015-08-08 08:18:52 +00:00
maxv
6647020bbc Unused inits (harmless).
Found by Brainy.
2015-07-24 13:02:52 +00:00
maxv
9aa6c10155 Small fixes.
ok hannken@
2015-06-28 10:04:32 +00:00
maxv
9b2abda5c6 Add a missing goto.
(was here before my changes)

ok christos@
2015-05-23 16:59:13 +00:00
riastradh
6d6f14f9de memcpy di_extb/db/ib separately. Noted by Coverity, CID 974636. 2015-05-20 18:21:17 +00:00
riastradh
9a70a528ec Don't (harmlessly) overrun di_db array; copy di_ib separately.
Noted by Coverity, CID 974635.

While here, simplify size calculation for memcpy.
2015-05-20 18:19:09 +00:00
martin
445ccb6af2 Cosmetics: fix netbsd.org spelling 2015-05-19 06:44:42 +00:00
martin
7ae75c3e08 Print all sizes as size_t 2015-05-18 08:33:29 +00:00
martin
fa64e6ed3d Make the recently added fs_cgsize test less strict, as it prevents existing
installs from booting.
Catch the common case and warn about it, pointing to a web page describing
the issue - but allow mounting. In all other cases, print more details about
the inconsistency and fail the mount.
2015-05-18 08:07:29 +00:00
maxv
0b096b3626 ffs_superblock_validate(): check the size of cylinder groups. 2015-04-26 06:19:36 +00:00
maxv
459997491f Instead of duplicating code, create ffs_is_appleufs(): returns 1 if the
device is an AppleUFS FS, 0 otherwise.

This changes the behavior a bit: if the kernel cannot determine whether the
disk is an AppleUFS one or not, it now considers it as a normal UFS rather
than returning an error and not mounting/reloading it.

No particular comment on tech-kern@
2015-04-22 07:27:09 +00:00
maxv
795334fc6b ffs_superblock_validate(): ensure fs_ncg!=0 and fs_maxbpg!=0 to prevent
several divisions by zero.
2015-04-04 06:00:12 +00:00
maxv
6e39240181 Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
2015-03-28 19:24:04 +00:00
maxv
bb338d5f26 Remove the 'cred' argument from breadn(), and update the man page
accordingly.

ok hannken@
2015-03-28 17:23:42 +00:00
riastradh
5a2d83e099 Disentangle buffer-cached I/O from page-cached I/O in UFS.
Page-cached I/O is used for regular files, and is initiated by VFS
users such as userland and NFS.

Buffer-cached I/O is used for directories and symlinks, and is issued
only internally by UFS.

New UFS routine ufs_bufio replaces vn_rdwr for internal use.
ufs_bufio is implemented by new UFS operations uo_bufrd/uo_bufwr,
which sit in ufs_readwrite.c alongside the VOP_READ/VOP_WRITE
implementations.

I preserved the code as much as possible and will leave further
simplification for future commits.  I kept the ulfs_readwrite.c
copypasta close to ufs_readwrite.c in case we ever want to merge them
back; likewise ext2fs_readwrite.c.

No externally visible semantic change.  All atf fs tests still pass.
2015-03-27 17:27:55 +00:00
hannken
54fa474e3e Change ffs to use vcache_new:
- Change ffs_valloc to return an inode number.
- Remove now obsolete UFS operations UFS_VALLOC and UFS_VFREE.
- Make ufs_makeinode private to ufs_vnops.c and pass vattr instead of mode.
2015-03-17 09:39:29 +00:00
maxv
9eec611462 ffs_reload(): fix a bug that prevents Big Endian FSes from being reloaded.
'newfs' should be tagged as FS_SWAPPED, not 'fs'.

Was here before my changes.

While here, also KNF a bit.
2015-03-15 09:21:01 +00:00
maxv
a578b5382f ffs_superblock_validate(): ensure fs_ipg and fs_fpg are != 0. Otherwise
division by zero in several places.
2015-03-14 19:52:54 +00:00
maxv
18abcb4757 ffs_superblock_validate(): check the number of inodes per block. Otherwise
a malformed value could panic the system.
2015-03-10 12:59:32 +00:00
maxv
c84267386a ffs_reload(): release 'bp' earlier 2015-03-03 17:56:51 +00:00
maxv
e6e56ce208 ffs_reload(): the current implementation blindly guesses critical fields
of the superblock didn't change. Add checks to ensure they didn't change
for real. This prevents several memory corruptions.
2015-03-03 17:46:39 +00:00
maxv
5f9c472c31 Small changes:
- instead of always calling DPRINTF with __func__, put __func__ directly
   in the macro
 - ffs_mountfs(): rename fsblockloc -> fs_sblockloc, initialize fs_sbsize
   to zero
No real functional change
2015-02-23 13:38:54 +00:00