Ross Lagerwall [Sun, 14 Sep 2014 14:41:04 +0000 (15:41 +0100)]
libnfs: Add access2()
Add nfs_access2(), like nfs_access() but it returns the individual
statuses of R_OK, W_OK and X_OK rather than a single success or failure
status. This saves the latency and overhead of multiple lookups if an
application tries to determine the status of each of R_OK, W_OK and
X_OK.
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Ronnie Sahlberg [Sat, 16 Aug 2014 21:51:53 +0000 (14:51 -0700)]
types: remove the [u_]quad type and replace with [u]int64
All current platforms have a quad type that maps to a 64bit scalar.
But there are platforms where quad maps to a 64bit non-scalar.
Replace quad with int64 in the protocol definitions and the ZDR layer
so that these fields will map to a 64 bit scalar also on those platforms
where quad can not be used.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Mike Frysinger [Tue, 4 Dec 2012 03:30:04 +0000 (22:30 -0500)]
fix implicit decl warnings
Include the proper headers to fix warnings like:
libnfs-sync.c:1529:3: warning: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
libnfs-zdr.c:506:2: warning: implicit declaration of function 'getuid' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sys/time.h needs to be protected with an ifdef
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Ross Lagerwall [Fri, 8 Aug 2014 19:14:44 +0000 (20:14 +0100)]
Map NFS3ERR_NOTEMPTY to ENOTEMPTY
Map NFS3ERR_NOTEMPTY to ENOTEMPTY rather than EEXIST. POSIX allows
either EEXIST or ENOTEMPTY for rmdir on a non-empty directory but
ENOTEMPTY is more explicit and in line with Linux, OS X, FreeBSD and
OpenBSD's behavior.
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Ross Lagerwall [Sun, 27 Jul 2014 17:01:25 +0000 (18:01 +0100)]
libnfs.c: Follow symlinks during path resolution
Follow symlinks during path resolution. If the symlink points outside
the mount, -ENOENT is returned. This is slightly different behavior
from the in-kernel NFS client where symlinks pointing outside the mount
get resolved to local paths.
The algorithm for symlink resolution is simple and stupid. If a symlink
is encountered, the path is rewritten and path resolution begins again
from the root filehandle. A count is kept to prevent loops. This is
not particularly efficient but it is good enough for now.
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Ross Lagerwall [Sun, 20 Jul 2014 20:39:06 +0000 (21:39 +0100)]
libnfs: Set as much stat information as possible
Set as much stat information as possible for stat, stat64, fstat and
readdir.
Fill in dev to the given fsid.
Fill in rdev to the given major and minor numbers.
Set the file type bits in the mode from the type returned by the server.
Set the number of blocks used based on the number of bytes used in
blocks of size 512 (which is what stat(2) uses), rounded up.
Fill in the nanosecond timestamps.
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Ross Lagerwall [Thu, 17 Jul 2014 21:31:23 +0000 (22:31 +0100)]
libnfs.c: add nfs_create
Add a new family of functions, nfs_create, like nfs_creat but takes an
additional flags argument which allows extra flags like O_SYNC, O_EXCL
and O_APPEND to be specified.
Ronnie Sahlberg [Sun, 29 Jun 2014 21:57:45 +0000 (14:57 -0700)]
New version 1.9.4
New version of libnfs:
- IPv6 support
- Support for Portmapper version 3 and an example portmap client.
- Directory caching top make repeated opendir() calls faster
- Readahead support
- Build manpages for the utilities (==nfs-ls)
- Support for O_APPEND
- Rename the list macros to avoid collission on *BSD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Peter Lieven [Mon, 23 Jun 2014 14:31:32 +0000 (16:31 +0200)]
add readahead support
This patch add support for an internal readahead machanism. The maximum readahead
size can be specified via URL parameter readahead. This should significantly
speed up small sequential reads.
Ronnie Sahlberg [Sun, 8 Jun 2014 16:45:22 +0000 (09:45 -0700)]
libnfs.c: always pass the attributes to the callback for recursive lookups
Always pass a fattr3 structure to the callbacks for the internal function
to perform recursive lookups : nfs_lookuppath_async().
This will allow us to access for example the mtime for an object before we
start performing any expensive functions.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Ronnie Sahlberg [Sun, 8 Jun 2014 14:21:43 +0000 (07:21 -0700)]
init.c: use list macro when removing pdus from the wait list
Use the macro when removing the pdus in the wait list from the queues.
Also make sure to remove them from the right queue, from waitqueue and not
the outqueue for PDUs we have already sent out.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Ronnie Sahlberg [Thu, 15 May 2014 02:04:43 +0000 (19:04 -0700)]
docs: add a prebuilt manpage to the distribution
Add a prebuilt manpage for nfs-ls and change the makefiles to not build the
manpage by default. This is because the manpages change rarely and this removes
the need for an internet connection when building the library.
(previously building the library required downloading a template from
sourceforge)
Update the README and mention that you now need to manually rebuild the
manpages if the manpage sources change.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Arne Redlich [Mon, 31 Mar 2014 21:40:26 +0000 (23:40 +0200)]
Fix the file position handling of the read and write calls
Since the interface is modelled after the libc calls we should try to match
their behaviour to avoid unpleasant surprises:
* read / write (sync and async flavours) update the file position
* pread / pwrite (sync and async flavours) do not update the file position
.
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
Arne Redlich [Mon, 31 Mar 2014 21:35:38 +0000 (23:35 +0200)]
libnfs-sync: nfs_{read,write}: use their _async counterparts internally
Previously nfs_read and nfs_write used to use nfs_pread and nfs_pwrite respectively.
In preparation of getting the file position handling right this has to be detangled.
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
Mark Hills [Thu, 20 Feb 2014 14:02:08 +0000 (14:02 +0000)]
Track waiting requests in a hash table, by xid
NFS servers can respond to requests in any order, and they do. In our
tests there is also some clustering to the responses; it could be
because eg. requests are served synchronously if the data is in the cache.
Introduce a hash table so that we are able to find the pdu quickly in
all cases, assuming random distribution of the responses.
Mark Hills [Thu, 27 Feb 2014 12:52:54 +0000 (12:52 +0000)]
Ensure the next pointer is correct
Fixes a bug where the next pointer was not being explicitly set. We
were ok much of the time due to zero-filled memory, and also we need
this if the same pdu is re-queued.
Mark Hills [Tue, 7 Jan 2014 10:23:46 +0000 (10:23 +0000)]
Optimisations to the pdu queues
When making many concurrent requests (as is likely in any performance
criticial application), the use of SLIST_REMOVE and SLIST_ADD_END are
a severe bottleneck because of their linear search.
I considered using a double-linked list but it was unnecessary to
allocate the additional memory for each list entry.
Instead, continue to use a single-linked list but retain:
* a pointer to the end of the list; and
* a pointer to the previous entry during a linear search.
The former would makes append operations O(1) time, and the latter
does the same for removal. We can do this because removal only happens
within the linear search, and there is no random access to the queue.