GitHub/LineageOS/android_kernel_motorola_exynos9610.git
12 years agopnfs-obj: Uglify objio_segment allocation for the sake of the principle :-(
Boaz Harrosh [Wed, 14 Mar 2012 03:44:26 +0000 (20:44 -0700)]
pnfs-obj: Uglify objio_segment allocation for the sake of the principle :-(

At some past instance Linus Trovalds wrote:
> From: Linus Torvalds <torvalds@linux-foundation.org>
> commit a84a79e4d369a73c0130b5858199e949432da4c6 upstream.
>
> The size is always valid, but variable-length arrays generate worse code
> for no good reason (unless the function happens to be inlined and the
> compiler sees the length for the simple constant it is).
>
> Also, there seems to be some code generation problem on POWER, where
> Henrik Bakken reports that register r28 can get corrupted under some
> subtle circumstances (interrupt happening at the wrong time?).  That all
> indicates some seriously broken compiler issues, but since variable
> length arrays are bad regardless, there's little point in trying to
> chase it down.
>
> "Just don't do that, then".

Since then any use of "variable length arrays" has become blasphemous.
Even in perfectly good, beautiful, perfectly safe code like the one
below where the variable length arrays are only used as a sizeof()
parameter, for type-safe dynamic structure allocations. GCC is not
executing any stack allocation code.

I have produced a small file which defines two functions main1(unsigned numdevs)
and main2(unsigned numdevs). main1 uses code as before with call to malloc
and main2 uses code as of after this patch. I compiled it as:
gcc -O2 -S see_asm.c
and here is what I get:

<see_asm.s>
main1:
.LFB7:
.cfi_startproc
mov %edi, %edi
leaq 4(%rdi,%rdi), %rdi
salq $3, %rdi
jmp malloc
.cfi_endproc
.LFE7:
.size main1, .-main1
.p2align 4,,15
.globl main2
.type main2, @function
main2:
.LFB8:
.cfi_startproc
mov %edi, %edi
addq $2, %rdi
salq $4, %rdi
jmp malloc
.cfi_endproc
.LFE8:
.size main2, .-main2
.section .text.startup,"ax",@progbits
.p2align 4,,15
</see_asm.s>

*Exact* same code !!!

So please seriously consider not accepting this patch and leave the
perfectly good code intact.

CC: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: null dereference in dev_remove()
Dan Carpenter [Tue, 13 Mar 2012 17:18:48 +0000 (20:18 +0300)]
NFS: null dereference in dev_remove()

In commit 5ffaf85541 "NFS: replace global bl_wq with per-net one" we
made "msg" a pointer instead of a struct stored in stack memory.  But we
forgot to change the memset() here so we're still clearing stack memory
instead clearing the struct like we intended.  It will lead to a kernel
crash.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Rate limit the state manager warning messages
Trond Myklebust [Mon, 12 Mar 2012 22:01:48 +0000 (18:01 -0400)]
NFSv4: Rate limit the state manager warning messages

Prevent the state manager from filling up system logs when recovery
fails on the server.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org
12 years agoSUNRPC: Don't use variable length automatic arrays in kernel code
Trond Myklebust [Mon, 12 Mar 2012 17:29:05 +0000 (13:29 -0400)]
SUNRPC: Don't use variable length automatic arrays in kernel code

Replace the variable length array in the RPCSEC_GSS crypto code with
a fixed length one. The size should be bounded by the variable
GSS_KRB5_MAX_BLOCKSIZE, so use that.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Check return value from rpc_queue_upcall()
Bryan Schumaker [Mon, 12 Mar 2012 15:33:00 +0000 (11:33 -0400)]
NFS: Check return value from rpc_queue_upcall()

This function could fail to queue the upcall if rpc.idmapd is not running,
causing a warning message to be printed.  Instead, I want to check the
return value and revoke the key if the upcall can't be run.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Only define some function when v4.1 is enabled
Bryan Schumaker [Mon, 12 Mar 2012 15:28:24 +0000 (11:28 -0400)]
NFS: Only define some function when v4.1 is enabled

Now that the nfs4_cb_match_client() function is static, gcc notices that
it is only used when CONFIG_NFS_V4_1 is enabled.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Fix a few sparse warnings
Trond Myklebust [Sun, 11 Mar 2012 19:22:54 +0000 (15:22 -0400)]
SUNRPC: Fix a few sparse warnings

net/sunrpc/svcsock.c:412:22: warning: incorrect type in assignment
(different address spaces)
 - svc_partial_recvfrom now takes a struct kvec, so the variable
   save_iovbase needs to be an ordinary (void *)

Make a bunch of variables in net/sunrpc/xprtsock.c static

Fix a couple of "warning: symbol 'foo' was not declared. Should it be
static?" reports.

Fix a couple of conflicting function declarations.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Fix a number of sparse warnings
Trond Myklebust [Sun, 11 Mar 2012 17:11:00 +0000 (13:11 -0400)]
NFS: Fix a number of sparse warnings

Fix a number of "warning: symbol 'foo' was not declared. Should it be
static?" conditions.

Fix 2 cases of "warning: Using plain integer as NULL pointer"

fs/nfs/delegation.c:263:31: warning: restricted fmode_t degrades to integer
  - We want to allow upgrades to a WRITE delegation, but should otherwise
    consider servers that hand out duplicate delegations to be borken.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: replace global bl_wq with per-net one
Stanislav Kinsbursky [Sun, 11 Mar 2012 14:20:31 +0000 (18:20 +0400)]
NFS: replace global bl_wq with per-net one

This queue is used for sleeping in kernel and it have to be per-net since we
don't want to wake any other waiters except in out network nemespace.
BTW, move wq to per-net data is easy. But some way to handle upcall timeouts
have to be provided. On message destroy in case of timeout, tasks, waiting for
message to be delivered, should be awakened. Thus, some data required to
located the right wait queue. Chosen solution replaces rpc_pipe_msg object with
new introduced bl_pipe_msg object, containing rpc_pipe_msg and proper wq.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: replace global bl_mount_reply with per-net one
Stanislav Kinsbursky [Sun, 11 Mar 2012 14:20:23 +0000 (18:20 +0400)]
NFS: replace global bl_mount_reply with per-net one

This global variable is used for blocklayout downcall and thus can be corrupted
if case of existence of multiple networks namespaces.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: remove nfs_inode radix tree
Fred Isaman [Thu, 8 Mar 2012 22:29:35 +0000 (17:29 -0500)]
NFS: remove nfs_inode radix tree

The radix tree is only being used to compile lists of reqs needing commit.
It is simpler to just put the reqs directly into a list.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: remove NFS_PAGE_TAG_LOCKED
Fred Isaman [Thu, 8 Mar 2012 22:29:34 +0000 (17:29 -0500)]
NFS: remove NFS_PAGE_TAG_LOCKED

The last real use of this tag was removed by
commit 7f2f12d963 NFS: Simplify nfs_wb_page()

Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.0: Re-establish the callback channel on NFS4ERR_CB_PATHDOWN
Trond Myklebust [Sat, 10 Mar 2012 16:23:15 +0000 (11:23 -0500)]
NFSv4.0: Re-establish the callback channel on NFS4ERR_CB_PATHDOWN

When the NFSv4.0 server tells us that it can no-longer talk to us
on the callback channel, we should attempt a new SETCLIENTID in
order to re-transmit the callback channel information.

Note that as long as we do not change the boot verifier, this is
a safe procedure; the server is required to keep our state.

Also move the function nfs_handle_cb_pathdown to fs/nfs/nfs4state.c,
and change the name in order to mark it as being specific to NFSv4.0.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Clean up nfs4_select_rw_stateid()
Trond Myklebust [Thu, 8 Mar 2012 22:42:01 +0000 (17:42 -0500)]
NFSv4: Clean up nfs4_select_rw_stateid()

Ensure that we select delegation stateids first, then
lock stateids and then open stateids.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Don't copy read delegation stateids in setattr
Trond Myklebust [Thu, 8 Mar 2012 22:16:12 +0000 (17:16 -0500)]
NFS: Don't copy read delegation stateids in setattr

The server will just return an NFS4ERR_OPENMODE anyway.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1 cleanup DS stateid error handling
Andy Adamson [Thu, 8 Mar 2012 16:03:53 +0000 (11:03 -0500)]
NFSv4.1 cleanup DS stateid error handling

The error handler nfs4_state parameter is never NULL in the pNFS case as
the open_context must carry an nfs_state.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Return the delegation if the server returns NFS4ERR_OPENMODE
Trond Myklebust [Wed, 7 Mar 2012 21:39:06 +0000 (16:39 -0500)]
NFSv4: Return the delegation if the server returns NFS4ERR_OPENMODE

If a setattr() fails because of an NFS4ERR_OPENMODE error, it is
probably due to us holding a read delegation. Ensure that the
recovery routines return that delegation in this case.

Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org
12 years agoNFSv4: Don't free the nfs4_lock_state until after the release_lockowner
Trond Myklebust [Wed, 7 Mar 2012 18:49:12 +0000 (13:49 -0500)]
NFSv4: Don't free the nfs4_lock_state until after the release_lockowner

Otherwise we can end up with sequence id problems if the client reuses
the owner_id before the server has processed the release_lockowner

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1 handle DS stateid errors
Andy Adamson [Wed, 7 Mar 2012 15:49:41 +0000 (10:49 -0500)]
NFSv4.1 handle DS stateid errors

Handle DS READ and WRITE stateid errors by recovering the stateid on the MDS.

NFS4ERR_OLD_STATEID is ignored as the client always sends a
state sequenceid of zero for DS READ and WRITE stateids.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: add fh_crc to debug output
Weston Andros Adamson [Wed, 7 Mar 2012 02:58:20 +0000 (21:58 -0500)]
NFS: add fh_crc to debug output

Print the filehandle crc in two debug messages

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: add filehandle crc for debug display
Weston Andros Adamson [Wed, 7 Mar 2012 01:46:43 +0000 (20:46 -0500)]
NFS: add filehandle crc for debug display

Match wireshark's CRC-32 hash for easier debugging

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add a helper encode_uint64
Trond Myklebust [Mon, 5 Mar 2012 16:40:12 +0000 (11:40 -0500)]
NFSv4: Add a helper encode_uint64

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: More xdr cleanups
Trond Myklebust [Mon, 5 Mar 2012 16:27:16 +0000 (11:27 -0500)]
NFSv4: More xdr cleanups

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Cleanup - convert more functions to use encode_op_hdr
Trond Myklebust [Mon, 5 Mar 2012 01:49:32 +0000 (20:49 -0500)]
NFSv4: Cleanup - convert more functions to use encode_op_hdr

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Fix nfs4_verifier memory alignment
Chuck Lever [Fri, 2 Mar 2012 22:14:31 +0000 (17:14 -0500)]
NFS: Fix nfs4_verifier memory alignment

Clean up due to code review.

The nfs4_verifier's data field is not guaranteed to be u32-aligned.
Casting an array of chars to a u32 * is considered generally
hazardous.

Fix this by using a __be32 array to generate a verifier's contents,
and then byte-copy the contents into the verifier field.  The contents
of a verifier, for all intents and purposes, are opaque bytes.  Only
local code that generates a verifier need know the actual content and
format.  Everyone else compares the full byte array for exact
equality.

Also, sizeof(nfs4_verifer) is the size of the in-core verifier data
structure, but NFS4_VERIFIER_SIZE is the number of octets in an XDR'd
verifier.  The two are not interchangeable, even if they happen to
have the same value.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add a encode op helper
Trond Myklebust [Sun, 4 Mar 2012 23:13:57 +0000 (18:13 -0500)]
NFSv4: Add a encode op helper

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add a helper for encoding NFSv4 sequence ids
Trond Myklebust [Sun, 4 Mar 2012 23:13:57 +0000 (18:13 -0500)]
NFSv4: Add a helper for encoding NFSv4 sequence ids

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Minor clean ups for encode_string()
Trond Myklebust [Sun, 4 Mar 2012 23:13:57 +0000 (18:13 -0500)]
NFSv4: Minor clean ups for encode_string()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Simplify the struct nfs4_stateid
Trond Myklebust [Sun, 4 Mar 2012 23:13:57 +0000 (18:13 -0500)]
NFSv4: Simplify the struct nfs4_stateid

Replace the union with the common struct stateid4 as defined in both
RFC3530 and RFC5661. This makes it easier to access the sequence id,
which will again make implementing support for parallel OPEN calls
easier.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add helpers for basic copying of stateids
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Add helpers for basic copying of stateids

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Rename nfs4_copy_stateid()
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Rename nfs4_copy_stateid()

It is really a function for selecting the correct stateid to use in a
read or write situation.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add a helper for encoding stateids
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Add a helper for encoding stateids

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Add a helper for encoding opaque data
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Add a helper for encoding opaque data

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Rename encode_stateid() to encode_open_stateid()
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Rename encode_stateid() to encode_open_stateid()

The current version of encode_stateid really only applies to open stateids.
You can't use it for locks, delegations or layouts.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Further clean-ups of delegation stateid validation
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4: Further clean-ups of delegation stateid validation

Change the name to reflect what we're really doing: testing two
stateids for whether or not they match according the the rules in
RFC3530 and RFC5661.
Move the code from callback_proc.c to nfs4proc.c

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Fix matching of the stateids when returning a delegation
Trond Myklebust [Sun, 4 Mar 2012 23:13:56 +0000 (18:13 -0500)]
NFSv4.1: Fix matching of the stateids when returning a delegation

nfs41_validate_delegation_stateid is broken if we supply a stateid with
a non-zero sequence id. Instead of trying to match the sequence id,
the function assumes that we always want to error. While this is
true for a delegation callback, it is not true in general.

Also fix a typo in nfs4_callback_recall.

Reported-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Properly handle the case where the delegation is revoked
Trond Myklebust [Tue, 6 Mar 2012 00:56:44 +0000 (19:56 -0500)]
NFS: Properly handle the case where the delegation is revoked

If we know that the delegation stateid is bad or revoked, we need to
remove that delegation as soon as possible, and then mark all the
stateids that relied on that delegation for recovery. We cannot use
the delegation as part of the recovery process.

Also note that NFSv4.1 uses a different error code (NFS4ERR_DELEG_REVOKED)
to indicate that the delegation was revoked.

Finally, ensure that setlk() and setattr() can both recover safely from
a revoked delegation.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org
12 years agoNFS: Fix a typo in _nfs_display_fhandle
Trond Myklebust [Tue, 6 Mar 2012 15:14:35 +0000 (10:14 -0500)]
NFS: Fix a typo in _nfs_display_fhandle

The check for 'fh == NULL' needs to come _before_ we dereference
fh.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Fix a compile issue when !CONFIG_NFS_V4_1
Trond Myklebust [Sun, 4 Mar 2012 23:12:57 +0000 (18:12 -0500)]
NFS: Fix a compile issue when !CONFIG_NFS_V4_1

The attempt to display the implementation ID needs to be conditional on
whether or not CONFIG_NFS_V4_1 is defined

Reported-by: Bryan Schumaker <Bryan.Schumaker@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Undo changes to idmap.h
Bryan Schumaker [Mon, 5 Mar 2012 19:58:15 +0000 (14:58 -0500)]
NFS: Undo changes to idmap.h

When compiled without NFS v4 configured these function won't be defined
and the compiler will yell.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoMerge commit 'nfs-for-3.3-4' into nfs-for-next
Trond Myklebust [Sat, 3 Mar 2012 20:04:15 +0000 (15:04 -0500)]
Merge commit 'nfs-for-3.3-4' into nfs-for-next

Conflicts:
fs/nfs/nfs4proc.c

Back-merge of the upstream kernel in order to fix a conflict with the
slotid type conversion and implementation id patches...

12 years agoNFS: Reduce debugging noise from encode_compound_hdr
Chuck Lever [Fri, 2 Mar 2012 21:58:56 +0000 (16:58 -0500)]
NFS: Reduce debugging noise from encode_compound_hdr

Get rid of

  encode_compound: tag=

when XDR debugging is enabled.  The current Linux client never sets
compound tags.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Request fh_expire_type attribute in "server caps" operation
Chuck Lever [Thu, 1 Mar 2012 22:02:05 +0000 (17:02 -0500)]
NFS: Request fh_expire_type attribute in "server caps" operation

The fh_expire_type file attribute is a filesystem wide attribute that
consists of flags that indicate what characteristics file handles
on this FSID have.

Our client doesn't support volatile file handles.  It should find
out early (say, at mount time) whether the server is going to play
shenanighans with file handles during a migration.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Introduce NFS_ATTR_FATTR_V4_LOCATIONS
Chuck Lever [Thu, 1 Mar 2012 22:01:57 +0000 (17:01 -0500)]
NFS: Introduce NFS_ATTR_FATTR_V4_LOCATIONS

The Linux NFS client must distinguish between referral events (which
it currently supports) and migration events (which it does not yet
support).

In both types of events, an fs_locations array is returned.  But upper
layers, not the XDR layer, should make the distinction between a
referral and a migration.  There really isn't a way for an XDR decoder
function to distinguish the two, in general.

Slightly adjust the FATTR flags returned by decode_fs_locations()
to set NFS_ATTR_FATTR_V4_LOCATIONS only if a non-empty locations
array was returned from the server.  Then have logic in nfs4proc.c
distinguish whether the locations array is for a referral or
something else.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Simplify arguments of encode_renew()
Chuck Lever [Thu, 1 Mar 2012 22:01:48 +0000 (17:01 -0500)]
NFS: Simplify arguments of encode_renew()

Clean up: pass just the clientid4 to encode_renew().  This enables it
to be used by callers who might not have an full nfs_client.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Add a client-side function to display NFS file handles
Chuck Lever [Thu, 1 Mar 2012 22:01:31 +0000 (17:01 -0500)]
NFS: Add a client-side function to display NFS file handles

For debugging, introduce a simplistic function to print NFS file
handles on the system console.  The main function is hooked into the
dprintk debugging facility, but you can directly call the helper,
_nfs_display_fhandle(), if you want to print a handle unconditionally.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Make clientaddr= optional
Chuck Lever [Thu, 1 Mar 2012 22:01:23 +0000 (17:01 -0500)]
NFS: Make clientaddr= optional

For NFSv4 mounts, the clientaddr= mount option has always been
required.  Now we have rpc_localaddr() in the kernel, which was
modeled after the same logic in the mount.nfs command that constructs
the clientaddr= mount option.  If user space doesn't provide a
clientaddr= mount option, the kernel can now construct its own.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Add API to acquire source address
Chuck Lever [Thu, 1 Mar 2012 22:01:14 +0000 (17:01 -0500)]
SUNRPC: Add API to acquire source address

NFSv4.0 clients must send endpoint information for their callback
service to NFSv4.0 servers during their first contact with a server.
Traditionally on Linux, user space provides the callback endpoint IP
address via the "clientaddr=" mount option.

During an NFSv4 migration event, it is possible that an FSID may be
migrated to a destination server that is accessible via a different
source IP address than the source server was.  The client must update
callback endpoint information on the destination server so that it can
maintain leases and allow delegation.

Without a new "clientaddr=" option from user space, however, the
kernel itself must construct an appropriate IP address for the
callback update.  Provide an API in the RPC client for upper layer
RPC consumers to acquire a source address for a remote.

The mechanism used by the mount.nfs command is copied: set up a
connected UDP socket to the designated remote, then scrape the source
address off the socket.  We are careful to select the correct network
namespace when setting up the temporary UDP socket.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Move clnt->cl_server into struct rpc_xprt
Trond Myklebust [Thu, 1 Mar 2012 22:01:05 +0000 (17:01 -0500)]
SUNRPC: Move clnt->cl_server into struct rpc_xprt

When the cl_xprt field is updated, the cl_server field will also have
to change.  Since the contents of cl_server follow the remote endpoint
of cl_xprt, just move that field to the rpc_xprt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: simplify check_gss_callback_principal(), whitespace changes ]
[ cel: forward ported to 3.4 ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field
Trond Myklebust [Thu, 1 Mar 2012 22:00:56 +0000 (17:00 -0500)]
SUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field

A migration event will replace the rpc_xprt used by an rpc_clnt.  To
ensure this can be done safely, all references to cl_xprt must now use
a form of rcu_dereference().

Special care is taken with rpc_peeraddr2str(), which returns a pointer
to memory whose lifetime is the same as the rpc_xprt.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[ cel: fix lockdep splats and layering violations ]
[ cel: forward ported to 3.4 ]
[ cel: remove rpc_max_reqs(), add rpc_net_ns() ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Add debugging messages to NFSv4's CLOSE procedure
Chuck Lever [Thu, 1 Mar 2012 22:00:40 +0000 (17:00 -0500)]
NFS: Add debugging messages to NFSv4's CLOSE procedure

CLOSE is new with NFSv4.  Sometimes it's important to know the timing
of this operation compared to things like lease renewal.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Clean up debugging in decode_pathname()
Chuck Lever [Thu, 1 Mar 2012 22:00:31 +0000 (17:00 -0500)]
NFS: Clean up debugging in decode_pathname()

I noticed recently that decode_attr_fs_locations() is not generating
very pretty debugging output.  The pathname components each appear on
a separate line of output, though that does not appear to be the
intended display behavior.  The preferred way to generate continued
lines of output on the console is to use pr_cont().

Note that incoming pathname4 components contain a string that is not
necessarily NUL-terminated.  I did actually see some trailing garbage
on the console.  In addition to correcting the line continuation
problem, add a string precision format specifier to ensure that each
component string is displayed properly, and that vsnprintf() does
not Oops.

Someone pointed out that allowing incoming network data to possibly
generate a console line of unbounded length may not be such a good
idea.  Since this output will rarely be enabled, and there is a hard
upper bound (NFS4_PATHNAME_MAXCOMPONENTS) in our implementation, this
is probably not a major concern.

It might be useful to additionally sanity-check the length of each
incoming component, however.  RFC 3530bis15 does not suggest a maximum
number of UTF-8 characters per component for either the pathname4 or
component4 types.  However, we could invent one that is appropriate
for our implementation.

Another possibility is to scrap all of this and print these pathnames
in upper layers after a reasonable amount of sanity checking in the
XDR layer.  This would give us an opportunity to allocate a full
buffer so that the whole pathname would be output via a single
dprintk.

Introduced by commit 7aaa0b3b: "NFSv4: convert fs-locations-components
to conform to RFC3530," (June 9, 2006).

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Make nfs_cache_array.size a signed integer
Chuck Lever [Thu, 1 Mar 2012 22:00:23 +0000 (17:00 -0500)]
NFS: Make nfs_cache_array.size a signed integer

Eliminate a number of implicit type casts in comparisons, and these
compiler warnings:

fs/nfs/dir.c: In function â€˜nfs_readdir_clear_array’:
fs/nfs/dir.c:264:16: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
fs/nfs/dir.c: In function â€˜nfs_readdir_search_for_cookie’:
fs/nfs/dir.c:352:16: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
fs/nfs/dir.c: In function â€˜nfs_do_filldir’:
fs/nfs/dir.c:769:38: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
fs/nfs/dir.c:780:9: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Consolidate the parsing of the '-ov4.x' and '-overs=4.x' mount options
Trond Myklebust [Fri, 2 Mar 2012 19:06:39 +0000 (14:06 -0500)]
NFS: Consolidate the parsing of the '-ov4.x' and '-overs=4.x' mount options

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Ensure we display the minor version correctly in /proc/mounts etc.
Trond Myklebust [Fri, 2 Mar 2012 19:00:20 +0000 (14:00 -0500)]
NFS: Ensure we display the minor version correctly in /proc/mounts etc.

The 'minorversion' mount option is now deprecated, so we need to display
the minor version number in the 'vers=' format.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Extend the -overs= mount option to allow 4.x minorversions
Trond Myklebust [Fri, 2 Mar 2012 18:59:49 +0000 (13:59 -0500)]
NFS: Extend the -overs= mount option to allow 4.x minorversions

Allow the user to mount an NFSv4.0 or NFSv4.1 partition using a
standard syntax of '-overs=4.0', or '-overs=4.1' rather than the
more cumbersome '-overs=4,minorversion=1'.

See also the earlier patch by Dros Adamson, which added the
Linux-specific syntax '-ov4.0', '-ov4.1'.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: parse and display server implementation ids
Weston Andros Adamson [Fri, 17 Feb 2012 20:20:26 +0000 (15:20 -0500)]
NFSv4: parse and display server implementation ids

Shows the implementation ids in /proc/self/mountstats.  This doesn't break
the nfs-utils mountstats tool.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: fix server_scope memory leak
Weston Andros Adamson [Fri, 17 Feb 2012 20:20:25 +0000 (15:20 -0500)]
NFSv4: fix server_scope memory leak

server_scope would never be freed if nfs4_check_cl_exchange_flags() returned
non-zero

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Send implementation id with exchange_id
Weston Andros Adamson [Fri, 17 Feb 2012 20:20:24 +0000 (15:20 -0500)]
NFSv4: Send implementation id with exchange_id

Send the nfs implementation id in EXCHANGE_ID requests unless the module
parameter nfs.send_implementation_id is 0.

This adds a CONFIG variable for the nii_domain that defaults to "kernel.org".

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Store the legacy idmapper result in the keyring
Bryan Schumaker [Fri, 24 Feb 2012 19:14:51 +0000 (14:14 -0500)]
NFS: Store the legacy idmapper result in the keyring

This patch removes the old hashmap-based caching and instead uses a
"request key actor" to place an upcall to the legacy idmapper rather
than going through /sbin/request-key.  This will only be used as a
fallback if /etc/request-key.conf isn't configured to use nfsidmap.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoCreated a function for setting timeouts on keys
Bryan Schumaker [Fri, 24 Feb 2012 19:14:50 +0000 (14:14 -0500)]
Created a function for setting timeouts on keys

The keyctl_set_timeout function isn't exported to other parts of the
kernel, but I want to use it for the NFS idmapper.  I already have the
key, but I wanted a generic way to set the timeout.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Get rid of NFS4CLNT_LAYOUTRECALL
Trond Myklebust [Thu, 1 Mar 2012 16:17:50 +0000 (11:17 -0500)]
NFSv4.1: Get rid of NFS4CLNT_LAYOUTRECALL

The NFS4CLNT_LAYOUTRECALL bit is a long-term impediment to scalability. It
basically stops all other recalls by a given server once any layout recall
is requested.

If the recall is for a different file, then we don't care.
If the recall applies to the same file, then we're in one of two situations:
Either we are in the case of a replay of an existing request, in which case
the session is supposed to deal with matters, or we are dealing with a
completely different request, in which case we should just try to process
it.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Get rid of redundant NFS4CLNT_LAYOUTRECALL tests
Trond Myklebust [Thu, 1 Mar 2012 16:17:47 +0000 (11:17 -0500)]
NFSv4.1: Get rid of redundant NFS4CLNT_LAYOUTRECALL tests

The NFS4CLNT_LAYOUTRECALL tests in pnfs_layout_process and
pnfs_update_layout are redundant.

In the case of a bulk layout recall, we're always testing for
the NFS_LAYOUT_BULK_RECALL flay anyway.
In the case of a file or segment recall, the call to
pnfs_set_layout_stateid() updates the layout_header 'barrier'
sequence id, which triggers the test in pnfs_layoutgets_blocked()
and is less race-prone than NFS4CLNT_LAYOUTRECALL anyway.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: move waitq from RPC pipe to RPC inode
Stanislav Kinsbursky [Mon, 27 Feb 2012 18:05:54 +0000 (22:05 +0400)]
SUNRPC: move waitq from RPC pipe to RPC inode

Currently, wait queue, used for polling of RPC pipe changes from user-space,
is a part of RPC pipe. But the pipe data itself can be released on NFS umount
prior to dentry-inode pair, connected to it (is case of this pair is open by
some process).
This is not a problem for almost all pipe users, because all PipeFS file
operations checks pipe reference prior to using it.
Except evenfd. This thing registers itself with "poll" file operation and thus
has a reference to pipe wait queue. This leads to oopses on destroying eventfd
after NFS umount (like rpc_idmapd do) since not pipe data left to the point
already.
The solution is to wait queue from pipe data to internal RPC inode data. This
looks more logical, because this wiat queue used only for user-space processes,
which already holds inode reference.

Note: upcalls have to get pipe->dentry prior to dereferecing wait queue to make
sure, that mount point won't disappear from underneath us.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: check RPC inode's pipe reference before dereferencing
Stanislav Kinsbursky [Mon, 27 Feb 2012 18:05:45 +0000 (22:05 +0400)]
SUNRPC: check RPC inode's pipe reference before dereferencing

There are 2 tightly bound objects: pipe data (created for kernel needs, has
reference to dentry, which depends on PipeFS mount/umount) and PipeFS
dentry/inode pair (created on mount for user-space needs). They both
independently may have or have not a valid reference to each other.
This means, that we have to make sure, that pipe->dentry reference is valid on
upcalls, and dentry->pipe reference is valid on downcalls. The latter check is
absent - my fault.
IOW, PipeFS dentry can be opened by some process (rpc.idmapd for example), but
it's pipe data can belong to NFS mount, which was unmounted already and thus
pipe data was destroyed.
To fix this, pipe reference have to be set to NULL on rpc_unlink() and checked
on PipeFS file operations instead of pipe->dentry check.

Note: PipeFS "poll" file operation will be updated in next patch, because it's
logic is more complicated.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: release per-net clients lock before calling PipeFS dentries creation
Stanislav Kinsbursky [Mon, 27 Feb 2012 18:05:37 +0000 (22:05 +0400)]
NFS: release per-net clients lock before calling PipeFS dentries creation

v3:
1) Lookup for client is performed from the beginning of the list on each PipeFS
event handling operation.

Lockdep is sad otherwise, because inode mutex is taken on PipeFS dentry
creation, which can be called on mount notification, where this per-net client
lock is taken on clients list walk.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: release per-net clients lock before calling PipeFS dentries creation
Stanislav Kinsbursky [Mon, 27 Feb 2012 18:05:29 +0000 (22:05 +0400)]
SUNRPC: release per-net clients lock before calling PipeFS dentries creation

v3:
1) Lookup for client is performed from the beginning of the list on each PipeFS
event handling operation.

Lockdep is sad otherwise, because inode mutex is taken on PipeFS dentry
creation, which can be called on mount notification, where this per-net client
lock is taken on clients list walk.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Don't call nfs4_deviceid_purge_client() unless we're NFSv4.1
Trond Myklebust [Sun, 26 Feb 2012 22:34:22 +0000 (17:34 -0500)]
NFSv4.1: Don't call nfs4_deviceid_purge_client() unless we're NFSv4.1

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Ensure struct nfs_client holds a reference to the net namespace
Trond Myklebust [Sun, 19 Feb 2012 07:46:49 +0000 (08:46 +0100)]
NFS: Ensure struct nfs_client holds a reference to the net namespace

Otherwise we have no guarantee that the net namespace won't just
disappear from underneath us once the task that created it
is destroyed.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
12 years agoNFS: Ensure that the nfs_client 'net' field is always set
Trond Myklebust [Sun, 19 Feb 2012 07:44:07 +0000 (08:44 +0100)]
NFS: Ensure that the nfs_client 'net' field is always set

Currently, the nfs_parsed_mount_data->net field is initialised in
the nfs_parse_mount_options() function, which means that it only
gets set if we're using text based mounts. The legacy binary
mount interface is therefore broken.

Fix is to initialise the ->net field in nfs_alloc_parsed_mount_data.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
12 years agoNFSv4: fix server_scope memory leak
Weston Andros Adamson [Thu, 16 Feb 2012 16:17:05 +0000 (11:17 -0500)]
NFSv4: fix server_scope memory leak

server_scope would never be freed if nfs4_check_cl_exchange_flags() returned
non-zero

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Fix a NFSv4.1 session initialisation regression
Trond Myklebust [Wed, 15 Feb 2012 01:33:19 +0000 (20:33 -0500)]
NFSv4.1: Fix a NFSv4.1 session initialisation regression

Commit aacd553 (NFSv4.1: cleanup init and reset of session slot tables)
introduces a regression in the session initialisation code. New tables
now find their sequence ids initialised to 0, rather than the mandated
value of 1 (see RFC5661).

Fix the problem by merging nfs4_reset_slot_table() and nfs4_init_slot_table().
Since the tbl->max_slots is initialised to 0, the test in
nfs4_reset_slot_table for max_reqs != tbl->max_slots will automatically
pass for an empty table.

Reported-by: Vitaliy Gusev <gusev.vitaliy@nexenta.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: include filelayout DS rpc stats in mountstats
Weston Andros Adamson [Fri, 17 Feb 2012 18:15:24 +0000 (13:15 -0500)]
NFS: include filelayout DS rpc stats in mountstats

Include RPC statistics from all data servers in /proc/self/mountstats for pNFS
filelayout mounts.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1 set highest_used_slotid to NFS4_NO_SLOT
Andy Adamson [Fri, 17 Feb 2012 18:05:23 +0000 (13:05 -0500)]
NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agonfs: Clean up debugging in nfs_follow_mountpoint()
Chuck Lever [Wed, 15 Feb 2012 21:35:17 +0000 (16:35 -0500)]
nfs: Clean up debugging in nfs_follow_mountpoint()

Clean up: Fix a debugging message which had an obsolete function name
in it (nfs_follow_mountpoint).

Introduced by commit 36d43a43 "NFS: Use d_automount() rather than
abusing follow_link()" (January 14, 2011)

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Use KERN_DEFAULT for debugging printk's
Chuck Lever [Wed, 15 Feb 2012 21:35:08 +0000 (16:35 -0500)]
SUNRPC: Use KERN_DEFAULT for debugging printk's

Our dprintk() debugging facility doesn't specify any verbosity level
for it's printk() calls, but it should.

The default verbosity for printk's is KERN_DEFAULT.  You might argue
that these are debugging printk's and thus the verbosity should be
KERN_DEBUG.  That would mean that to see NFS and SUNRPC debugging
output an admin would also have to boost the syslog verbosity, which
would be insufferably noisy.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: add sending,pending queue and max slot to xprt stats
Andy Adamson [Tue, 14 Feb 2012 21:19:18 +0000 (16:19 -0500)]
SUNRPC: add sending,pending queue and max slot to xprt stats

With static RPC slots, the xprt backlog queue stats were useful in showing
when the transport (TCP) was starved by lack of RPC slots. The new dynamic
RPC slot code, commit d9ba131d8f58c0d2ff5029e7002ab43f913b36f9, always
provides an RPC slot and so only uses the xprt backlog queue when the
tcp_max_slot_table_entries value has been hit or when an allocation error
occurs. All requests are now placed on the xprt sending or pending queue which
need to be monitored for debugging.

The max_slot stat shows the maximum number of dynamic RPC slots reached which is
useful when debugging performance issues.

Add the new fields at the end of the mountstats xprt stanza so that mountstats
outputs the previous correct values and ignores the new fields. Bump
NFS_IOSTATS_VERS.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: init per-net rpcbind spinlock
Stanislav Kinsbursky [Thu, 16 Feb 2012 13:42:12 +0000 (17:42 +0400)]
SUNRPC: init per-net rpcbind spinlock

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agonfs41: Verify channel's attributes accordingly to RFC v2
Vitaliy Gusev [Wed, 15 Feb 2012 15:38:25 +0000 (19:38 +0400)]
nfs41: Verify channel's attributes accordingly to RFC v2

 ca_maxoperations:

      For the backchannel, the server MUST
      NOT change the value the client offers.  For the fore channel,
      the server MAY change the requested value.

  ca_maxrequests:

       For the backchannel, the server MUST NOT change the
       value the client offers.  For the fore channel, the server MAY
       change the requested value.

Signed-off-by: Vitaliy Gusev <gusev.vitaliy@nexenta.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: dont allow minorversion= opt when vers != 4
Weston Andros Adamson [Wed, 1 Feb 2012 19:06:41 +0000 (14:06 -0500)]
NFS: dont allow minorversion= opt when vers != 4

Don't allow invalid 'vers' and 'minorversion' combinations in mount options,
such as "vers=3,minorversion=1".

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: Ensure that we can trace waitqueues when !defined(CONFIG_SYSCTL)
Trond Myklebust [Thu, 9 Feb 2012 03:01:15 +0000 (22:01 -0500)]
SUNRPC: Ensure that we can trace waitqueues when !defined(CONFIG_SYSCTL)

The tracepoint code relies on the queue->name being defined in order to
be able to display the name of the waitqueue on which an RPC task is
sleeping.

Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
12 years agoNFSv4: Further reduce the footprint of the idmapper
Trond Myklebust [Wed, 8 Feb 2012 18:39:15 +0000 (13:39 -0500)]
NFSv4: Further reduce the footprint of the idmapper

Don't allocate the legacy idmapper tables until we actually need
them.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
12 years agoNFSv4: The idmapper now depends on keyring functionality
Trond Myklebust [Wed, 8 Feb 2012 18:21:38 +0000 (13:21 -0500)]
NFSv4: The idmapper now depends on keyring functionality

Add the appropriate 'select KEYS' to the NFSv4 Kconfig entry.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Reduce the footprint of the idmapper
Trond Myklebust [Tue, 7 Feb 2012 19:59:05 +0000 (14:59 -0500)]
NFSv4: Reduce the footprint of the idmapper

Instead of pre-allocating the storage for all the strings, we can
significantly reduce the size of that table by doing the allocation
when we do the downcall.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
12 years agoNFS: add mount options 'v4.0' and 'v4.1'
Weston Andros Adamson [Tue, 7 Feb 2012 16:49:11 +0000 (11:49 -0500)]
NFS: add mount options 'v4.0' and 'v4.1'

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: fix nfs4_find_client_sessionid() arguments list
Stanislav Kinsbursky [Tue, 7 Feb 2012 15:53:19 +0000 (19:53 +0400)]
NFS: fix nfs4_find_client_sessionid() arguments list

It's not compilable in case of CONFIG_NFS_V4_1 is not set.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFS: Initialise the nfs_net->nfs_client_lock
Trond Myklebust [Tue, 7 Feb 2012 05:05:11 +0000 (00:05 -0500)]
NFS: Initialise the nfs_net->nfs_client_lock

Ensure that we initialise the nfs_net->nfs_client_lock spinlock.
Also ensure that nfs_server_remove_lists() doesn't try to
dereference server->nfs_client before that is initialised.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
12 years agoLockd: shutdown NLM hosts in network namespace context
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:08:29 +0000 (15:08 +0400)]
Lockd: shutdown NLM hosts in network namespace context

