Commit Graph

1681 Commits

Author SHA1 Message Date
hannken
0bac62655e Change ntfs to vcache.
- Use (inumber, attrtype, attrname) as key.
- Inline ntfs_fget() and ntfs_frele() as they only get called once.
2014-11-13 16:51:53 +00:00
hannken
a26eea283a - Change ntfs_vgetex() to always load the ntnode and fnode.
- Take the vnode attributes from the NAME attribute.
- Remove now unused ntfs_times() and ntfs_filesize().
- Treat nodes without an unnamed DATA attribute as zero-sized regular files.
2014-11-13 16:51:10 +00:00
hannken
6f8e2ffe40 - Fix ntfs_ntlookupattr() to make the examples from the man page work.
- Fix ntfs_loadntnode() to always read full cluster to prevent buffer
  cache inconsistency.
- Change ntfs_vgetex() and ntfs_fget() to take a const attrname and
  always pass a possibly empty string.
- Change printf to dprintf.
- Get rid of dead fields i_next, i_prev of struct ntnode.
2014-11-13 16:49:56 +00:00
riz
28fe942ff2 Revert previous, it is actually needed. (builds are failing) 2014-11-10 19:44:08 +00:00
maxv
fcc99ce60e Do not uselessly include <sys/malloc.h>. 2014-11-10 18:46:33 +00:00
nakayama
bf71b4294d Fix vnode locking changes in rev.1.89:
- lock vnode by the end of cache_purge and vput.
2014-11-07 12:05:58 +00:00
manu
0c81f4b006 PUFFS direct I/O cache fix
There are a few situations where we must take care of the cache if direct
I/O was enabled:
- if we do direct I/O for write but not for read, then any write must
  invalidate the cache so that a reader gets the written data and not
  the not-updated cache.
- if we used a vnode without direct I/O and it is enabled for writing,
  we must flush the cache before compeling the open operation, so that
  the cachec write are not lost.

And at inactive time, we wipe direct I/O flags so that a new open without
direct I/O does not inherit direct I/O.
2014-11-04 09:14:42 +00:00
manu
17036f29cb Fix PUFFS node use-after-reclaim
When puffs_cookie2vnode() misses an entry, vcache_get()
creates a new node (puffs_vfsop_loadvnode being called to
initialize the PUFFS part), then it discovers it is VNON,
and tries to vrele() it. vrele() calls VOP_INACTIVE(),
which led us in puffs_vnop_inactive() where we sent a
request to the filesystem for a node that already had been
reclaimed.

The fix is to check for VNON nodes in puffs_vnop_inactive()
and to return without doing anyting. This is suboptimal, but
a better workaround would probably need to modify vcache API,
with an impact on other filesystems. Let us keep it simple.
2014-11-04 09:10:37 +00:00
manu
962cb9b884 Add PUFFS_HAVE_FALLOCATE in puffs_msgif.h so that filesystem can decide
at build time wether fallocate is usable
2014-10-31 14:20:54 +00:00
manu
78fa995d09 Add PUFFS support for fallocate and fdiscard operations 2014-10-31 13:52:41 +00:00
manu
ef586c84dd According to pooka@'s comment, a long time ago, VOP_STRATEGY could not
fail without taking down the kernel. It seems this is not the case anymore,
hence we can stop dropping errors in puffs_vnop_strategy()

Approved by pooka@
2014-10-31 13:51:33 +00:00
christos
2d22a4aaac Revert previous; it does not work with COMPAT_BSDPTY, screen(1) fails because
it does a TIOCPTSNAME immediately after opening ptmx and finds an old style pty.
2014-10-21 16:05:01 +00:00
snj
f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
christos
14b4a4b149 From Ilia Zykov:
- correct some incorrect comments
- add XXX warning
- increase security by activating when get the slave
- make pty_vn_open() private to tty_ptm.c
2014-10-15 15:00:03 +00:00
hannken
668c7daae4 Change nilfs to vcache. 2014-10-15 09:05:46 +00:00
hannken
52473f33d5 Prepare nilfs for vcache:
- Calling getnewvnode() with "mp == NULL" is wrong.  Stop attaching a
  vnode to system file nodes and change nilfs_bread() to translate
  the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
  nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
  a nilfs node with locked vnode.  Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
  return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.
