Commit Graph

106 Commits

Author SHA1 Message Date
manu 8abab6b782 Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.
2015-02-15 20:21:29 +00:00
manu 575ae72270 Fix atime update
FUSE filesystems assume that SETATTR with atime is the result of utiimes()
being called. As a result, atime and mtime will be updated.  This happens
with MooseFS and glusterFS. atime is supposed to be updated by the
filesystem itself when it gets read operations.

We fix the problem in SETATTR operations by
1) do not create a mtime update when we have an atime update (and vice
   versa), just fill the fields to avoid the filesystem restting the
   missing field to Epoch, but do not pretend we want to update it.
2) If the change is limited to atime, iscard it, as updates should be
   done by READ operations
3) Kernel part of PUFFS has been fixed to make sure reads on empty file
   are sent to the filesystem:
   http://mail-index.netbsd.org/source-changes/2015/01/13/msg062364.html

Thanks to Tom Ivar Helbekkmo for reporting this issue.
2015-01-13 16:51:30 +00:00
manu efbefee25c Allow setxattr to be called with a NULL value, instead of crashing. 2014-11-12 05:08:43 +00:00
manu ec8879c99e Restore build with -DDEBUG, and avoid a spurious diagnostic error with -DDEBUG 2014-11-04 09:17:31 +00:00
manu 25834497bf Avoid deadlocks on write errors
On write errors, we failed to dequeue some operations, leading to
rare but unpleasant deadlocks
2014-10-31 15:20:08 +00:00
manu 6645d5252e FUSE fallocate support
There seems to be no fdiscard FUSE operation at the moment, hence that one
is left unused.
2014-10-31 15:12:15 +00:00
manu 94c72edb04 Fix invalid free in deletextattr FUSE handler
Do not free FUSE message on error as it was not allocated.
2014-10-28 16:54:11 +00:00
manu f14b589944 Report allocated bytes on FS correctly, instead of using file size
(which is wrong for sparse files)
2014-10-11 04:19:38 +00:00
manu 95e87e4336 Do not trust the filesystem's readdir to give us nul-terminated file names 2014-09-30 00:06:19 +00:00
manu e6dc4d2455 Avoid a file resize serialization deadlock when writing with
PUFFS_IO_APPEND flag. The symptom was a hang when appending to
a file with a null size.
2014-09-11 04:05:52 +00:00
manu 4f16513e03 rmdir dir/.. must return an error. Use ENOTEMPRY like FFS does. 2014-09-05 15:20:16 +00:00
enami 21a900455a Fix build failure on amd64. 2014-09-03 23:59:58 +00:00
manu bcfebaff94 Improve POSIX compliance of FUSE filesystems through PERUSE
- access denied is EPERM and not EACCES
- access to file owned by someone else in a sticy-bit directory should
  be allowed for the sticy-bit directory owner
- setting sticky-bit on a non directory should produce EFTYPE
- implement PATHCONF method as much as we can.
2014-09-03 16:01:45 +00:00
manu 38582b4fe4 We used to remove the trailing zeros in FUSE readlink replies, but
it seems it does not always happen. Just remove them if present.
2014-08-29 04:58:40 +00:00
manu fb724fffd1 Remove usless warning that happens often with direct IO 2014-08-19 15:29:14 +00:00
manu beafd5bc7c Removed unimplemented mmap and seek method. seek's declaration caused
seek request to be passed backand forth between kernel and userland
while we did nothing about them.
2014-08-16 16:31:15 +00:00
manu 781f78b809 Use just introduced open2 PUFFS method and its PUFFS_OPEN_IO_DIRECT oflag
to implement FUSE's OPEN_IO_DIRECT, by which the filesystem tells the kernel
that read/write to the file should bypass the page cache.

Remove a warning about read beyond EOF which will now normally appear when
page cache is bypassed.
2014-08-16 16:28:43 +00:00
manu ac7134332d - Make sure non root users cannot access system namespace attributes
- honour namespace specification when listing attributes
- Also fix message memory leak introduced by previous commit
2014-08-10 03:22:33 +00:00
manu 6a9d039fd1 getextattr: fix attribute length being reported to caller. If buffer
is too small, return ENORANGE.

Caught by glusterFS regression tests
2014-08-09 19:06:50 +00:00
manu 4bef47b350 Send GETATTR to filesystem for removed but still-open files, as
it is the expected behavior (bug caught by glusterFS regression tests)
2014-08-09 03:17:11 +00:00
manu b76d3b3fa5 For filesystems mounted without -o use_ino, readdir is not
able to fetch inode number. We perfom an addtional lookup
on each file to get it.

In that case, do not lookup .. from root, as it breaks
out of the filesystem and hits NULL pointers.
2014-01-06 08:56:34 +00:00
manu 42e0a87c26 Catch open without FREAD|FWRITE (it should not happen) 2013-07-19 07:32:35 +00:00
manu f7b644965d One more explicit error log, and two bug fixes
1) with recent FUSE, when lookup returns a null ino, it means ENOENT
2) odd corner case that caused a bug on dd if=test of=test conv=notrunc
   This caused the file to be open first ro, then rw. A logic bug in
   perfuse_node_open caused it to skip the second operation, whereas
   it should open for writing, and store the write FH without touching
   the read FH.
2013-07-18 09:01:20 +00:00
manu 299c086640 When lookup returns a node with null inode number, it means the ENOENT,
with negative caching. We do not implement negative caching yet, but
we honour the ENOENT.
2012-11-03 15:43:20 +00:00
manu 3cd0e66ce4 Turn a fatal error into a warning. 2012-09-10 13:56:18 +00:00
riz d41e703879 Disable default build of debugging info. 2012-09-06 16:39:07 +00:00
manu 2a9a80bb36 Add PUFFS_KFLAG_CACHE_DOTDOT so that vnodes hold a reference on their
parent, keeping them active, and allowing to lookup .. without sending
a request to the filesystem.

