Commit Graph

299 Commits

Author SHA1 Message Date
pooka 226c70ad91 Build this as mount_puffsportal for now, so that it can be easily
installed at the same with the regular mount_portal.
2007-07-08 14:27:48 +00:00
pooka 33318660d7 * don't need to define a nop notify, just pass in NULL to init
* remove node's i/o descriptor in reclaim
2007-07-08 11:45:00 +00:00
pooka e395775675 Add support for non-blocking I/O. Also fixes problems the providers
and popen() caused with concurrent access.

This should match the original portalfs in functionality now.
2007-07-08 10:43:03 +00:00
pooka 1ad69966c9 I'm fairly certain this file system's type is psshfs, not ppshfs
(how did that manage to be there this long?)
2007-07-07 22:06:09 +00:00
pooka bfecc30afc adapt to puffs_framebuf changes 2007-07-07 21:14:26 +00:00
pooka 330acd4a45 Add initial puffs version of mount_portal, eventually to replace
portalfs.  Uses the same config files etc. as the "regular"
mount_portal, and actually compiles a lot of the code directly from
under src/sbin/mount_portal.

Doesn't yet support concurrent access, but I have a pretty clear
vision on how to neatly fix that.
2007-07-02 18:35:14 +00:00
pooka 58457f2209 adapt: inactive no longer comes with int *refcount (not that it was
used except for setting the default here anyway)
2007-07-02 10:26:50 +00:00
pooka 6596e0c995 adapt: **newnode etc. pointers -> struct puffs_newinfo 2007-07-01 18:40:15 +00:00
pooka fe7bbdec69 adapt: pid -> const struct puffs_cid * 2007-07-01 17:23:44 +00:00
pooka a5c38fbcdf g/c bit about MNT_NOATIME being mandatory. it obvious isn't since
the code was #if 0'd out.
2007-06-26 13:20:34 +00:00
pooka 4a403dd973 Fix return value comparison inversion. Makes psshfs work for the
nocache case again, as the server error value for EOF is properly
handled again.
2007-06-26 11:04:29 +00:00
pooka 5662e7f720 PUFFS_KFLAG_NOCACHE became two, so introduce the command line options
-o nonamecache and -o nopagecache and adapt file systems where necessary.
2007-06-24 22:18:38 +00:00
pooka 91629617de Call puffs_pn_remove() just in case the file server happens to be
quick with recycling qids.
2007-06-24 19:13:39 +00:00
pooka 23c0297785 print warning if directory cache invalidation fails 2007-06-21 13:53:00 +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
tls 4147a3c54a Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry.  RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros.  Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default.  Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
2007-05-28 12:06:17 +00:00
pooka 464b354e31 devnullify ssh process's stderr to avoid tty spam 2007-05-21 08:55:04 +00:00
pooka d32c8fa56b In case we are really tight on vnodes, the directory vnode might
be reclaimed from under while we are warming the getattr cache.
Shuffle some code to prevent the effects.  Theoretically the race
is still possible, but I don't think it will happen in practice.
In any case, the code could benefit from some more dusting.
2007-05-20 20:27:04 +00:00
pooka 4bc09685b9 Observe that when doing ls -l, the attributes of the first file
getattr are usually still outstanding when we already would like
the result.  Instead of issueing another stat which will be serviced
only after all the other entries in the directory, record all the
outgoing readdir getattr buffers and if we encounter an outstanding
request when we need to fetch attrs, do a puffs_framev_framebuf_ccpromote()
wait for it instead of firing off the second query.  This shaves
almost 10% off the time for ls -lR.

