Fix compilation issues in abstract_atomic

pick from 5473441f67a1484

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix compilation if DBUS is not used.

pick from 5473441f67a1484f

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Handle ESRCH error in VFS's posix2fsal_error()

Signed-off-by: Amit Dror <amitd@infinidat.com>
Fix compiler/linker errors on dev_22 when built with -DUSE_9P=OFF.

Signed-off-by: Sachin Bhamare <sbhamare@panasas.com>
(cherry picked from commit f3f2c12c3f65d7171a28a5733ab2d4faffe5e330)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Get rid of unused function definitions.

Signed-off-by: Sachin Bhamare <sbhamare@panasas.com>
(cherry picked from commit 76f0805f1516b927cf14582d1107fc3784014004)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Add definitions of two new syscalls to be used on FreeBSD platform.

This commit adds definitions of following 2 syscalls which are essentially
by-handle versions for link and readlink.
1. fhlink() -- Link file by handle.
2. fhreadlink() -- Read the symbolic link by handle.

Signed-off-by: Sachin Bhamare <sbhamare@panasas.com>
(cherry picked from commit 756848d87616e77b1c424949ee351e5b1f8fb6d0)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Add link_by_handle and readlink_by_handle APIs.

link_by_handle() on freebsd translates to fhlink(), a newly added syscall.
link_by_handle() on linux doesn't change current semantics and continues to use
linkat() with empty path name under the hood.

readlink_by_handle() on freebsd translates to fhreadlink(), a newly added
syscall.
readlink_by_handle() on linux doesn't change current semantics and continues to
use readlinkat() with empty path name under the hood.

Signed-off-by: Sachin Bhamare <sbhamare@panasas.com>
(cherry picked from commit 32d1c0b67cbc14035f7b0ac5477b076a322c8337)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Re-work VFS FSAL handle code to use newly added by-handle APIs in OS layer.

This commit fixes some places in the VFS FSAL handle code where linkat() and
readlinkat() calls were used with empty path names.
Since FreeBSD doesn't support empty path names in at-syscalls, we ended up
using new syscalls in FreeBSD which allow us to link() and readlink() by handle
instead.
On linux platform, these by-handle APIs continue to use linkat() and
readlinkat() with emprty path names as before.

Signed-off-by: Sachin Bhamare <sbhamare@panasas.com>
(cherry picked from commit 656ec5d01ad71bba0b3b2b5cdff0658538260ef5)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Merge commit '35907ede5090' from linuxbox2/next into merge_next

Dropped  Optimize Idmapper 7caee8906b67 dute to build probs.  Confirmed
with aemerson

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P/RDMA: Protect send buffers against early re-use

For 9P/RDMA, ganesha has two sets of buffers : recv and send buffers.
Each recv buffer is associated to a send buffer.
When a request is received on a recv buffer, it is processed and the associated
send buffer is used to send the reply.

But the current code fails to check that the previous message that was to be
sent using this send buffer has actually been sent and that this buffer can
be reused. In case of high traffic, this leads to buffer overwriting and
duplicate messages.

This patch adds a mutex to each buffer. Before processing a request, the mutex
is taken, and it will be released after the reply has been sent. If another request
wants to use the send buffer, it will have to wait for the message to be really
sent.

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 859bca0298ebc7010bf11ee511ec90c2719e0ddc)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P/RDMA: unlock buffer also when send fails

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 6d53d09b2242da497d3b2a3a3d5687c4de8b34c3)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: Implement msize negotiation in TVERSION

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 4f2dbe96c100c03322146a12438e6e729bba06d4)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: Add lower bound to msize

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 849b9ca52ce755ae3d971290007793e89b0ad9d9)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: use negotiated msize instead of _9P_MSG_SIZE

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 5c57618a678da92e1f9ce5deb567437734b35e91)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P/RDMA: increase max message size to 1MB

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 44e447ffd763c5bcc1dbc805f239f660dade8cd4)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: read data directly into the outgoing buffer, remove the extra copy.

We didn't know what buffer size to use anyway.
This also allows us to kill _9P_SEND_BUFFER_SIZE,
_9P_RECV_BUFFER_SIZE and _9p_READ_BUFFER_SIZE.

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 6e053840c00476e05fa0cc6396c45c829fb7b863)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: read : check count against msize

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit 2b5700fc7865659a68295eef501e348e3a2a3f5a)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: write : check count against msize

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit b6df1fc3aab4d3219ab3fe4161d2480f47d628e8)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: readdir : check count against msize

Also kill _9P_MAXDIRCOUNT
There is probably no reason to keep it since msize will
limit the request size anyway.

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit e3fe8f32cd0d333ea74520756bb794c8ba9dd352)

Signed-off-by: Jim Lieb <jlieb@panasas.com>
9P: Cleanups, documentation and cosmetic changes in 9p.h

Signed-off-by: Simon Derr <simon.derr@bull.net>
(cherry picked from commit d0886dcbaa6d622d65e392ecb5f68d459ef5a9f8)

Signed-off-by: Jim Lieb <jlieb@panasas.com>