Commit Graph

2219 Commits

Author SHA1 Message Date
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
riastradh
46e71c7d57 Make VOP_LINK return directory still locked and referenced.
Ride 7.99.10 bump.
2015-04-20 22:59:19 +00:00
riastradh
9368a7f9c7 Fix more dvp->v_mount after vput(dvp). 2015-04-20 21:02:49 +00:00
riastradh
f6139440c5 Make vget always return vnode unlocked.
Convert callers who want locks to use vn_lock afterward.

Add extra argument so the compiler will report stragglers.
2015-04-20 13:44:16 +00:00
riastradh
8f010f576c Release the glock on VOP_GETPAGES failure.
Tripped over by nick@'s failing disk, missing unlock in error branch
discovered by jmcneill@.
2015-04-15 14:39:24 +00:00
riastradh
adada8d6d4 Strip IO_JOURNALLOCKED, PGO_JOURNALLOCKED out of ulfs_readwrite.c.
These are vestigial from ufs_readwrite.c with wapbl -- lfs does not
have a journal but only the explicit wapbl calls, not these flags,
got ripped out in the transition to ulfs_readwrite.c.
2015-04-12 22:51:23 +00:00
riastradh
edcd087bc1 Same putpages->kassert in ulfs_readwrite.c 2015-04-12 22:49:55 +00:00
riastradh
0e4f519ef4 Omit now-unused variable. rump build didn't catch this... 2015-04-12 22:48:38 +00:00
riastradh
3124f8f989 Don't putpages in ufs buffercached writes: kassert there are none. 2015-04-12 22:41:28 +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
riastradh
7153b8dc81 Don't use dvp after vput(dvp).
Still don't understand why the fstrans_done must happen after the
vput, and that will cause trouble once we move responsibility for the
vrele and unlock outside the vop as it seems obvious we ought to do
-- it's the caller's reference, not the vop's.
2015-04-01 20:03:11 +00:00
riastradh
24895d95c1 Amplify that even if we fixed it now the tentacles are still stuck. 2015-03-31 11:43:05 +00:00
riastradh
e9f7453834 Write an essay explaining why ffs_write is one huge WAPBL transaction. 2015-03-31 00:22:50 +00:00
riastradh
cec9a597e4 WAPBL tx is always locked by ufs_bufrd caller, so never unlock it. 2015-03-29 14:39:41 +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
riastradh
a9b674d150 Let I/O errors override inode update errors in UFS.
Fixes tests/fs/vfs/t_io:read_fault for UFS.
2015-03-28 17:45:47 +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
ec4019718c Make some comments match better in ulfs_readwrite. 2015-03-28 17:08:53 +00:00
riastradh
dd74d7b4d4 Factor out post-read/write inode updates in UFS. 2015-03-28 17:06:15 +00:00
riastradh
2cd2eda401 VOP_WRITE never has IO_JOURNALLOCKED. 2015-03-28 04:13:25 +00:00
riastradh
bc2fbd02f8 Turn some `#if DIAGNOSTIC' into KASSERT. 2015-03-28 03:53:36 +00:00
riastradh
3b1b197e15 Missed another spot, in ext2fs_write. 2015-03-28 03:49:41 +00:00
riastradh
7acf502e35 Missed a spot in ext2fs_read 2015-03-28 03:46:51 +00:00
riastradh
8e1eba1ebe Tighten some kasserts in ufs_bufio code paths. 2015-03-27 19:47:14 +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
5c7e714fca Hum. Perhaps I missed a bit of the specification. Let's not be that
severe when checking the superblock.

Should fix ATF.
2015-02-23 17:05:58 +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
maxv
3e35936473 Merge _sbcompute() and _sbcheck() into _sbfill().
In ext2fs_sbfill(), check more fields of the superblock, to prevent
several kernel panics when mounting/unmounting a disk.
2015-02-22 14:55:23 +00:00
maxv
81c691b934 ffs_superblock_validate(): sanitize fs_fragshift, fs_bmask and fs_fmask. 2015-02-22 14:22:34 +00:00
maxv
8cadf998b5 KNF, and simplify a bit.
No functional change
2015-02-22 14:12:48 +00:00
maxv
ea17f38b73 Several fixes:
- rename ext2fs_checksb() -> ext2fs_sbcheck(): more consistent
 - in ext2fs_sbcheck(), add a check to ensure e2fs_inode_size!=0,
   otherwise division by zero
 - add ext2fs_sbcompute(), to compute dynamic values of the superblock.
   It is done twice in _reload() and _mountfs(), so put it in a function.
 - reorder the code in charge of loading the superblock: now, read the
   superblock, swap it directly, and *then* pass it to ext2fs_sbcheck().
   It is similar to what ffs now does. It is better since the fields don't
   need to be swapped on the fly in ext2fs_sbcheck().
Tested on amd64.
2015-02-20 17:44:54 +00:00
maxv
afc7ff8c74 Style, and fix a DPRINTF
No functional change
2015-02-20 17:10:17 +00:00
maxv
18daf27dfc e2fs_sbcheck(): add a check to ensure e2fs_bpg!=0. Otherwise the kernel
panics with a division by zero.

While here, remove the #ifdef's.
2015-02-19 21:31:44 +00:00
maxv
12c9fae830 Revert a change in my previous commit that broke the checksum calculation.
Noted by dholland@
2015-02-15 11:04:43 +00:00
maxv
f2f615bb86 ffs_superblock_validate(): when checking the number of frag blocks, also
make sure it matches fs->fs_frag. This also prevents an infinite loop if
fs->fs_frag=0.
2015-02-14 13:43:28 +00:00
maxv
cba38714c3 ffs_superblock_validate(): compute fs_bshift and fs_fshift, and ensure
they are consistent with what is indicated in the superblock. This allows
us to safely use some ffs_ macros.
2015-02-14 10:21:29 +00:00
maxv
7fcc4ddf11 In fact, we need to sanitize the superblock *after* swapping it. Therefore,
move the swap code inside the loop.

'fs->fs_sbsize' is swapped twice: the first time in order to get the
correct superblock size, and later when swapping the whole superblock
structure. As a result, we need to check 'fs->fs_sbsize' twice.

This:
 - fixes my previous changes for swapped FSes
 - allows the kernel to look for other superblock locations if the
   current superblock is not validated

And now:
 - ffs_superblock_validate() takes only one argument: the fs structure
 - 'fs_bsize' is unused, so delete it

Add some comments to explain a bit what we are doing.
2015-02-14 09:55:53 +00:00
maxv
a42dfe11dc Two typos:
- "preferrably" -> "preferably"
 - "overriden" -> "overridden"
No functional change.
2015-02-14 09:06:11 +00:00
maxv
dd5da7d8bc ffs_superblock_validate(): sanitize the number of frag blocks. 2015-02-14 09:00:12 +00:00
maxv
4d2092869c ffs_appleufs_validate():
- remove superfluous printfs
 - ensure ul_namelen!=0, otherwise the kernel accesses ul_name[-1] and
   overwrites the previous field in the structure.
2015-02-14 08:07:39 +00:00
maxv
55a23d9c1d KNF. No functional change. 2015-02-14 07:56:31 +00:00
maxv
e54cf2b426 Currently, in ffs_reload(), we don't handle the possibility that the
superblock location may have changed. But that implies that we don't
handle the possibility that its size may have changed either.

Therefore: add a check to ensure the size hasn't changed. Otherwise the
mismatch leads to a memory corruption with kmem.
2015-02-14 07:41:40 +00:00
maxv
8f21e79caf Style. No functional change. 2015-02-14 07:20:11 +00:00