Enable the featuure for perfused, as this is how FUSE works.
2012-08-10 16:49:35 +00:00
manu 075ba0e590 - Fix same vnodes associated with multiple cookies
The scheme used to retreive known nodes on lookup was flawed, as it only
used parent and name. This produced a different cookie for the same file
if it was renamed, when looking up ../ or when dealing with multiple files
associated with the same name through link(2).

We therefore abandon the use of node name and introduce hashed lists of
inodes. This causes a huge rewrite of reclaim code, which do not attempt
to keep parents allocated until all their children are reclaimed

- Fix race conditions in reclaim
There are a few situations where we issue multiple FUSE operations for
a PUFFS operation. On reclaim, we therefore have to wait for all FUSE
operation to complete, not just the current exchanges. We do this by
introducing node reference count with node_ref() and node_rele().

- Detect data loss caused by FAF
VOP_PUTPAGES causes FAF writes where the kernel does not check the
operation result. At least issue a warning on error.

- Enjoy FAF shortcut on setattr
No need to wait for the result if the kernel does not want it. There is
however an exception for setattr that touch the size, we need to wait
for completion because we have other operations queued for after the
resize.

- Fix fchmod() on write-open file
fchmod() on a node open with write privilege will send setattr with both mode and size set. This confuses some FUSE filesystem. Therefore we send two FUSE operations, one for mode, and one for size.

- Remove node TTL handling for netbsd-5 for simplicity sake. The code
still builds on netbsd-5 but does not have the node TTL feature anymore.
It works fine with kernel support on netbsd-6.
2012-07-21 05:49:42 +00:00
abs f8f196e8f9 Fix the build by adding (unused) flags argument to perfuse_node_setattr_ttl 2012-06-28 13:53:13 +00:00
manu 574c09729f Fix memory leak when we discard a voided setattr operation 2012-06-14 05:58:22 +00:00
manu 08f6c5569f Fix memory leak on setattr 2012-06-13 01:45:56 +00:00
manu 1d0360b1c9 Add placeholder so that we can later add allbacks without breaking the ABI 2012-06-05 15:04:18 +00:00
manu 35ee07be22 Setting mode by fchmod(2) will break on glusterfs-3.3 is we attempt
to set atime and mtime at the same time. Detect that situation just
like we detected ftruncate(2) and wipe atime and mtime if it occurs.
2012-05-28 02:13:32 +00:00
manu 70d8192475 - When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
  and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
  a newly created vnode but has been made redundant along time ago since
  uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and   RECLAIM (how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
  we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
2012-04-18 00:57:21 +00:00
manu 6bceb41868 Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.

PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
2012-04-08 15:13:06 +00:00
matt e1a2f47f12 Use C89 function definition 2012-03-21 10:10:36 +00:00
matt fa835e8c8b These directories default to WARNS?=5 2012-03-21 05:37:42 +00:00
manu 202e6de05c The kernel can lookup the same node multiple time and will reclaim as
many times it looked up. All reclaims but the last one must be ignored,
otherwise we discard a node which will still get operations. We therefore
have to keep track of lookup/reclaim count and hnour reclaims only when
the count reaches zero.
2012-03-08 14:58:57 +00:00
manu 9724ab82d4 Make sure perfused exit when the filesystem crashed, so that unmount
is done. Failure to do so caused deadlocks, with operation that
held a lock on the root vnode and got stuck in perfused forever.

Approved by releng.
2012-02-03 15:54:15 +00:00
dholland 762237230c Fix 32-bit build 2012-01-29 09:01:31 +00:00
manu 8fcbc70792 Improve FUSE trace facility 2012-01-29 06:22:01 +00:00
riz 1874c03a4b Redo previous; remove all the casts I added, and use PRI* macros instead.
(by popular demand - makes sense, too)
2011-12-29 04:25:49 +00:00
riz 8340adc56e Cast time_t to intmax_t for printf purposes, and format with %j. Fixes
build on amd64 and probably i386 as well.
2011-12-29 01:40:32 +00:00
manu 4fba06add5 Add a FUSE trace facility, with statistics collection. This should help
tracking bugs and performance issues
2011-12-28 17:33:52 +00:00
manu 71a2942b6b Rework puffs_framebuf management toremove leaks and abusive reuses. On
exchange error, the puffs_framebuf is now freed immediatly, before
requeuing outstanding requests.
2011-12-16 05:34:54 +00:00
manu 55557eb9ac - Add missing ENOENT or ESTALL when accessing deleted node
- Fix a warning, fix style (80 chars for a line)
2011-11-28 05:33:33 +00:00
manu 124660b818 Copy node expiration date before comparing it, otherwise the comparison
does not work (no idea why) and cached node is never used.
2011-11-17 02:28:21 +00:00
manu 98c38e3ee8 Correctly pass the advlock owner id from kernel to filesystem, instead of
using process PID.

Allow the usage of the read filehandle for advlock, in order to support
shared locks on read-only files
2011-11-16 04:52:40 +00:00
manu ec1aa8a54b Return EISDIR for read/write to directories. NetBSD directory read should
instead return a getent(2) output, but is that really used?
2011-11-10 16:21:09 +00:00
manu 2bc8acd859 - Fix the confusion between fileno (opaque FUSE reference) and inode
numbers. fileno must be used when exchanging FUSE messages.
- Do not use kernel name cache anymore, as it caused modification from
  other machines to be invisible.
- Honour name and attribute cache directive from FUSE filesystem
2011-10-30 05:11:37 +00:00