Also, get rid of the SUPERREADDIR conditional, since it has penetrated
the code quite a bit and the #ifdef SUPERREADDIRs were starting to
look like tagliatelle alla bolognese (n.b. I love how it looks,
but I wouldn't like it either if my tagliatelle alla bolognese
looked like psshfs code).  Maybe it should be re-introduced in the
form of a switch?
2007-05-20 20:06:23 +00:00
pooka a769baf075 Implement SUPERREADDIR (like nfs readdirplus) getattr cache warming
a bit differently: when reading the directory, store all getattr
caching queries and fire off only when the directory read is
complete.  That way the common sequence is not [readdir, lots of
async getattr requests, readdir EOF] but rather [readdir, readdir
EOF, lots of async getattr].  This speeds up ls -lR by about 25%
(on my LAN).
2007-05-20 17:47:12 +00:00
pooka 7c537b89eb Change the signature of puffs_respcmp to return -1,0,1 for smaller,
equal, larger, respectively instead of 0/1 for non/equal.  This
will allow sorting the buffers for faster matching in libpuffs.
While here, change the name from respcmp to framecmp, as that better
reflects the purpose.

NOTE!  there is no obvious way to make compilation fail for file
systems which may already be using this feature (although I don't
think there are any outside our tree, as the feature is two weeks
old).  Nevertheless, non-updated file systems will fail very quickly.
2007-05-20 16:24:37 +00:00
pooka b283afddec support reclaim. set noref setback when removing a node to prompt
immediate reclaim.
2007-05-19 10:38:23 +00:00
pooka 423fa255c6 remove obvious incorrect assert() from doreclaim() and remove the
whole PSN_NUKED bit - it's not very useful because of the noref setback.
2007-05-18 18:00:07 +00:00
pooka f98f18ebad * use NOREF setback to prompt immediate (well, once the kernel
reference count goes to 0) reclaim of deleted nodes as opposed to
  waiting for the system to start reclaiming the freelist
* combine some nodeflags from different variable to one status variable
2007-05-18 16:13:47 +00:00
pooka c8b0a89198 reflect changes in fs mount: use puffs_mount() instead of
puffs_domount() & puffs_start()
2007-05-17 14:13:04 +00:00
pooka c1f0cc6870 Add error parameter to puffs_framev_cb to signal if there is a
result of if the function should just do resource cleanup.
2007-05-16 10:04:08 +00:00
pooka 0b0e609b9b Enhance the GETRESPONSE, JUSTSEND and SENDCB macros to process the
return value from the network layer.
2007-05-16 09:57:21 +00:00
pooka ddf4b3708e * free framebuf after use (even in the common path ;)
* simplify a loop
2007-05-15 17:08:34 +00:00
pooka 8427494a96 don't leak memory if getting data from the buffer fails
CID 4485
2007-05-15 14:22:58 +00:00
pooka eaf4ddfb76 remember to free longname if getting vattr from the message fails
CID 4486
2007-05-15 14:17:30 +00:00
pooka 9fec81140f In case we counter a protocol error while parsing the readdir response,
completely release our directory cookie - it's unlike we'll be coming
back to it.  And if we do, it'll just be autogenerated.

