Commit Graph

1311 Commits

Author SHA1 Message Date
manu 96c935e33b Add a mutex for operations that touch size (setattr, getattr, write, fsync).
This is required to avoid data corruption bugs, where a getattr slices
itself within a setattr operation, and sets the size to the stall value
it got from the filesystem. That value is smaller than the one set by
setattr, and the call to uvm_vnp_setsize() trigged a spurious truncate.
The result is a chunk of zeroed data in the file.

Such a situation can easily happen when the ioflush thread issue a
VOP_FSYNC/puffs_vnop_sync/flushvncache/dosetattrn while andother process
do a sys_stat/VOP_GETATTR/puffs_vnop_getattr.

This mutex on size operation can be removed the day we decide VOP_GETATTR
has to operated on a locked vnode, since the other operations that touch
size already require that.
2011-08-29 04:12:45 +00:00
hannken 8dc51ab7d8 Print the warning message on mount once.
Should fix PR #42795 (patch to make mounting union filesystems less obnoxious)
2011-08-28 08:27:57 +00:00
hannken f68873a343 Finish and enable whiteout support for tmpfs:
- Enable VOP tmpfs_whiteout().
- Support ISWHITEOUT in tmpfs_alloc_file().
- Support DOWHITEOUT in tmpfs_remove() and tmpfs_rmdir().
- Make rmdir on a directory containing whiteouts working.

Should fix PR #35112 (tmpfs doesn't play well with unionfs).
2011-08-27 15:32:28 +00:00
hannken f937bd97b7 Stop abusing relookup() to prepare the creation of new nodes
in the upper layer.
Replace union_relookup() with union_do_lookup() that prepares
a component, calls VOP_LOOKUP() and does the EEXIST test.
2011-08-23 07:39:37 +00:00
riastradh b4d52ac6e6 Fix tmpfs_rename locking.
Fixes PR kern/36681.  tmpfs now survives dirconc, all our vfs/tmpfs
tests and rename races in atf, and a bunch of hand-written tests
that I'd commit if atf didn't find them highly indigestible.

ok dholland
2011-08-18 21:42:18 +00:00
mbalmer 0813ba11d0 Fix some typos. 2011-08-16 14:29:16 +00:00
apb 464d645aeb Rename all static functions to have "v7fs_" prefix. Fixes a problem
in the tools build, where the static link() and unlink() functions
conflicted with those declared in <unistd.h>.
2011-08-14 09:02:07 +00:00
hannken 1147247693 Use mutexes to protect the hash lists instead of tsleep/wakeup. 2011-08-13 10:48:14 +00:00
hannken 94fc281af2 Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.

No functional changes intended.
2011-08-12 17:41:17 +00:00
hannken b8e5efdc84 Add missing parts to mount devices from a union file system:
- union_close()    has to lock/unlock the lower vnode.
- union_fsync()    has to call spec_fsync() for the union vnode.
- union_strategy() must allow writes to devices on the lower file system.
- union_bwrite()   was completely missing.
2011-08-12 14:36:29 +00:00
hannken 7b19d6d068 When creating a union node representing a device initialize
the spec_node to make vrele() happy.
2011-08-12 06:40:10 +00:00
hannken 3ec6312958 Update the (shared) v_interlock if the upper node changes. 2011-08-10 15:56:01 +00:00
hannken b80057eeb2 For devices, sockets and fifos ignore setting the file size to zero to make
open(..., O_TRUNC) happy and allow them to write through the lower layer.

Fixes PR #43560 (writing to null device in unionfs fails)
2011-08-10 06:27:02 +00:00
hannken 9be6a4a9b4 Use LK_SHARED, it is sufficient for VOP_GETATTR() and VOP_READDIR(). 2011-08-10 06:19:54 +00:00
uch f2404aeb3c Remove suspicious warning message. 2011-08-08 11:42:30 +00:00
hannken 342315ffad Change union rmdir semantics to fail directory removal for
non-empty directories like all other file systems do.

Change test accordingly.
2011-08-07 06:01:51 +00:00
hannken efc3d2ec25 When union_lookup() creates a shadow directory and nameiop is not LOOKUP
it has to restart the lookup to get the componentname right.

Fixes PR #44383 (an endless stream of whiteout and opaque dir problems ...)
2011-08-05 08:17:47 +00:00
dholland 66d63879a2 Insert casts to off_t to avoid 32-bit multiplication overflow when
computing device offsets on 32-bit platforms. Should fix PR 45191.
2011-08-03 16:21:52 +00:00
uch b53b51d13e v7fs_lookup() fix return value. Pass t_vnops rename_dir(3)
v7fs_setttr() check credential. Pass t_unpriv owner
v7fs_rename() reload inode(v7fs_vnode_reload). Pass t_vnops rename_reg_nodir
2011-07-30 03:53:18 +00:00
uch 53172ceae2 When rename directory, check hierarchy. Pass t_vnops rename_dir(5) 2011-07-30 03:52:04 +00:00
uch cba32d8fa9 Fix return vaule. Pass t_vnops:rename_dotdot, dir_noempty, rename_dir(6) 2011-07-30 03:51:53 +00:00
uch fbcb953c8f Existing inode don't recycle. rump works. 2011-07-24 12:31:33 +00:00
uch 803c773c57 remove partition check from v7fs_mount. problem on rump implementation. 2011-07-23 05:10:30 +00:00
hannken 9f9c02f1cd Even though msdosfs never truncates file names it advertises _PC_NO_TRUNC
as zero.  Make it advertise one (no_trunc == true).

Names longer than NAME_MAX (255) will never pass namei() btw.

Fixes PR #43670 (msdosfs claims support for filenames longer than {NAME_MAX},
                 but fails)