2014-10-15 09:03:53 +00:00
uebayasi
fe9a32c84e Define filesystem attributes with vfs dependency. 2014-10-11 06:42:18 +00:00
he
89a215e851 Do the previous correctly... 2014-10-07 12:58:09 +00:00
he
d01de6e07a As is evidenced by several of our 32-bit MIPS ports, it's wrong to
print vsize_t with PRIx64 -- instead use our own PRIxVSIZE macro.
2014-10-07 11:37:06 +00:00
he
60c92b53ed Make this build again without debugging enabled; DPRINTF() can end up
as empty, and in an if conditional, you then need braces if that's the
only potential body.
2014-10-06 14:26:44 +00:00
manu
4cb6f55f7a Retore LP64 fix that was removed by mistake 2014-10-06 09:05:55 +00:00
manu
0671358a48 Improve zero-fill of last page after shrink fix:
1) do it only if the file is open for writing, otherwise we send write
requests to the FS on a file that has never been open.
2) do it inside existing if (vap->va_size != VNOVAL) block
2014-10-06 04:41:59 +00:00
apb
15239241e8 Add close brace, accidentally omitted from previous change. 2014-10-05 20:40:46 +00:00
apb
f1dbec9add Safer definitions of DPRINTF and DPRINTF_VERBOSE.
In the PUFFSDEBUG case, wrap do { ... } while (/*CONSTCOND*/0)
around the definitions.  In the non-PUFFSDEBUG case, define them
as ((void)0) instead of as empty.
2014-10-05 14:13:14 +00:00
justin
bc648e4794 Use PRIx64 for printing offsets 2014-10-05 09:28:24 +00:00
manu
2a5ce25ed0 If we truncate the file, make sure we zero-fill the end of the last
page, otherwise if the file is later truncated to a larger size
(creating a hole), that area will not return zeroes as it should.
2014-10-05 07:53:22 +00:00
hannken
e716e7d8d6 Change filecore to vcache.
Compile-tested only, was not able to get my hands on a readable fs image.
2014-10-04 13:27:24 +00:00
hannken
f401fa494c Fix the puffs_sop_thread -> puffs_cookie2vnode path:
- pass the cookie by reference
- add missing mutex_exit()
- update assertion for VNON typed vnodes
2014-09-30 10:15:03 +00:00
reinoud
ef40ac265a Fix bug introduced in last patch 2014-09-17 21:18:43 +00:00
reinoud
79652a00ee As pointed out by wiz@ prevent a possible attack or corruption that results in
an endless loop of indirect descriptors being processed.

The number of indirect descriptors followed is now maximized.
While here, also fix a use-after-free bug!
2014-09-17 19:47:05 +00:00
manu
209370b3d8 PUFFS fixes for size update ater write plus read/write sanity checks
- Always update kernel metadata cache for size when writing
  This fixes situation where size update after appending to a file lagged
- Make read/write nilpotent when called with null size, as FFS does
- Return EFBIG instead of EINVAL for negative offsets, as FFS does
2014-09-11 07:59:14 +00:00
gson
1b265e6701 Store symlinks without a NUL terminator so that lstat(2) returns the
correct length.  Fixes the tmpfs part of PR kern/48864.
2014-09-08 14:49:46 +00:00
manu
08a33828ae When changing a directory content, update the ctime/mtime in kernel cache,
otherwise the updated ctime/mtime appears after the cached entry expire.
2014-09-05 15:39:18 +00:00
matt
82ef6ef7b8 Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
2014-09-05 09:26:16 +00:00
matt
2b8e56db05 Don't use C++ class and this keywords as variables. 2014-09-05 05:39:52 +00:00
martin
3c93e210ff Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
2014-09-01 09:09:47 +00:00
hannken
accb62aedc Change puffs from hashlist to vcache.
- field "pa_nhashbuckets" of struct "puffs_kargs" becomes a no-op.
  and should be removed on the next protocol version bump.
2014-08-28 08:29:50 +00:00
maxv
5f2f7d8e15 Remove dead returns:
return VAR/func(XX);
	return VAR;

The latter is never reached. Sent on tech-kern@, no disagreement.
2014-08-21 06:40:35 +00:00
manu
7642144c05 Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.
2014-08-16 16:19:41 +00:00
hannken
b041904f72 Needs HASH_SLIST, not HASH_LIST. 2014-08-16 07:22:30 +00:00
hannken
912cfee7bf Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
2014-08-15 13:40:39 +00:00
maxv
b0e4602c25 Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
2014-08-14 14:06:53 +00:00
hannken
2607f151da - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
2014-08-13 14:10:00 +00:00
maxv
10b6c96ec4 http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-2
#04-0x01: Uninitialized var 'rqp' (does not compile anyway)
2014-08-12 06:57:20 +00:00
hannken
265f1d8cdb Change hfs from hashlist to vcache.
- use (cnid, fork) as key.
- use pool for hfs nodes.
2014-08-10 08:53:22 +00:00
gson
f3b28c737c Whitespace fix 2014-08-08 19:14:45 +00:00
hannken
5d6be57d01 Change efs from hashlist to vcache. 2014-08-07 08:24:23 +00:00
hannken
ea4bd7d40f Change adosfs from hashlist to vcache.
- point ap->block to real file header block for hard links.
2014-08-05 08:50:54 +00:00
reinoud
e3b6b3457e Posix requires the va_size of a symlink to be pathlength for symbolic links.
This fixes yet another atf case.
2014-07-29 15:48:22 +00:00
reinoud
60e6f474d5 Fix debug printout of udf_write_metadata_partition_spacetable(), it referred
to an old variable.
2014-07-29 15:36:43 +00:00
reinoud
a72b8dae23 Access time should only be set on accessing the data or messing with the
contents, not on inode access rights and ownership changes. Should address
PR kern/49033 for UDF.

