Commit Graph

971 Commits (65de83140aa6264b75a8cb5eda9e0ba1b1f56b9b)

Author SHA1 Message Date
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
Ronnie Sahlberg b5f961c076 Dir cache: compare also mtime.nseconds when validating the cache
Compare BOTH the seconds field and the nanoseconds field when checking if
the cached directory structure is valid or not.
Linux knfsd and other modern servers actually do set the nanosecond field
so why not check it.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-06 16:04:03 -08:00
Ronnie Sahlberg 4476f11b9d Try to avoid allocating memory during zdr string decoding
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:16:35 -08:00
Ronnie Sahlberg 62daa224d9 Remove the zdr_malloc call when decoding a BYTES blob
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:15:20 -08:00
Ronnie Sahlberg e3cf674856 Use a single allocation for zdr_mem and the payload
Lets use a single allocation instead of two in the zdr_mem handler.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:13:47 -08:00
Ronnie Sahlberg 8c391edb17 Use a single allocation for both rpc_pdu and zde_decode_buf
We can save one malloc by storing both the rpc_pdu and decoding buffer
in the same memory block.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:12:36 -08:00
Ronnie Sahlberg 04363a9274 New version 1.10.0
The biggest changes in this release are:
 - Fix a leak where we leaked one rdpe_cb_data structure on each open_dir()
 - Make building the utils optional
 - Android: the correct define is __ANDROID__ not ANDROID
 - Win32: Use _U_ instead of ATTRIBURE((unused))
 - Win32: Fix nfs_stat declaration for Win32
 - Various fixes for mingw builds
 - Make rpc->connect_cb a one shot callback and improve documentation
 - Remove the FUSE module. It now lives in its own repo
 - Fix POLLERR/POLLHUP handling to properly handle session failures and to
   try to auto-reconnect

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:06:44 -08:00
Ronnie Sahlberg 49eaca0c42 Includes: Don't install win32/win32_compat.h
This header should only be used for building libnfs and should
not be installed.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:06:44 -08:00
Ronnie Sahlberg d827447242 Don't leak a rpde_cb_data structure on each opendir()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-16 18:37:07 -08:00
Ronnie Sahlberg ae236110d1 Merge pull request #134 from jbkempf/readme_update
Readme update
2016-01-16 11:56:46 -08:00
Jean-Baptiste Kempf f29382d03c README: mention Android 2016-01-16 19:16:35 +01:00
Jean-Baptiste Kempf 4324dcb846 README: mention MingW to cross-compile 2016-01-16 19:14:03 +01:00
Jean-Baptiste Kempf ab0b9b1f88 README: remove tabs and trailing spaces 2016-01-16 19:11:27 +01:00
Ronnie Sahlberg 66876e2879 Merge pull request #131 from jbkempf/win32_mingw
Support Win32 compilation with Mingw
2016-01-16 08:51:31 -08:00
Ronnie Sahlberg 9472c8a593 Merge pull request #133 from fkuehne/noutils-featurebranch
Add a configure option to disable the utils compilation
2016-01-16 08:48:12 -08:00
Felix Paul Kühne 0dc008ab93 Add a configure option to disable the utils compilation
For some targets like iOS, utils are not useable, so it should be possible to disable their compilation
2016-01-14 17:02:53 +01:00
Ronnie Sahlberg d337e4634e Merge pull request #132 from jbkempf/android_ndk
The correct NDK define for Android is __ANDROID__
2016-01-09 13:31:04 -08:00
Jean-Baptiste Kempf d02d5d0f5e The correct NDK define for Android is __ANDROID__
The ANDROID macro is not recommended
2016-01-09 13:35:11 +01:00
Diego Elio Pettenò 215b6eab13 win32: instead of ATTRIBUTE(unused) use _U_ to mark dummy as unused. 2016-01-08 23:43:07 +01:00
Diego Elio Pettenò 7744df2c76 build: enable subdir-objects option to make sure that source files are built where expected. 2016-01-08 23:43:06 +01:00
Diego Elio Pettenò 6b5b09dbc1 build: avoid abusing AM_LDFLAGS.
This fixes build with options such as --as-needed that require correct positional argument passing. They also ensure that the right dependency library is used.
2016-01-08 23:43:06 +01:00
Jean-Baptiste Kempf 4f0d26258e Win32: Fix nfs_stat declaration for Win32
So that the definition and declaration match.

There might be another way, with stat64i32 but I'm not confident it will
work with MSVC
2016-01-08 23:41:56 +01:00
Jean-Baptiste Kempf 3c37d03f4b Win32: do not compile nfs-cp in utils
It depends on stat features that are not available
2016-01-08 23:23:00 +01:00
Jean-Baptiste Kempf cd53647f53 Win32: link utils with winsock2 2016-01-08 23:23:00 +01:00