Commit Graph

48 Commits

Author SHA1 Message Date
manu cf73d5332b libpuffs support for fallocate and fdiscard operations 2014-10-31 13:56:04 +00:00
manu ccfb03f9b0 Add an open2 method, like open but with an additionnal oflags used
by the filesystem to send back information about the file.
This is used to implement PUFFS_OPEN_IO_DIRECT by which the filesystem
tells the kernel that read/write should bypass the page cache.
2014-08-16 16:25:44 +00:00
christos 27c90c0e19 revert previous, will turn off globally. 2013-11-06 19:56:38 +00:00
christos 48ec4b4e3a XXX: gcc initialization (mc68k gcc-4.5.x gcc-4.8.x) 2013-11-06 19:50:10 +00:00
manu d256e38414 Fix regression that has been introduced when the lookup/reclaim race
condition was addressed in libpuffs by counting lookups.

The fix assumes that cookies map to struct puffs_cookie, which has not
been documented as a requirement for filesystems using libpuffs. As an
example, we got burnt by this assumption in libp2k (kern/46734), and
we fixed bit by actually mapping libp2k cookies to struct puffs_node.

It is unlikely, but there may be third party filesystems that use cookies
unmapped to struct puffs_node, and they were left broken for now.

- we introduce a puffs_init() flag PUFFS_FLAG_PNCOOKIE that let filesystems
inform libpuffs that they map cookies to struct puffs_node. Is that flag
is used, the lookup/reclaim race condition fix is enabled. We enable the
flag for libp2k.

- filesystems that use puffs_pn_new() obviouslty use struct puffs_node
and gain PUFFS_FLAG_PNCOOKIE automatically even if they did not specify
it in puffs_init(). This include all our PUFFS filesystem in-tree except
libp2k.

- for filesystems not willing to use struct puffs_node, we introduce a
reclaim2 vnop, which is reclaim with an additionnal lookup count argument.
This vnop let the filesystem implement the lookup/reclaim race fix on
its own.
2012-08-16 09:25:43 +00:00
manu 244cd4a742 Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.
2012-08-10 08:42:10 +00:00
manu 8502ba8ea3 - Improve PUFFS_KFLAG_CACHE_FS_TTL by reclaiming older inactive nodes.
The normal kernel behavior is to retain inactive nodes in the freelist
until it runs out of vnodes. This has some merit for local filesystems,
where the cost of an allocation is about the same as the cost of a
lookup. But that situation is not true for distributed filesystems.
On the other hand, keeping inactive nodes for a long time hold memory
in the file server process, and when the kernel runs out of vnodes, it
produce reclaim avalanches that increase lattency for other operations.

We do not reclaim inactive vnodes immediatly either, as they may be
looked up again shortly. Instead we introduce a grace time and we
reclaim nodes that have been inactive beyond the grace time.

- Fix lookup/reclaim race condition.

The above improvement undercovered a race condition between lookup and
reclaim. If we reclaimed a vnode associated with a userland cookie while
a lookup returning that same cookiewas inprogress, then the kernel ends
up with a vnode associated with a cookie that has been reclaimed in
userland. Next operation on the cookie will crash (or at least confuse)
the filesystem.

We fix this by introducing a lookup count in kernel and userland. On
reclaim, the kernel sends the count, which enable userland to detect
situation where it initiated a lookup that is not completed in kernel.
In such a situation, the reclaim must be ignored, as the node is about
to be looked up again.
2012-07-21 05:17:10 +00:00
manu d1056538cc Pass the FAF flag to handlers:
- setattr_ttl is updated to add a flag argument. Since it was not present in
  a previous release, we can change its API
- write2 is introduced, this is write with an extra flag for FAF.
- fsync already has the FAF information in a flag and needs no change
- for other operations, FAF is unconditional
2012-06-27 13:25:23 +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 fb4eb35384 Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
2012-04-08 15:07:45 +00:00
manu 154cec5236 Rollback previous change as it breaks autmates tests 2011-11-25 15:02:02 +00:00
manu 77ac17e5c3 Remove files specified in pcn.
When remove files using name from pnode, another link on this file
can be unlinked. E.g. "touch 1; ln 1 2; rm 2" will remove file named
"1". Thus puffs_null_node_remove should remove directory entry which
name is provided by pcn (as said in puffs_ops.3). Caller should
provide appropriately initialized pcn.

