Commit Graph

944 Commits (e27453b4a96dcad4b18e04fd62d639c67b55cad0)

Author SHA1 Message Date
Ronnie Sahlberg b70d5b6dac WIN32: No need to run rpcgen.exe anymore. Remove from project.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-20 18:09:25 -07:00
Ronnie Sahlberg fc2501dc45 Merge branch 'master' of github.com:sahlberg/libnfs 2016-09-20 17:45:37 -07:00
sahlberg e53758fc43 compiler warnings 2016-09-20 17:45:05 -07:00
sahlberg 6d3e9814fa more win32 fixes 2016-09-20 17:44:42 -07:00
sahlberg c672db8351 WIN32: Use size_t for the rpc fragment size 2016-09-20 17:43:53 -07:00
sahlberg 563c112343 WIN32: fix compile warnings in nfs.c 2016-09-20 17:43:26 -07:00
Ronnie Sahlberg 53f634468c WIN32: Update the path to nfs-{cp|ls}.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-20 17:42:46 -07:00
sahlberg b741a44f81 WIN32: Add portmap to more include directives 2016-09-20 17:40:18 -07:00
sahlberg 4c3d809e07 WIN32: Don't call assert() before all variables are declared.
VisualStudioOnline does not like when you intermingle variable
definitions and code so move the assert() to after the variables
are all declared.
2016-09-20 17:37:48 -07:00
sahlberg 799abde68d WIN32: win32 does not have IFNAMSIZ 2016-09-20 17:36:59 -07:00
Ronnie Sahlberg 6cde2aca64 Conditionally include unistd.h from libnfs-zdr.c as some platforms lack this header
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-20 17:36:19 -07:00
Ronnie Sahlberg b0c3cb3415 Conditionally include unistd.h from libnfs-zdr.c a some platforms lack this header
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-19 18:36:59 -07:00
Chris 5f75307a36 Added the ability to bind to a specific interface with the
`nfs_set_interface` and `rpc_set_interface` APIs, or via the
NFS URL `if=<interface>` parameter. This feature requires
`root` permissions.

NOTE: This has only been compiled and tested on Ubuntu 14.04. It's
unlikely that it'll work on other platforms without modification,
particularly around the inclusion of <net/if.h> and IFNAMSIZ define
in `libnfs-private.h`.
2016-09-19 18:31:49 -07:00
Ronnie Sahlberg fac3a95453 Make rpc_disconnect() a no-op if the session is already disconnected
This addresses a bug causing a segfault if we destroy the nfs context/
disconnect the session while the mount_8_cb callbacks for checking the
filehandle for nested mountpoints are still in flight.

Issue found and reported by doktorstick

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-05 13:18:17 -07:00
Ronnie Sahlberg 28e01e67b1 Add seekdir and telldir support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-05 10:14:49 -07:00
Ronnie Sahlberg cdbcdfd736 Update some comment and fix typos
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-07-05 09:59:30 -07:00
Ronnie Sahlberg d9e75d56fa Add comment that nfs_rewinddir will never block.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-21 19:30:00 -07:00
Ronnie Sahlberg 4388570dc4 Merge pull request #151 from benoit-canet/rewinddir
nfs_rewinddir: introduce additional nfs_rewinddir()
2016-06-21 19:28:20 -07:00
Ronnie Sahlberg 4cc09b972a Fix crash in nfs_truncate due to dereference of uninitialized data
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-21 19:25:27 -07:00
Benoît Canet 352fb5bb70 nfs_rewinddir: introduce additional nfs_rewinddir()
Introduce the nfs_rewinddir() utility function used
to cancel previous nfs_readdir() side effects.

Signed-off-by: Benoît Canet <benoit@scylladb.com>
2016-06-07 08:36:27 +02:00
Ronnie Sahlberg cdd1643c76 Merge pull request #150 from plieven/for_upstream
For upstream
2016-06-03 05:07:45 -07:00
Peter Lieven 10546da322 pagecache: define hash constant as UL
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-06-03 13:46:48 +02:00
Ronnie Sahlberg f9455e5ba5 gcc 5.3 does not allow casting a char * to any longer, so cast via void *
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-06-02 09:20:54 +02:00
Peter Lieven 9cb49494c7 pdu: drop the rpc->encodebuf
the only call thar really needs a big encodebuf is WRITE. So give each
PDU its private encodebuf. This avoids the need to memcpy the data from
the static rpc->encodebuf to the pdu->outdata.data.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-06-02 09:12:53 +02:00
Peter Lieven 21c466254a libnfs: avoid a bounce buffer in pread if possible
there are cases where we do not need the bounce buffer. So avoid
the overhead of malloc, memcpy and free.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-31 22:03:02 +02:00
Peter Lieven 14492d5c65 pagecache: allow readahead and pagecache options to coexist
before this setting readahead would always modify the pagecache,
but it might be desireable to have a greater pagecache and only
a reasonable small readahead.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-31 12:05:20 +02:00
Peter Lieven 5a660d5afc libnfs-sync: make send_nfsd_probes portable
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-31 12:03:10 +02:00
Peter Lieven 36d687cdbc pagecache: avoid time() syscall if the cache has no ttl
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-31 08:34:17 +02:00
Ronnie Sahlberg 654243473a Merge pull request #148 from plieven/fix_hang
Fix deadlock once again
2016-05-30 09:27:05 -07:00
Peter Lieven 453db33f07 pdu: fix potential overflow in rpc_get_pdu_size
(size & 0x7fffffff) + 4 can overflow an int returning
a negative number.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-30 16:13:39 +02:00
Peter Lieven 295057aba4 socket: really handle count == 0 in rpc_read_from_socket
in commit b319b97 the check for count == 0 was introduced, but
it was accidently reverted in commit f681a2c if pdu->inpos < 4.