Test results now come clean for bugs related to this issue in the ATF.
2014-07-29 11:10:12 +00:00
dholland
05d075b3ae Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.
2014-07-25 08:20:51 +00:00
maxv
549e231932 Make DPRINTF more understandable, and replace my previous #ifdef DIAGNOSTIC... 2014-07-18 17:24:34 +00:00
maxv
8ee3c88d2b Limit the minimum size of a disk sector to 512 bytes, to prevent memory
overflow on extremely low secsize. This normally conforms to the old standard
(for which there doesn't seem to be a clear spec). Since 2011, IDEMA's Advanced
Format standardizes it to 4k, so this change won't cause any trouble on
new devices.

Put the printf under DIAGNOSTIC temporarily to see if someone complains.

after a quick discussion on tech-kern
2014-07-16 20:09:00 +00:00
christos
c0371c86f3 Correct the bread size of struct fsinfo from Gerald Lee at DELL dot com 2014-07-15 11:43:54 +00:00
maxv
409868ac4b smbfs depends on nsmb, so add the dependency as appropriate. Fixes
# modload smbfs
on modular kernels, PR kern/40011, and probably system crashes.
2014-07-14 16:29:50 +00:00
maxv
56ce0b03bc Minor changes:
- malloc()+memset() -> malloc(|M_ZERO)
 - rename 'vers' to 'FSVers'
 - declare 'ExtFlags' instead of calling getushort() two times
2014-07-09 09:00:18 +00:00
maxv
8fce630b04 Remove ROOTNAME (unused). 2014-07-09 08:43:54 +00:00
maxv
1273c3cb8c - Perform sanity checks not just for GEMDOSFS, but for all FAT devices. This
also fixes a division-by-zero bug that could crash the system.
- Define GEMDOSFS_BSIZE instead of a hard-coded 512 value, and remove 'bsize'.
- Rename 'tmp' to 'BlkPerSec'.

From me, FreeBSD, OpenBSD and the FAT specification.

ok christos@
2014-07-08 19:34:47 +00:00
hannken
798256c9ef Change msdosfs from hashlist to vcache:
- Use (dir_cluster, dir_offset, dir_generation) as key, where
  dir_generation is non-zero and unique for unlinked but open nodes.
- Change deget() to return a vnode as it is unsafe to return a
  referenced but unlocked denode.
2014-07-08 09:21:52 +00:00
hannken
4f7c01f703 CID 1223346: No need to check bp against NULL. It is always valid here. 2014-06-22 09:47:40 +00:00
hannken
11b42c4183 Unlock directory vnode after VOP_CREATE. 2014-06-17 12:38:12 +00:00
hannken
69110c4ec6 Change cd9660 from hashlist to vcache. 2014-06-16 09:55:49 +00:00
hannken
605674c009 Remove the hints "isodir" and "relocated" from cd9660_vget_internal()
and always reread the directory entry by inumber.  For directories
the directory entry is always its "." entry.

Always read directories via the device vnode to prevent buffer cache
inconsistency.  Keep i_devvp as a hint for fstat(1) and friends and
always use im_devvp for reads.  No need to vref()/vrele() i_devvp.

The additional bread is either cached because cd9660_lookup() just
released the buffer or will be used in the near future when the
directory gets traversed during lookup.

No objections on tech-kern@
2014-06-14 07:39:28 +00:00
pooka
a98adcf8d6 use psize_t for physical memory calculation 2014-06-13 11:57:48 +00:00
martin
b7650b1af5 Check for invalid mount arguments early and gracefully fail the mount.
Spotted by pooka@
2014-06-10 16:10:59 +00:00
martin
269c704651 Make sure to expand "freepages" to 64bit before shifting to byte values -
on rump we may have all our virtual address space "free".
Pointed out by pooka@.
2014-06-10 15:44:27 +00:00
martin
c7dd06b6bb Remove the hardcoded 4 MB free kernel memory limit and replace it
by uvmexp.freetarg, as discussed on tech-kern.
Main purpose is to make tmpfs usable (as far as possible) on small memory
machines.
This is a bit experimental, but we need to give it some real world exposure
to see how well it works.
2014-06-07 09:54:34 +00:00
joerg
11581dcbbb Introduce two helper functions to centralise the namecache statistics
in vfs_cache.c. Use consistent locking around the per-cpu data.
2014-06-03 19:30:29 +00:00
martin
755f765c3a PR kern/48815: do not skip ';' twice when comparing file versions.
Patch from Thomas Schmitt.
2014-06-01 11:01:18 +00:00
hannken
de57916f59 msdosfs_reclaim(): add missing fstrans and protect change
of v_data with v_interlock as msdosfs_sync() now needs it.
2014-05-30 08:42:35 +00:00
rmind
ce079fc9c0 tmpfs_mknod: it is not our responsibility to call vput() on the directory
vnode, so remove it (and ensure *vpp is NULL while here).
2014-05-26 19:12:07 +00:00
christos
202570e1e0 use macro. 2014-05-25 19:33:28 +00:00
christos
50f00297b4 use standard dirty vnode test. 2014-05-25 19:32:36 +00:00
hannken
e03668ca99 The pageflush_selector gets a vnode with v_interlock held.
Remove the mutex_enter()/mutex_exit() and simplify.

Hi christos...
2014-05-25 17:43:47 +00:00
christos
02cb0c6eaf Introduce a selector function to the vfs vnode iterator so that we don't
need to vget() vnodes that we are not interested at, and optimize locking
a bit. Iterator changes reviewed by Hannken (thanks), the rest of the bugs
are mine.
2014-05-24 16:34:03 +00:00
dholland
8e1257d82c Also set or assert that *vpp is null before calling VOP_MKDIR. 2014-05-17 04:07:15 +00:00
dholland
3955d2067a Set *vpp to NULL before calling VOP_CREATE. This always happens when
calling using nameidata, and if not something went wrong, so we'd like
to be able to assert about it.
2014-05-17 04:03:49 +00:00
martin
3638eee882 PR kern/48799: make filehandles properly use 64bit inodes on CD9660 file
systems. Patch from Thomas Schmitt, with slight modifications.
2014-05-13 17:05:26 +00:00
martin
b31205ebbb PR kern/48787: inode calculation from ISO9660 block offset might get
truncated to 32bit - force the whole expression to be evaluated as ino_t.
Patch from Thomas Schmitt, with minor modifications (and reworded comment).
2014-05-10 14:11:58 +00:00
christos
71fd41685f fix typo 2014-04-30 01:59:30 +00:00
christos
0172bc970f handle MNT_UPDATE 2014-04-30 01:33:51 +00:00
pooka
45fe388485 Don't lock an already locked vnode. 2014-04-25 15:18:06 +00:00
maxv
23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
jakllsch
6d9f89fe00 Use size_t instead of int for character count to avoid sign compare issues. 2014-04-06 19:25:22 +00:00
christos
c636575468 Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
2014-04-04 18:10:29 +00:00
christos
4d87c37c1f forgot to commit one patch:
Avoid returning released(free), but still hashed inode numbers.
(Ilya Zykov)
2014-03-27 21:13:06 +00:00
christos
a9253db65e From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
  dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
2014-03-27 17:31:56 +00:00
christos
9b453fe1d0 if one of the ptyfs instances has grabbed the handle don't grab it again,
Ilya Zykov
2014-03-26 21:28:48 +00:00
christos
66873a203c kill sprintf. 2014-03-25 16:30:28 +00:00
hannken
f3cf481632 - Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add  vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
2014-03-24 13:42:40 +00:00
dholland
37ec3a866f Tidy up locking in cd9660_mount; thrash the lock less, and make it
clear that the lock is only dropped when calling iso_mountfs().

While here, don't use the vnode pointer's value after vrele().
2014-03-24 04:03:25 +00:00
hannken
6d285189fb Change all vfsops to use C99 designated initializers.
No functional changes intended.
2014-03-23 15:21:15 +00:00
christos
0f18888b15 fix unused 2014-03-23 09:30:59 +00:00
christos
74758fe57e Ilya Zykov: Prepare readdir for multi-mountpoint use 2014-03-21 17:21:53 +00:00
christos
bf11f52a36 - return an error if we could not get the pts pathname
- correct getting pathname if the mount point inside a chroot
(Ilya Zykov)
2014-03-19 18:09:00 +00:00
hannken
fcb1d82829 Change smbfs_sync() to use vfs_vnode_iterator. 2014-03-17 09:37:09 +00:00
hannken
f9d8c5c8e8 Change pageflush() to use vfs_vnode_iterator. 2014-03-17 09:36:34 +00:00
hannken
b1e067f299 Change msdosfs_sync() to use vfs_vnode_iterator. 2014-03-17 09:35:59 +00:00
hannken
5e8d36ac30 Restructure union_lock() to always lock before testing for dead node.
Add two little helpers to lock or unlock a node.  Use "vp" for the
union node and "lockvp" for the node to be locked.  Use ISSET() to
test flags, add assertions.
2014-03-12 09:40:05 +00:00