From Evgeniy Ivanov <lolkaantimat@gmail.com>
2011-11-24 01:58:52 +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
pooka 248168affc Remove PUFFS_WITH_THREADS ifdef garbage, just use libc weak symbols. 2010-12-06 14:50:34 +00:00
pooka c3be8a8cd5 * support extended attributes
* bump major due to structure growth
* add some spare space
* remove ABI sillyness
2010-05-21 10:50:52 +00:00
pooka 75008bfc31 Dispatch puffs_node_abortop().
Note: We use the storage of puffs_cache_write from puffs_ops for
this purpose.  It's not issued by the kernel and hence currently
unused, and this saves us from the trouble of bumping the lib major
version.
2009-10-17 23:19:52 +00:00
pooka ff42332733 Replace void * by puffs_cookie_t where appropriate. No functional change. 2008-08-12 19:44:39 +00:00
pooka 73bad8cbdb Reserve enough memory for ops which return more than they receive. 2008-03-20 15:28:03 +00:00
pooka d1d05d65b9 Implement lazy contexts for file systems using puffs_mainloop().
Previously each request was executed on its own callcontext and
switched to every time the request was being processed.  Now requests
borrow the mainloop context and switch only if/when they yield.
This takes two context switches away from a file system request
bringing down the typical amounts 2->0 (e.g. dtfs) and 4->2 (e.g.
psshfs).

The interfaces for manually executing requests changed a bit:
puffs_dispatch_create() and puffs_dispatch_exec() must now be used.
They are not tested, as nothing in-tree wants them and I doubt
anyone else is really interested in them either.

Also do some misc code cleanup related to execution contexts.  The
"work-in-progress checkpoint" committed over a year ago was starting
to look slightly weed-infested.
2008-01-28 18:35:49 +00:00
pooka 9f5abca72f Comment out the puffs_executor hacks for now, they have races.
The issue should be solved in another fashion anyway.
2008-01-16 23:17:43 +00:00
pooka 614c59fcb2 Cache a number of execution contexts instead of re-initializing
them every time.  Speeds up pure in-memory file systems such as
sysctlfs or dtfs quite a bit.  For actual I/O-workhorses the result
is of course less tasty.
2008-01-16 21:29:59 +00:00
pooka 08c7b6138e * nuke puffs_cc_get{specific,usermount} for good
* move prototypes for puffs_docc and puffs_dopufbuf into the
  public header, as they are should be exposed
2007-12-16 20:02:57 +00:00
pooka 319ddafdc5 Now that "l" is gone both as an argument to operations and from
componentname, remove all vestiges of puffs_cid.
2007-12-08 19:57:02 +00:00
pooka 61113f40fd Part 3/n of extensive changes to message handling:
Get rid of the original puffs_req(3) framework and use puffs_framebuf(3)
instead for file system requests.  It has the advantage of being
suitable for transporting a distributed message passing protocol
and therefore us being able to run the file system server on any
host.

Ok, puffs is not quite here yet: libpuffs needs to grow request
routing support and the message contents need to be munged into a
host independent format.  Saying which format would be telling,
but it might begin with an X, end in an L and have the 13th character
in the middle.  Keep an eye out for the sequels: Parts 3+m/n.
2007-12-04 21:24:10 +00:00
pooka 21913eabe5 Rototill.
Ok, ok, a few more words about it: stop holding puffs_cc as a holy
value and passing it around to almost every possible place (popquiz:
which kernel variable does this remind you of?).  Instead, pass
the natural choice, puffs_usermount, and fetch puffs_cc via
puffs_cc_getcc() only in routines which actually need it.  This
not only simplifies code, but (thanks to the introduction of
puffs_cc_getcc()) enables constructs which weren't previously sanely
possible, say layering as a curious example.

There's still a little to do on this front, but this was the major
fs interface blast.
2007-11-30 19:02:28 +00:00
pooka aadcb17f11 * allocate pcc as a slice from the stack instead of allocating it
separately
* provide puffs_cc_getcc()