Lockd now managed in network namespace context. And this patch introduces
network namespace related NLM hosts shutdown in case of releasing per-net Lockd
resources.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoLockD: make NSM network namespace aware
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:08:21 +0000 (15:08 +0400)]
LockD: make NSM network namespace aware

NLM host is network namespace aware now.
So NSM have to take it into account.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoLockD: make nlm hosts network namespace aware
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:08:13 +0000 (15:08 +0400)]
LockD: make nlm hosts network namespace aware

This object depends on RPC client, and thus on network namespace.
So let's make it's allocation and lookup in network namespace context.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoLockd: per-net up and down routines introduced
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:08:05 +0000 (15:08 +0400)]
Lockd: per-net up and down routines introduced

This patch introduces per-net Lockd initialization and destruction routines.
The logic is the same as in global Lockd up and down routines. Probably the
solution is not the best one. But at least it looks clear.
So per-net "up" routine are called only in case of lockd is running already. If
per-net resources are not allocated yet, then service is being registered with
local portmapper and lockd sockets created.
Per-net "down" routine is called on every lockd_down() call in case of global
users counter is not zero.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoLockd: pernet usage counter introduced
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:07:57 +0000 (15:07 +0400)]
Lockd: pernet usage counter introduced

Lockd is going to be shared between network namespaces - i.e. going to be able
to handle lock requests from different network namespaces. This means, that
network namespace related resources have to be allocated not once (like now),
but for every network namespace context, from which service is requested to
operate.
This patch implements Lockd per-net users accounting. New per-net counter is
used to determine, when per-net resources have to be freed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoLockd: create permanent lockd sockets in current network namespace
Stanislav Kinsbursky [Tue, 31 Jan 2012 11:07:48 +0000 (15:07 +0400)]
Lockd: create permanent lockd sockets in current network namespace