This patch fixes this issue resulting in deadlocks and removes
the somewhat redundant receive code.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-30 16:13:32 +02:00
Ronnie Sahlberg 00d9ba1563 Remove rpc_set_tcp_syncnt from the nfs-cat utility
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-17 18:38:30 -07:00
Ronnie Sahlberg cef46f4803 Merge pull request #146 from plieven/pagecache_v2
Pagecache v2
2016-05-17 06:18:26 -07:00
Peter Lieven 922ae3ef4d libnfs: fix compiler warnings on 32bit systems
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-17 09:10:22 +02:00
Peter Lieven 3e2847226f libnfs: add a pagecache
this adds support for a simple read cache to avoid unnecassary request
to the NFS storage. libnfs by design cannot benefit from the kernel page
cache and suffers from performance penalties in some cases when compared
with a file accessed via kernel NFS.

This patch exposes 3 new API calls:
 void nfs_set_pagecache(struct nfs_context *nfs, uint32_t v);
 void nfs_set_pagecache_ttl(struct nfs_context *nfs, uint32_t v);
 void nfs_pagecache_invalidate(struct nfs_context *nfs, struct nfsfh *nfsfh);

As well as the two new URL parameters pagecache and pagecache_ttl.

pagecache is defined in number of pages where a page is always NFS_BLKSIZE (4kB).
pagecache_ttl takes the page timeout in seconds where 0 means infinite.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-13 12:03:40 +02:00
Peter Lieven 77d592c8e9 configure.ac: really build with -Werror by default
Signed-off-by: Peter Lieven <pl@kamp.de>
2016-05-13 10:38:45 +02:00
Ronnie Sahlberg b3c4106022 Add win32 magics to example programs
Some examples lack win32 socket magic. Add it.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-04-27 19:32:16 -07:00
Ronnie Sahlberg a5408bfa09 zdr string decode: don't memcpy when src and dst pointers are the same
If we are decoding a zdr string and the called did not provide
a pointer/buffer for us. We can just return the string to the rx buffer
immediately and avoid calling libnfs_zdr_opaque().

This avoids wasting cpu cycles on running a memcpy where src and dst buffers
are the same.
2016-03-21 22:06:59 -07:00
Ronnie Sahlberg 3c26ce1e6b Merge pull request #143 from jbkempf/android_ndk_statvfs
Android: only redefine statvfs if it is not already defined
2016-03-14 19:16:28 -07:00
Ronnie Sahlberg 936b8ec588 Merge branch 'master' of github.com:sahlberg/libnfs 2016-03-14 19:15:11 -07:00
Kuldeep Kumar 83d1005c6b sync apis with timeout values
Add support to timeout sync functions.
Add a field to the rpc context to specify the timeout for functions.
Currently only sync functions support a timeout.
2016-03-14 19:04:53 -07:00
Dirk Jagdmann 1c13afae56 fix spelling errors. 2016-03-14 18:47:54 -07:00
Jean-Baptiste Kempf 41c41aec0b Android: only redefine statvfs if it is not already defined
It is defined with recent platforms version 21 and more recent
2016-03-11 00:09:16 +01:00
Ronnie Sahlberg eebe56cee7 Merge branch 'master' of github.com:sahlberg/libnfs 2016-02-24 18:06:52 -08:00
Ronnie Sahlberg 8372dbe7d1 Discard readahead cache on pwrite and truncate too
Reported by Dirk Jagdmann

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-24 18:03:48 -08:00
Ronnie Sahlberg 2927ce048c Merge pull request #139 from doj/master
fix spelling errors.
2016-02-13 19:48:35 -08:00
Ronnie Sahlberg cb923a2f54 link/rename uses two directories. We must drop both drom the dircache.
Link and Rename are special since they will process two (often) different
directories. We need to drop both directories from the cache and also do so
BEFORE we clear/steal the data->fh.data.data_val pointer.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-10 22:43:35 -08:00
Dirk Jagdmann 0623dabf1e fix spelling errors. 2016-02-10 15:06:08 -08:00
Ronnie Sahlberg 458f6c2be5 Add option and method to disable/enable directory caching
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-07 16:06:00 -08:00
Ronnie Sahlberg 6d5628bcab Drop the directory cache if we do things that stalify the data
Add calls to explicitely drop the directory cache everytime we do things
that might make the data stale.
Such as adding / removing objects to a directory, changing metadata for
objects etc.

Instead of just dropping the cache, we could use the wcc data.
IF wcc->before is the same timestamp as what we have in the cache
then we can just perform the same mutate on what we have in the cache
to reflect the new state and bump the timestamp of the cache to be wcc->after.
That would be a lot of work though and I am not convinced it is worth it.
After all, the cache is just an optimization to make directory operation
faster.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-06 16:26:35 -08:00