2011-07-20 11:52:00 +00:00
apb f1ca1ce2bf In sources that get compiled into the tools version of makefs, add:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif

This should fix cross-build problems, but I can't really test
that now, so I am not re-enabling the inclusion of v7fs support
in makefs.
2011-07-18 21:51:49 +00:00
joerg 3eb244d801 Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
2011-07-17 20:54:30 +00:00
uch 6a2dbe9ae4 core symlink operation moved to v7fs_file_util.c and introduce V7FSBSD_MAXSYMLINKLEN for makefs 2011-07-16 12:35:40 +00:00
uch f96feeccb7 export v7fs_datablock_addr for makefs 2011-07-16 12:35:32 +00:00
njoly 8b2b6e057f Add function name to a few debug messages. 2011-07-13 19:51:29 +00:00
uch fa2ab7e4a5 Fix readdir eofflag(bogus eofflags was setted). getcwd works. 2011-07-13 12:28:57 +00:00
uch 7572a219c6 Fix inode update method. chown and chmod works. 2011-07-13 12:22:49 +00:00
uch 709aeb1f3a When filesize is zero, correctly return V7FS_ITERATOR_END 2011-07-13 12:18:22 +00:00
riastradh e203e3912f Fix renaming over mismatched non-directory types in tmpfs.
Renaming a file of any non-directory type over another file of any
other non-directory type is OK -- they need not match as long as
neither is a directory, so loosen the kassert to reflect this.

XXX Need to write test cases for this.

ok dholland, rmind
2011-07-13 03:28:41 +00:00
reinoud b2a0605256 English checked and corrected, courtisy of
Igor Sobrado <sobrado@orion.ciencias.uniovi.es> as noted in OpenBSD that has a
copy of this file.
2011-07-07 17:45:38 +00:00
manu be95d60797 Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.

There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
  extattr_list_file(2), which is obtanined by setting the
  EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)

This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
2011-07-04 08:07:29 +00:00
mrg 2624874e7c avoid some uninitialised variable warnings from GCC.
at least the puffs one seems valid, but i'm not 100% sure.
2011-07-03 08:57:43 +00:00
uch e8e84f5a1b Set missing error number 2011-07-02 01:05:38 +00:00
wiz 4cbd24b23f dependant -> dependent 2011-06-30 20:09:15 +00:00
enami d281b75f90 Backout previous. May be I need more coffee. 2011-06-30 00:37:07 +00:00
enami 7a1a5c2e85 - Use << PAGE_SHIFT rather than calling round_page again.
- No need to call uao_dropswap_range() here since uao_dropswap()
  is already called for each pages by uvm_vnp_setsize().
2011-06-30 00:09:26 +00:00
uch 9255b46fb4 7th Edition(V7) File System support. and NetBSD symbolic-link, socket, FIFO extension. see newfs_v7fs(8). 2011-06-27 11:52:22 +00:00
rmind 7083a919fc - Fix a silly bug: remove umap from uobj in ubc_release() UBC_UNMAP case.
- Use UBC_WANT_UNMAP() consistently.

ARM (PMAP_CACHE_VIVT case) works again.
2011-06-19 02:42:53 +00:00
hannken d296304e60 Rename uvm_vnp_zerorange(struct vnode *, off_t, size_t) to
ubc_zerorange(struct uvm_object *, off_t, size_t, int) changing
the first argument to an uvm_object and adding a flags argument.

Modify tmpfs_reg_resize() to zero the backing store (aobj) instead
of the vnode.  Ubc_purge() no longer panics when unmounting tmpfs.

Keep uvm_vnp_zerorange() until the next kernel version bump.
2011-06-16 09:21:02 +00:00
rmind e225b7bd09 Welcome to 5.99.53! Merge rmind-uvmplock branch:
- Reorganize locking in UVM and provide extra serialisation for pmap(9).
  New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
  the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
  Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
  kernel-lock on some ports).  Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
2011-06-12 03:35:36 +00:00
rmind 14a6291ecb Remove few references to simple_lock. 2011-06-09 02:59:22 +00:00
rmind 4cffafacf2 - tmpfs_getattr: perform tmpfs_update() before fetching the timestamps.
- tmpfs_rmdir: detach after tn_links decrement, so that correct event
  i.e. NOTE_DELETE would be trigerred.
2011-05-30 19:22:44 +00:00
rmind 9976e82537 Fix non-DEBUG build. 2011-05-29 22:43:32 +00:00
rmind 4781942ccb - Rework and document inode reference counting. Also document inode life
cycle (destruction part).  Perform link counting in tmpfs_dir_attach()
  and tmpfs_dir_detach(), instead of alloc/free and arbitrary places.
  Fixes PR/44285, PR/44288, PR/44657 and likely PR/42484.

- Fix the race between the lookup and inode destruction.  Fixes PR/43167
  and its duplicates PR/40088, PR/40757.

- Improve tmpfs_rename() locking a little, fix kqueue event notifications
  and also fix PR/43617.  Add simplistic tmpfs_parentcheck_p(); to be
  expanded and used for further rename() locking fixes.

- Cache directory entry "hint" in the tmpfs node, add tmpfs_dir_cached(),
  and thus avoid unnecessary lookup in tmpfs_remove() and tmpfs_rmdir().

- Set correct _PC_FILESIZEBITS value in tmpfs_pathconf().  Fixes PR/43576.

- Few minor fixes.
2011-05-29 22:29:06 +00:00
christos 662aaad8a2 undo the multiple inclusion protection part. 2011-05-29 01:14:31 +00:00
rmind 8a0123cd33 - Prevent tmpfs.h from inclusion in userland.
- Clean up and KNF tmpfs.h a little bit.
2011-05-29 01:00:50 +00:00