This is in preparation for the removal of you-should-guess-what as
an argument to routines here and there and everywhere.
2007-11-29 17:47:54 +00:00
pooka 6a3d9a187d Remove "puffs_cid" from the puffs interface following l-removal
from the kernel vfs interfaces.  puffs_cc_getcaller(pcc) can be
used now should the same information be desired.
2007-11-27 11:31:17 +00:00
pooka baea362887 Fix a few bugs and memleaks with the threading code. 2007-10-31 16:09:09 +00:00
pooka f7de032584 lock massage, although I don't think there's a happy ending here 2007-10-29 17:47:33 +00:00
pooka 40ffc8b91f Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.
2007-10-29 15:52:44 +00:00
pooka b40b63f077 Add possibility to set pre- and post callbacks which will be called
for all operations before or after executing the specific callback
(the api is not be final yet, though).
2007-10-28 18:40:30 +00:00
pooka edb40ac9bf Add some very initial support for a threading worker model as an
alternative to the (vastly superior ;) continuation model.  This
is very preliminary stuff and not compiled by default (which it
even won't do without some other patches I cannot commit yet).

The raison d'commit of the patch is a snippet which ensures proper
in-order dispatching of all operations, including those which don't
require a response.  Previously many of them would be dispatched
simultaneosly, e.g. fsync and reclaim on the same node, which
obviously isn't all that nice for correct operation.
2007-10-26 17:35:01 +00:00
pooka be98071c8c Always provide caller information from the kernel based on curlwp.
(but don't deprecate the old puffs_cid interface just yet)
2007-10-21 14:28:05 +00:00
pooka 33c91738e5 Part 1/n of some pretty extensive changes to how the kernel module
interacts with the userspace file server:

  * since the kernel-user communication is not purely request-response
    anymore (hasn't been since 2006), try to rename some "request" to
    "message".  more similar mangling will take place in the future.

  * completely rework how messages are allocated.  previously most of
    them were borrowed from the stack (originally *all* of them),
    but now always allocate dynamically.  this makes the structure
    of the code much cleaner.  also makes it possible to fix a
    locking order violation.  it enables plenty of future enhancements.

  * start generalizing the transport interface to be independent of puffs

  * move transport interface to read/write instead of ioctl.  the
    old one had legacy design problems, and besides, ioctl's suck.
    implement a very generic version for now; this will be
    worked on later hopefully some day reaching "highly optimized".

  * implement libpuffs support behind existing library request
    interfaces.  this will change eventually (I hate those interfaces)
2007-10-11 19:41:13 +00:00
pooka bf2346742b g/c #if 0'd code which isn't likely to get used any time soon 2007-10-09 21:04:55 +00:00
pooka 174fb761dd Pass reason string to pu_errnotify. Print it in the default
version before aborting.
2007-10-01 21:10:50 +00:00
pooka aa533e99dd Add error notifications, which are used to deliver errors from the
kernel to the file server for silly things the file server did,
e.g. attempting to create a file with size VSIZENOTSET.  The file
server can handle these as it chooses, but the default action is
for it to throw its hands in the air and sing "goodbye, cruel world,
it's over, walk on by".
2007-09-27 21:14:49 +00:00
pooka 8631cf4e2b mmap fflags -> prot 2007-07-27 08:28:16 +00:00
pooka df6f052d2f Get rid of the "int *refs" parameter to inactive: the same can be
accomplished now with puffs_setbacks.
2007-07-02 10:24:17 +00:00
pooka 8023454664 Instead of requesting various pieces of information from node-creating
methods using "please fill me"-pointers, pass "struct puffs_newinfo *"
and provide methods to fill in new node info.
2007-07-01 18:39:39 +00:00
pooka ffe0a01441 Instead of supplying a plain pid, supply an abstract struct puffs_cid *,
which can currently be used to query the pid and lwpid.
2007-07-01 17:22:13 +00:00
pooka 438f52d212 make puffs_cred an opaque type 2007-07-01 15:30:15 +00:00
pooka f8326bf98e Move puffs to a two clause license where it already isn't so. And
as agc pointed out, even files with the third clause were already
effectively two clause because of a slight bug in the language...
2007-06-06 01:54:59 +00:00
pooka e001b11fcd default refcount to 1 in inactive 2007-05-18 18:01:55 +00:00
pooka 75bb6c40b0 dispatch PUFFS_VN_POLL 2007-05-18 13:53:54 +00:00
pooka 291fe845cd Step 3 and currently final step of a more general purpose event loop:
support removal and addition of i/o file descriptors on the fly.

* detect closed file descriptors
* automatically free waiters of a dead file descriptor
* give the file server the possibility to specify a callback which
  notifies of a dead file descriptor
* move loop function to be a property of the mainloop instead of
  framebuf (doesn't change effective behaviour)
* add the possibility to configure a timespec parameter which
  attempts to call the loop function periodically
* move the event loop functions from the puffs_framebuf namespace
  to puffs_framev to differential between pure memory management
  functions
2007-05-15 13:44:46 +00:00
pooka 46dc457634 copyright adjustment 2007-05-11 21:44:00 +00:00
pooka e9cad0cef9 move puffs request dispatching code into it's own module.
no functional change
2007-05-11 21:42:42 +00:00