CID 4487
2007-05-15 14:12:41 +00:00
pooka 5252a3b094 free name from proto_getstat() after use
CID 4488
2007-05-15 13:56:00 +00:00
pooka e3468dbcce adapt to "step 3" of puffs_framebuf changes 2007-05-15 13:46:47 +00:00
pooka c495e43bb1 uint32_t vs. size_t pointer adjustments for LP64 build 2007-05-12 09:41:30 +00:00
pooka 3a7dcceb40 use puffs_mainloop(); puffs_framebuf_eventloop() is a goner 2007-05-11 21:27:45 +00:00
pooka 5069b5df0c adapt to puffs_framebuf changes 2007-05-11 16:23:00 +00:00
pooka a2b224da1f Error with rtagid instead of tagid. caught by Dan's compiler flags. 2007-05-11 11:43:08 +00:00
pooka 888697433e remove caveat no longer applicable 2007-05-09 21:50:47 +00:00
pooka 3c246dfd5b use fprintf instead of errx for usage() 2007-05-09 21:46:27 +00:00
tnn 05ca7e85d0 Add an EXAMPLES section. 2007-05-09 21:00:27 +00:00
tnn 098bf95670 Change [-O sshopt value] to [-O sshopt=value] to better conform with the
way other userland apps behave. In /etc/fstab one would specify options
with -O=sshopt=value.
2007-05-09 20:25:20 +00:00
tnn edbbe0d8f9 Add flag [-O sshopt value] to mount_psshfs(8), allowing the user to specify
options to pass along to ssh(1). Remove redundant flag [-p sshport]; an
equivalent of -O Port sshport. ok'd by pooka@
2007-05-09 19:54:39 +00:00
pooka dca252d8a0 Use inactive-on-demand, set inactive request in open() to close
file handles when last reference is removed from the kernel.
2007-05-07 17:20:58 +00:00
pooka 3ac2e6b4df If mode is set, the uppermost byte specifying the type must be
correctly, otherwise the file server will attempt a conversion.
Specifically, if the directory bit is not set when changing the
permissions for a directory, a conversion from directory to regular
file would be attempted and naturally it being unsupported the
whole chmod would fail.  So supply the file type as part of the
file mode.
2007-05-06 22:17:50 +00:00
pooka afa0f0e278 Close file handles in inactive instead of close - a memory mapping
may still be active after a vnode is closed
2007-05-06 21:58:24 +00:00
pooka ded3a0bfa7 Open files in open and close them in inactive. This avoids the
silly and problematic chmod + open + "un"chmod in write, among
other things.
2007-05-06 19:48:51 +00:00
pooka c0da05fe2a Fire off FXP_CLOSE in create() and return immediately instead of
waiting for the result.
2007-05-06 15:30:18 +00:00
pooka d34b752303 use puffs_framebuf_remaining() 2007-05-06 10:54:55 +00:00
pooka cfd2c55859 adapt to puffs_framebuf_eventloop signature change 2007-05-06 10:51:19 +00:00
pooka 0e7bdfc146 Adapt to use puffs_framebuf. This gets rid of most of the duplicated
code between mount_psshfs and mount_9p and clarifies the code
structure.
2007-05-05 15:49:51 +00:00
pooka ff4087e2ce Fix a couple of gotchas left after AUTOVAR() started creating the
network buffers.

CID 4477, 4478, 4479, 4480
2007-05-04 18:17:34 +00:00
pooka 6784b33211 free uid and gid strings after use
CID 4474, 4475
2007-05-04 18:12:25 +00:00
pooka 9c16b5e434 For consistency destroy kernel request putbuffers also when
escaping event loop (the process is going to exit anyway, but ...)
2007-05-02 18:50:30 +00:00
pooka 5e73325b44 g/c forgotten printf 2007-05-01 20:43:14 +00:00
pooka c442e78507 Add -p to specify server port if someone should for some reason
happen to run sshd on port, to pick a random number, 443.

Probably should give a way to specify rest of the ssh options.
2007-04-29 10:02:56 +00:00
pooka 0809789ff9 Use PUFFS_KFLAG_WTCACHE to avoid the need to do a sync(8) on the
client host to get all the data onto the server.
2007-04-22 20:03:26 +00:00
pooka 436cfd0df4 Alter the strategy for reading/writing a bit. First of all, use
PUFFS_KFLAG_WTCACHE.  Second, create separate fids for reading and
writing.  If opening for read, open a read-only fid and for write
a write-only fid; use these for reading and writing.  When the
open-count for a node drops to zero, clunk both.  This avoids hitting
the fid limit when accessing large directory hierarchies.

Two problems remain:
* does not take credentials into account, although we can only mount
  the remote 9P file server with one set of credentials, so not a
  huge worry
* doesn't work for the open/mmap/close/access_memory_window case, but
  that will require some further kernel changes
