Commit Graph

86 Commits

Author SHA1 Message Date
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
manu aec8bd3191 perfuse memory usage can grow quite large when using a lot of vnodes,
and the amount of data memory involved is not easy to forcast. We therefore
raise the limit to the maximum.

Patch from Manuel Bouyer. It helps completing a cvs update on a glusterfs
colume.
2011-10-23 05:01:00 +00:00
manu b4362f9202 mlockall is not necessary after all, once we have fixed a kernel bug involving
agedaemon sleeping form memory
2011-10-18 15:47:32 +00:00
tron aff2bc3b4f Avoid comparison between signed and unsigned integer expressions by
casting the offset to a unsigned type. This fixes the NetBSD/i386
and hopefully the NetBSD/amd64 build.
2011-09-10 10:06:10 +00:00
christos 92ad06d875 make this build on amd64 and remove redundant and unused code. 2011-09-09 22:51:44 +00:00
manu 5a6d3e75bd Serialize access to file size. We already have such a thing in the
kernel, where it fixes race for PUFFS filesystems, but we need it again
in perfused since FUSE filesystems are allowed to reorder requests.

The huge issue is in the asyncrhonous SETATTR sent by fsync. It is
followed by a syncrhnous FSYNC, so if the filesystem does not reorder
requests, once the FSYNC returns, we are confident the SETATTR is done.
But since FUSE can reorder, we need to implement sync in perfused.
2011-09-09 15:45:28 +00:00
manu f19a344abc Make sure perfused remains locked in memory, otherwise we can get
deadlocks in low memory situations, where ioflush waits for perfused
to fsync vnodes, and perfused waits for memory to be freed.
2011-09-09 15:35:22 +00:00
christos e3c6f18d56 simplify and eliminate non literal string formats. 2011-08-14 08:19:04 +00:00
christos dda15b03dd - fix warn/err confusiog
- fix debugging printf
- add func arguments to simple formats
2011-08-13 23:12:15 +00:00
manu 4c7933948b Fix uninitiaized variable usage (never though lint would miss that when
used by return statement) that caused unprivilegied user to fail on
unlink(2) and rename(2) operations.
2011-08-09 09:06:52 +00:00
manu 40e8be3f0f Remove PUFFS_KFLAG_WTCACHE, which caused data corruption and slowdown 2011-08-09 06:58:33 +00:00
manu 1de6a9d5ab Do not reject reads on directory, it raises a useless EBADFD while the
thing can just fail silently.
2011-08-02 16:57:16 +00:00
manu fb0fa57f18 Fix creds passed to FUSE when requests are done on behalf of the kernel.
We previously sent uid/gid set to -1, we now set it to 0.
2011-08-02 14:53:38 +00:00
manu 4b1fc9a3f7 Make sure libperfuse still builds on netbsd-5.1 2011-07-19 07:29:39 +00:00
manu 7541af315c ftruncate(2) cause a SETATTR with only va_size set, and some filesystems
(e.g.: glusterfs) will do a custom handling in such a situation. This
breaks because libpuffs folds a metadata (va_atime and va_mtime) update
in each SETATTR. We try to identify SETATTR caused by ftruncate(2) and
remove va_atime and va_mtime in such situation.

This fixes a bug with glusterfs, where parts of a file downloaded by
FTP was filled with zeros because of a ftruncate(2) sent out of order
with write(2) requests. glusterfs behavior depends on the undocumented
FUSE rule that ftruncate(2) will only set va_size in SETATTR.
2011-07-18 02:14:01 +00:00
manu 6e1ab723f7 FUSE struct dirent's off is not the offset in the buffer, it is an opaque
cookie that the filesystem passes us, and that we need to send back on
the next READDIR. Most filesystem just ignore the value and send the
next chunk of buffer, but not all of them. Fixing this allows glusterfs
distributed volume to work.
2011-07-14 15:37:32 +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
riz ad760bfaf3 Don't hardcode the libpuffs path to /usr/src/lib/libpuffs. 2011-06-28 20:28:48 +00:00
manu 8ae0a67d6d Add support for extended attributes 2011-06-28 16:19:16 +00:00
manu 5255616730 Fix race conditions between write and getattr/setattr, which lead to
inconsitencies between kernel and filesystem idea of file size during
writes with IO_APPEND.

At mine, this resulted in a configure script producing config.status
with ": clr\n" lines stripped (not 100% reproductible, but always this
specific string. That is of little interest except for my own future
reference).

When a write is in progress, getattr/setattr get/set the maximum size
among kernel idea (grown by write) and filesystem idea (not yet grown).
2011-06-01 15:54:10 +00:00
manu 344a543c33 Remove outdated comment about a fixed bug 2011-06-01 07:57:24 +00:00