This patch parametrizes Lockd permanent sockets creation routine by network
namespace context.
It also replaces hard-coded init_net with current network namespace context in
Lockd sockets creation routines.
This approach looks safe, because Lockd is created during NFS mount (or NFS
server start) and thus socket is required exactly in current network namespace
context. But in the same time it means, that Lockd sockets inherits first Lockd
requester network namespace. This issue will be fixed in further patches of the
series.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: service shutdown function in network namespace context introduced
Stanislav Kinsbursky [Tue, 31 Jan 2012 10:09:25 +0000 (14:09 +0400)]
SUNRPC: service shutdown function in network namespace context introduced

This function is enough for releasing resources, allocated for network
namespace context, in case of sharing service between them.
IOW, each service "user" (LockD, NFSd, etc), which wants to share service
between network namespaces, have to release related resources by the function,
introduced in this patch, instead of performing service shutdown (of course in
case the service is shared already to the moment of release).

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: service destruction in network namespace context
Stanislav Kinsbursky [Tue, 31 Jan 2012 10:09:17 +0000 (14:09 +0400)]
SUNRPC: service destruction in network namespace context

v2: Added comment to BUG_ON's in svc_destroy() to make code looks clearer.

This patch introduces network namespace filter for service destruction
function.
Nothing special here - just do exactly the same operations, but only for
tranports in passed networks namespace context.
BTW, BUG_ON() checks for empty service transports lists were returned into
svc_destroy() function. This is because of swithing generic svc_close_all() to
networks namespace dependable svc_close_net().

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: clear svc transports lists helper introduced
Stanislav Kinsbursky [Tue, 31 Jan 2012 10:09:08 +0000 (14:09 +0400)]
SUNRPC: clear svc transports lists helper introduced

