summaryrefslogtreecommitdiff
path: root/lib/libperfuse/ops.c
AgeCommit message (Collapse)Author
2014-01-06For filesystems mounted without -o use_ino, readdir is notmanu
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.
2013-07-19Catch open without FREAD|FWRITE (it should not happen)manu
2013-07-18One more explicit error log, and two bug fixesmanu
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.
2012-11-03When lookup returns a node with null inode number, it means the ENOENT,manu
with negative caching. We do not implement negative caching yet, but we honour the ENOENT.
2012-07-21- Fix same vnodes associated with multiple cookiesmanu
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-06-28Fix the build by adding (unused) flags argument to perfuse_node_setattr_ttlabs
2012-06-14Fix memory leak when we discard a voided setattr operationmanu
2012-06-13Fix memory leak on setattrmanu
2012-05-28Setting mode by fchmod(2) will break on glusterfs-3.3 is we attemptmanu
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-04-18- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carrymanu
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-08Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so thatmanu
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-03-21Use C89 function definitionmatt
2012-03-08The kernel can lookup the same node multiple time and will reclaim asmanu
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-01-29Improve FUSE trace facilitymanu
2011-12-28Add a FUSE trace facility, with statistics collection. This should helpmanu
tracking bugs and performance issues
2011-12-16Rework puffs_framebuf management toremove leaks and abusive reuses. Onmanu
exchange error, the puffs_framebuf is now freed immediatly, before requeuing outstanding requests.
2011-11-28- Add missing ENOENT or ESTALL when accessing deleted nodemanu
- Fix a warning, fix style (80 chars for a line)
2011-11-17Copy node expiration date before comparing it, otherwise the comparisonmanu
does not work (no idea why) and cached node is never used.
2011-11-16Correctly pass the advlock owner id from kernel to filesystem, instead ofmanu
using process PID. Allow the usage of the read filehandle for advlock, in order to support shared locks on read-only files
2011-11-10Return EISDIR for read/write to directories. NetBSD directory read shouldmanu
instead return a getent(2) output, but is that really used?
2011-10-30- Fix the confusion between fileno (opaque FUSE reference) and inodemanu
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-09-10Avoid comparison between signed and unsigned integer expressions bytron
casting the offset to a unsigned type. This fixes the NetBSD/i386 and hopefully the NetBSD/amd64 build.
2011-09-09make this build on amd64 and remove redundant and unused code.christos
2011-09-09Serialize access to file size. We already have such a thing in themanu
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-08-13- fix warn/err confusiogchristos
- fix debugging printf - add func arguments to simple formats
2011-08-09Fix uninitiaized variable usage (never though lint would miss that whenmanu
used by return statement) that caused unprivilegied user to fail on unlink(2) and rename(2) operations.
2011-08-02Do not reject reads on directory, it raises a useless EBADFD while themanu
thing can just fail silently.
2011-08-02Fix creds passed to FUSE when requests are done on behalf of the kernel.manu
We previously sent uid/gid set to -1, we now set it to 0.
2011-07-19Make sure libperfuse still builds on netbsd-5.1manu
2011-07-18ftruncate(2) cause a SETATTR with only va_size set, and some filesystemsmanu
(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-14FUSE struct dirent's off is not the offset in the buffer, it is an opaquemanu
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-04Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell themanu
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-06-28Add support for extended attributesmanu
2011-06-01Fix race conditions between write and getattr/setattr, which lead tomanu
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-01Remove outdated comment about a fixed bugmanu
2011-05-30Use SOCK_SEQPACKET in perfuse if available. This fix file operations hangsmanu
where the FUSE filesyste replied to an operation and got an ENOBUFS it did not handle. We now are also able to cleanly unmount
2011-05-18- Proper permission checks when doing directory traversal. e.g.: runmanu
rm dir/file while dir was never looked up since the mount. In that situation, we get lookup with pcn_nameiop NAMEI_DELETE for dir before we get it for file. But for dir we are just looking for PUFFS_VEXEC. This is solved by honouring NAMEI_ISLASTCN, which is set for the last element only - do not send O_EXCL to FUSE as documentation forbids it. - fix warning
2011-05-11Use sysconf(_SC_PAGESIZE) instead of PAGE_SIZE.jakllsch
2011-05-03Fixes for the advlock method. It can now sustain pkgsrc/devel/locktestsmanu
with glusterfs as backend
2011-04-25- Implement proper unprivilegied user permission verificationsmanu
Verification is now done in the lookup method, as it is the way to go. Of course there are corner cases, such as the sticky bit which need special handling in the remove method. - Set full fsidx in vftstat method - Do not pass O_APPEND to the filesystem. FUSE always sends the write offset, so setting O_APPEND is useless. If the filesystem uses it in an open(2) system call, it will even cause file corruptions, since offsets given to pwrite(2) will be ignored. This fix allows glusterfs to host a NetBSD ./build.sh -o build - Do not use the FUSE access method, use getattr and check for permission on our own. The problem is that a FUSE filesystem will typically use the Linux-specific setfsuid() to perform access control. If that is missing, any chack is likely to occur on behalf of the user running the filesystem (typically root), causing access method to return wrong information. - When possible, avoid performing a getattr method call and use cached value in puffs_node instead. We still retreive the latest value by calling getattr when performing append write operation, to minimize the chances that another writer appended since the last time we did. - Update puffs_node cached file size in write method - Remove unused argument to perfuse_destroy_pn()
2010-10-11Remove code supporting SOCK_STREAM, as SOCK_DGRAM works finemanu
2010-10-11FUSE filesystems' readlink returns a resolved link with a NUL trailingmanu
character, and PUFFS do not want it. This fixes this bug, that returned stat the informations for x instead of reporting ENOENT: mkdir x && ln x z && stat -x z/whatever/you/want
2010-10-11- fix access control: pcn->pcn_cred is not user credentialsmanu
- Keep track of file generation - remove size tracking in pnd_size, we have it in pn_va.va_size
2010-10-04- delete an obsoelte comment about inactivemanu
- remove a test for getattr return field that was never filled - correctly send filehandle and filehandle flags for getaattr
2010-10-03- Correctly handle rename whith overwritten destinationmanu
- Keep track of file name to avoid lookups when we can. This makes sure we do not have two cookies for the same inode, a situation that cause wreak havoc when we come to remove or rename a node. - Do not use PUFFS_FLAG_BUILDPATH at all, since we now track file names - In open, queue requests after checking for access, as there is no merit to queue a will-be-denied request while we can deny it immediatly - request reclaim of removed nodes at inactive stage
2010-09-29= Open files =manu
- Restore open on our own in fsycn and readdir, as the node may not already be open, and FUSE really wants it to be. No need to close immediatly, it can be done at inactive time. = Write operations = - fix a nasty bug that corrupted files on write (written added twice) - Keep track of file size in order to honour PUFFS_IO_APPEND = many fixes in rename = - handler overwritten nodes correctly - wait for all operations on the node to drain before doing rename, as filesystems may not cope with operations on a moving file. - setback PUFFS_SETBACK_INACT_N1 cannot be used from rename, we therefore miss the inactive time for an overwritten node. This bounds us to give up PUFFS_KFLAG_IAONDEMAND. = Removed files = - forbid most operations on a removed node, return ENOENT - setback PUFFS_SETBACK_NOREF_N1 at inactive stage to cause removed file reclaim = Misc = - Update outdated ARGSUSED for lint - Fix a memory leak (puffs_pn_remove instead of puffs_pn_put) - Do not use PUFFS_FLAG_BUILDPATH except for debug output. It makes the lookup code much simplier.
2010-09-23== file close operations ==manu
- use PUFFS_KFLAG_WTCACHE to puffs_init so that all writes are immediatly send to the filesystem, and we do not have anymore write after inactive. As a consequence, we can close files at inactive stage, and there is not any concern left with files opened at create time. We also do not have anymore to open ourselves in readdir and fsync. - Fsync on close (inactive stage). That makes sure we will not need to do these operations once the file is closed (FUSE want an open file). short sircuit the request that come after the close, bu not fsinc'ing closed files, - Use PUFFS_KFLAG_IAONDEMAND to get less inactive calls == Removed nodes == - more ENOENT retunred for operations on removed node (but there are probably some still missing): getattr, ooen, setattr, fsync - set PND_REMOVE before sending the UNLINK/RMDIR operations so that we avoid races during UNLINK completion. Also set PND_REMOVED on node we overwirte in rename == Filehandle fixes == - queue open operation to avoid getting two fh for one file - set FH in getattr, if the file is open - Just requires a read FH for fsyncdir, as we always opendir in read mode. Ok, this is misleading :-) == Misc == - do not set FUSE_FATTR_ATIME_NOW in setattr, as we provide the time - short circuit nilpotent operations in setattr - add a filename diagnostic flag to dump file names
2010-09-20- performance improvement for read, readdir and write. Now we usemanu
SOCK_DGRAM, we can send many pages at once without hitting any bug - when creating a file, it is open for FUSE, but not for the kernel. If the kernel does not do a subsequent open, we have a leak. We fight against this by trying to close such file that the kernel left unopen for some time. - some code refactoring to make message exchange debug easier (more to come)
2010-09-15- Use SOCK_DGRAM instead of SOCK_STREAM, as the filesystem seems tomanu
assume datagram semantics: when using SOCK_STREAM, if perfused sends frames faster than the filesystem consumes them, it will grab multiple frames at once and discard anything beyond the first one. For now the code can work both with SOCK_DGRAM and SOCK_STREAM, but SOCK_STREAM support will probably have to be removed for the sake of readability. - Remeber to sync parent directories when moving a node - In debug output, display the requeue type (readdir, write, etc...)
2010-09-09- call FSYNCDIR for directoriesmanu
- directories can be open R/W (for FSYNCDIR) - do not skip calls to FSYNC or FSYNCDIR if the filesystem returned ENOSYS: it may change its mind, and it may also actually do something when retunring ENOSYS - When FSYNC and FSYNCDIR return ENOSYS, do not report it to kernel (silent failure)