2007-04-22 18:10:48 +00:00
pooka 46853cdc64 descend into mount_9p 2007-04-21 14:23:10 +00:00
pooka e73a712f80 mount_9p: mount a file server using the Plan9 file sharing protocol
Works, but lots of little things to nibble on:
* fix permissions to work better
* limit the amount of open files required
* do constant folding with psshfs code
* support authentication
etcetc.
2007-04-21 14:21:42 +00:00
pooka 4895c619c9 use puffs_cc_getspecific() where puffs_usermount is not required 2007-04-19 20:31:09 +00:00
pooka 8ecf355f37 psbuf_recycle now exists, so use it instead of destroy&make in one
spot I probably missed originally.  No real functional change.
2007-04-18 15:53:20 +00:00
pooka 4c854dd8b4 Use ntohl instead of htonl when converting data from the network.
Result isn't that much different, though ....
2007-04-18 15:35:02 +00:00
pooka 66efb94d3b use PUFFS_STORE_DCOOKIE 2007-04-17 11:43:32 +00:00
pooka b173dac692 adapt to kernel changes with file handles 2007-04-16 13:06:39 +00:00
pooka 37dd7942fc Instead of keeping on adding parameters to puffs_mount(), make it
only take the bare essentials, which currently means removing
"maxreqlen" from the argument list (all current callers I'm aware
of set it as 0 anyway).  Introduce puffs_init(), which provides a
context for setting various parameters and puffs_domount(), which
can be used to mount the file system.  Keep puffs_mount() as a
shortcut for the above two for simple file systems.

Bump development ABI version to 13.  After all, it's Friday the 13th.
Watch out!  Bad things can happen on Friday the 13th. --No carrier--
2007-04-13 13:35:46 +00:00
pooka b142df9b67 Actually, we can't reclaim our memory image for nodes which have
been nodetofh translated even if they are not valid on the sftp
server anymore, because some nfs client might still be clinging on
to the file handle we are reclaiming now.
2007-04-12 21:08:49 +00:00
pooka db8a30d61d document -e for nfs exportability 2007-04-12 21:04:39 +00:00
pooka bf4e539fe8 Support nfs exporting.
Now, when I say support, I mean "support", due to the limitations
of the backend.  File handles are valid only for one session, since
nodes can only be identified by pathnames and pathnames don't (all)
fit into the nfs file handle space.  Additionally, we can't detect
if a pathname is completely replaced by another file (if it's done
via some other route that through our mount, of course).  But then
again, that's an inherent problem with sshfs even without nfs.
2007-04-12 20:42:46 +00:00
pooka 95a18d20b9 Hide struct puffs_usermount from the rest of the world and provide
accessors for interesting data in it.  Namely, you can now get
pu->pu_privdata with puffs_getspecific(), pu->pu_pn_root with
puffs_set/getroot() and pu->pu_maxreqlen with puffs_getmaxreqlen().
2007-04-12 15:09:00 +00:00
pooka 1cfe630356 adapt to new readdir signature. no functional change 2007-04-11 21:21:50 +00:00
pooka 81cd3e0214 fix another case of checking for return value from wrong variable
(that's what you get when you copypaste code, a cid with a pin
to burst your bubble, that's what you get for all your troubles, I'll
never copypaste again)

CID 4461
2007-04-09 20:59:08 +00:00
pooka fb8082e163 Check for success from correct variable after allocnode()
CID 4460
2007-04-09 20:52:32 +00:00
pooka 94b72e4fc4 If we have to do a stat in lookup, update time of last stat for
the new node to avoid a most likely immediate stat from the server.
2007-03-22 13:43:58 +00:00
pooka 7517e20c03 In case lookup from the directory listing fails, try statting the
target before giving up.  Makes it possible to access files from
-r+x directories.
2007-03-22 13:11:00 +00:00
pooka f446ae6b9f * don't require a directory entry to exist for a reclaimee node.
this can happen legally when a file is removed from backing
  storage not using this sshfs instance, a readdir is executed for
  the parent directory and only then the node gets reclaimed.
* now that there is a mechanism in place which does not require a
  pcc to do an sftp transaction, do not yield() in operations where
  the final transaction is something where we don't care about the
  return value (e.g. close handle).  speedup benefit for no cost.