This patch moves service transports deletion from service sockets lists to
separated function.
This is a precursor patch, which would be usefull with service shutdown in
network namespace context, introduced later in the series.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoSUNRPC: clear svc pools lists helper introduced
Stanislav Kinsbursky [Tue, 31 Jan 2012 10:09:00 +0000 (14:09 +0400)]
SUNRPC: clear svc pools lists helper introduced

This patch moves removing of service transport from it's pools ready lists to
separated function. Also this clear is now done with list_for_each_entry_safe()
helper.
This is a precursor patch, which would be usefull with service shutdown in
network namespace context, introduced later in the series.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Add a module parameter to set the number of session slots
Trond Myklebust [Tue, 7 Feb 2012 00:50:40 +0000 (19:50 -0500)]
NFSv4.1: Add a module parameter to set the number of session slots

Add the module parameter 'max_session_slots' to set the initial number
of slots that the NFSv4.1 client will attempt to negotiate with the
server.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4.1: Convert slotid from u8 to u32
Trond Myklebust [Tue, 7 Feb 2012 00:38:51 +0000 (19:38 -0500)]
NFSv4.1: Convert slotid from u8 to u32

It is perfectly legal to negotiate up to 2^32-1 slots in the protocol,
and with 10GigE, we are already seeing that 255 slots is far too limiting.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
12 years agoNFSv4: Ensure we throw out bad delegation stateids on NFS4ERR_BAD_STATEID
Trond Myklebust [Thu, 9 Feb 2012 20:31:36 +0000 (15:31 -0500)]
NFSv4: Ensure we throw out bad delegation stateids on NFS4ERR_BAD_STATEID

To ensure that we don't just reuse the bad delegation when we attempt to
recover the nfs4_state that received the bad stateid error.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@vger.kernel.org