Commit Graph

911 Commits (04cdb72bb1a147c2d732dcca5f87e5e3bd2e2252)

Author SHA1 Message Date
Ronnie Sahlberg 4d102bd24d Improve the documentation for *_get_fd/*_which_events/*_service
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-10-19 18:57:30 -07:00
Ronnie Sahlberg d73d4f3305 rpc_reconnect_requeue: return -1 if autoreconnect is not enabled
This funciton is called from rpc_service when it has detected that
a socket has errored out during reading/writing.
However, since this fucntion returns 0 (==success) for the case where
autoreconnect is not enabled, this means that for an errored socket we
will return 0 (==success) from rpc_service() back to the application.

Change rpc_reconnect_requeue to return -1 when invoked and autoreconnect
is disabled so that applications will receive an error back from rpc_service.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-10-19 18:57:17 -07:00
Ronnie Sahlberg 82d2a22807 Merge pull request #130 from plieven/fix_fd
fix some reconnect issues
2015-09-28 19:25:17 -07:00
Peter Lieven ddd9e2f7e9 socket: keep fd the same across reconnects
There is no guarantee that we get the same fd again when
reestablishing a session. But if the fd changes during a
reconnect we might up with a client application busy polling
on the old fd.

Qemu registers a read handler on the current fd, but is
not realizing fd changes. So we busy poll on the old fd for good.
Things are working (except for the busy polling) until
a drain all is issued. At this point Qemu deadlocks.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-09-22 14:54:48 +02:00
Peter Lieven 7b7aef6b6d socket: keep reconnecting if a reconnect fails
otherwise we end up eating up all socket errors in rpc_service and then
believe we are connected, but the next call to rpc_read_from_socket
fails because the socket is closed. we then reconnect anyway.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-09-22 14:40:59 +02:00
Ronnie Sahlberg e453431d00 Merge pull request #129 from agraf/fuse-commands
Fuse commands
2015-09-11 05:01:04 -07:00
Alexander Graf 883f660430 fuse_nfs: Add fsync
Libnfs already has exports for fsync, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:24:47 +02:00
Alexander Graf 9439361243 fuse_nfs: Add truncate
Libnfs already has exports for truncate, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:24:09 +02:00
Alexander Graf b66121610d fuse_nfs: Add chown
Libnfs already has exports for chown, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:23:35 +02:00
Alexander Graf 315112b923 fuse_nfs: Add chmod
Libnfs already has exports for chmod, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:23:03 +02:00
Alexander Graf d1709ab573 fuse_nfs: Add link
Libnfs already has exports for link, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:22:29 +02:00
Alexander Graf 37fd16ee08 fuse_nfs: Add rename
Libnfs already has exports for rename, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:21:31 +02:00
Alexander Graf 50aabd0729 fuse_nfs: Add symlink
Libnfs already has exports for symlink, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:20:49 +02:00
Alexander Graf 618b6ea030 fuse_nfs: Add mknod
Libnfs already has exports for mknod, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:19:52 +02:00
Ronnie Sahlberg c7204781b1 Merge pull request #128 from agraf/fuse-symlinks
Fuse symlinks
2015-09-10 17:34:29 -07:00
Alexander Graf 39d1f3693c fuse_nfs: Add symlink support
The fuse framework allows us to directly expose symlinks from NFS to the user,
just like a real NFS mount would. All we need to do is call lstat rather
than stat and implement a readlink function.

With this patch I can successfully chroot into a rootfs mounted using
fuse_nfs.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 00:23:48 +02:00
Alexander Graf e81f9e23ab fuse_nfs: Consider st_.tim as struct timespec
At least in my version of glibc the members st_mtim, st_ctim and st_atim
are defined as struct timespec rather than struct timeval, thus
containing a tv_nsec field rather than tv_usec.

Use the proper struct fields instead, fixing compilation on Linux.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 00:22:09 +02:00
Ronnie Sahlberg 2a95006567 Merge pull request #122 from plieven/fix_recv
socket: also reconnect on write errors
2015-09-06 06:57:32 -07:00
Ronnie Sahlberg 96142f98ff Merge pull request #127 from plieven/for_upstream
socket: fix deadlock in rpc_reconnect_requeue
2015-09-06 06:55:55 -07:00
Ronnie Sahlberg c859ac8bd7 Merge branch 'master' of github.com:sahlberg/libnfs 2015-09-06 06:53:47 -07:00
Ronnie Sahlberg c078a42353 Fix OSX build.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-06 06:52:44 -07:00
Peter Lieven 5c7a0f04e6 socket: fix deadlock in rpc_reconnect_requeue
the requeueing code is broken because we access pdu->next
after we mangled it in rpc_return_to_queue.

This leads to losing of waitqueue elements and more severe
a deadlock as soon as more than one waitpdu queue has elements.

Reason for that is that the first elements of the first
two queues are linked to each other.

Example:
waitpdu[0]->head = pduA ; pduA->next = pduB; pduB->next = NULL;
waitpdu[1]->head = pduC ; pduC->next = NULL;
outqueue->head = NULL;

After the for loop for waitpdu[0] queue the outqueue looks like

outqueue->head = pduA; pduA->next = NULL;

At this point pduB is lost!

In the for loop for waitpdu[1] queue the outqueue looks like this
after the first iteration:

outqueue->head = pduC; pduC->next = pduA; pduA->next = NULL;

We now fetch pdu->next of pduC which is pduA.

In the next iteration we put pduA in front of pduC. pduA->next
is then pduC and pduC->next is pduA. => Deadlock.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-28 21:13:37 +02:00
Ronnie Sahlberg aea3b9be1c Merge pull request #125 from alonbl/build
build: add m4 directory to source tree
2015-08-23 15:28:14 -07:00
Alon Bar-Lev 8338c7e27f build: add m4 directory to source tree
m4 directory is required for autotools generation, the use of bootstrap
script is nice helper, however, the autoreconf -ivf should be usable
for autotools based checkout without any other action.

these days the bootstrap script is kinda useless, in the old days it was
a very complex set of autoconf/automake/libtool/gettext commands.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2015-08-24 01:05:00 +03:00
Ronnie Sahlberg cc69b9c189 Merge pull request #123 from plieven/fix_rpc_error
init: do not write to stderr in rpc_set_error
2015-08-06 05:40:42 -07:00
Peter Lieven 29ab169d2b init: do not write to stderr in rpc_set_error
only log error if debug >= 1.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-06 10:12:04 +02:00
Peter Lieven aacee393ca socket: also reconnect on write errors
This also return -1 for rpc_service if rpc_reconnect_requeue fails.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-06 09:53:49 +02:00
Ronnie Sahlberg e466dc6b03 Merge pull request #121 from plieven/fix_recv
socket: handle count == 0 in rpc_read_from_socket
2015-08-04 16:12:43 -07:00
Peter Lieven b319b976dc socket: handle count == 0 in rpc_read_from_socket
An EOF is signalled through a POLLIN event and subsequen recvs return
always 0. Handle this condition and reconnect. Otherwise we might
deadlock here.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-04 14:55:28 +02:00
Ronnie Sahlberg 2288339ed4 Merge pull request #120 from plieven/m4_fix
bootstrap: create m4 directory
2015-08-02 11:04:27 -07:00
Ronnie Sahlberg 8f06fc9d92 New version 1.9.8
- Disable multithreading in fuse_nfs
- Add -Wall and -Werror compiler flags (and fix issues found by it)
- Add nfs-cat utility
- Switch to using nfs_[f]stat64 instead of the deprecated nfs_[f]stat call
  in all examples
- If the server does not return any atttributes for entries in READDIRPLUS
  then try to fetch them using lookup instead.
- Reconnection fixes
- Enforce the max pdu size and add sanity checks when reading PDUs from
  the socket.
- Stop using ioctl(FIONREAD) to find out how many bytes to read, and treat
  0 as an indication of a problem. Some applications call their POLLIN handlers
  spuriosly even when there is no data to read, which breaks this check in
  libnfs.
- Add basic support to do logging.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 10:18:25 -07:00
Peter Lieven b09a55f3d3 bootstrap: create m4 directory
newer versions of autotools fail if the directory is not there.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-07-14 14:20:48 +02:00
Ronnie Sahlberg 68941809a8 Merge pull request #118 from plieven/for_upstream
For upstream
2015-06-23 14:17:35 -07:00
Peter Lieven 9bff07490f add basic support for setting a log level
only logging to stderr is supported at the moment. Per default
there is no output. Its possible to set the log level via
debug url parameter.

Example:
 nfs-ls nfs://127.0.0.1/export?debug=2

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-23 08:55:11 +02:00
Peter Lieven f7bc4c8bb1 init: do not leak rpc->inbuf
additionally free(NULL) is a NOP. So simplify the code

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 16:22:20 +02:00
Peter Lieven 24429e95b8 socket: we have to use memmove in rpc_read_from_socket
I was errornously believing that the areas could not overlap.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 15:54:54 +02:00
Peter Lieven beaa838637 fix some compiler warnings
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:49:17 +02:00
Peter Lieven 7000a0aa04 socket: make rpc->inbuf static and simplify receive logic
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:26 +02:00
Peter Lieven 82aec93f12 socket: limit memory allocation when reading from socket
the write limit of libnfs has been 1M since a long time.
Restrict rtmax and wrmax to 1M and error out otherwise.

Limit the PDU size when reading from socket to rule out
malicious servers forcing us to allocate a lot of memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:20 +02:00
Peter Lieven dc70b92dc6 socket: reset written bytes for head outqueue element
We could be in the middle of writing a PDU while we start reconnecting.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:15 +02:00
Peter Lieven cf420d32d0 socket: use FIONREAD ioctl only for UDP
under Linux poll might return POLLIN even if there are no bytes available for read.
See select(2) manpage for surious readiness under BUGS.

As a consequence we start dropping TCP connections which are still alive.

Signed-off-by: Peter Lieven <pl@kamp.de>

Conflicts:
	lib/socket.c
2015-06-19 13:45:03 +02:00
Peter Lieven 99ae3c01c4 add some debug output
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:43:55 +02:00
Ronnie Sahlberg 68b0298102 Add missing NULLing of data->continue_data for READDIR
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-26 19:50:00 -07:00
Ronnie Sahlberg d8ba04d9c6 READDIRPLUS: use lookup on entries where the server did not return any attr
Some servers sometimes do not return attrivbutes for files in the RDP
replies. So we need to fallback to using LOOKUPs for these entries
just like we always have to do in the READDIR case.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-25 16:53:56 -07:00
Ronnie Sahlberg 7121bc3b89 Merge branch 'master' of github.com:sahlberg/libnfs 2015-05-24 07:51:00 -07:00
Ronnie Sahlberg 08ea9a3138 UTILS: move nfs-cp from examples to utils
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:50:43 -07:00
Ronnie Sahlberg eadef4f724 UTILS: move nfs-cp from examples to utils
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:49:09 -07:00
Ronnie Sahlberg ec3a3afeae EXAMPLES: convert remaining nfs_[f]stat to nfs_[f]stat64
The old nfs_[f]stat calls are deprecated. Convert to the newer
nfs_[f]stat64 call that takes struct nfs_stat_64

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:38:17 -07:00
Ronnie Sahlberg 6f2727468d FUSE: use nfs_stat64() not nfs_stat()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:19:01 -07:00
Ronnie Sahlberg 32633fc3af Merge branch 'master' of github.com:sahlberg/libnfs 2015-05-24 07:05:38 -07:00