2007-03-13 18:00:34 +00:00
pooka ad70c5ab2e one more size_t -> uint32_t 2007-02-27 14:17:14 +00:00
pooka cbb615f4db size_t -> uint32_t cleanup to make LP64 build
noticed by wiz
2007-02-27 13:28:39 +00:00
pooka b44590b7d0 * document -s
* explicitly mention that this implements sshfs functionality
2007-02-17 22:19:20 +00:00
pooka f5fed5348b Support reclaim. To support dotdot lookup, here we leave the
reclaimed nodes hanging until all their children have been reclaimed
and then reclaim everything we can as far up to root as possible.
This is because the file system structures are currently interlinked
in a fashion which would make dotdot lookup based on purely a path
instead of a in-memory node parent member pointer very difficult.
Yes, this deserves a closer look some day.
2007-02-15 13:07:29 +00:00
pooka 986368958f Don't destroy puffs_nodes in success paths of remove and rmdir: the
kernel assumes that they will not be recycled until reclaim.
2007-02-10 02:53:27 +00:00
pooka 306e0025cf Implement "superreaddir". This issues a getattr for all the
directory entries already in readdir and caches the results instead
of waiting for each individial getattr from the kernel.  For
high-latency links the difference in "ls -l" is quite astounding
and even on my lan "ls -lR" is faster than for nfs in a normal
directory hierarchy (i.e. not one artifically setup to have thousands
of files per directory).

TODO: implement some sort of bandwidth/latency measurement in the
code and enable or disable this option based on than information
(and a command-line flag).
2007-02-09 23:36:17 +00:00
pooka 984c93b472 more ketchup 2007-01-20 14:37:48 +00:00
pooka 9fcf633272 play catchup with the lib 2007-01-20 13:52:35 +00:00
pooka 5d293715c8 * adapt to libpuffs path changes
* fix bug in rename
2007-01-15 00:42:21 +00:00
pooka c921b47454 don't detach if -s or -o dump is given on the command line 2007-01-11 18:52:26 +00:00
pooka 0ac919744e Give nukenode a destroy flag. If given, it completely wipes out
the node and directory cache (for directories).  Otherwise it just
nukes directory entry information.  The latter case is used when
renaming.
2007-01-11 18:50:42 +00:00
pooka 9da6af0a36 Invalidate kernel name cache for a directory when (re-)reading
directory contents from the server.
2007-01-09 18:23:21 +00:00
pooka 6ee2e9c031 Mark invalid attributes as invalid. Fixes stuff such a cp'ing files
when cp uses mmap().  Also makes attributes appear correct.
2007-01-09 12:34:20 +00:00
wiz 85181e787c New sentence, new line. Sort SEE ALSO. Punctuation nit. 2007-01-08 07:26:40 +00:00
pooka 94f62e9b01 properly carry fileid for directory entries, fixes pwd 2007-01-07 21:59:27 +00:00
pooka d66d221ae1 man page for mount_psshfs 2007-01-07 19:56:26 +00:00
pooka 5c80f85b24 use UBC by default 2007-01-07 19:33:23 +00:00
pooka 7f864d6007 * Adapt to openssh standard of timestamps in file attributes. Maybe
should make this work with the IETF standard some day, also.
* kludge with writes and permissions a bit to be able to flush data
  cached in ubc to files which are already with r/o permissions in
  the backend
2007-01-07 19:31:48 +00:00
pooka c53a62f5e3 fix link count calculation for directories 2007-01-07 19:29:55 +00:00
pooka a67e4ce37f * do mount as a forward operation instead of a callback
* process -o args for mount
2007-01-06 18:25:19 +00:00
pooka d584a8d23a SUSv3 says: should the implementation not support directory unlinking,
unlink shall fail with EPERM and the errno of the failure shall be EPERM
2007-01-01 21:32:12 +00:00
pooka 75a62546e6 Makefile.inc to get BINDIR right 2006-12-29 17:42:52 +00:00
pooka 81b905fdbb if MKPUFFS=yes is given, build & install mount_psshfs (default: no) 2006-12-29 15:52:20 +00:00
pooka c3ef8ea5d0 puffs sshfs, an sshfs implementation built on top of the puffs
continuation framework
2006-12-29 15:35:39 +00:00