13 Jan, 2012

1 commit


12 Dec, 2011

1 commit


17 Dec, 2010

4 commits

  • Clean up.

    Change nlmsvc_lookup_host() to be purpose-built for server-side
    nlm_host management. This replaces the generic nlm_lookup_host()
    helper function, just like on the client side. The lookup logic is
    specialized for server host lookups.

    The server side cache also gets its own specialized equivalent of the
    nlm_release_host() function.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     
  • NFS clients don't need the garbage collection processing that is
    performed on nlm_host structures. The client picks up an nlm_host at
    mount time and holds a reference to it until the file system is
    unmounted.

    Servers, on the other hand, don't have a precise way to tell when an
    nlm_host is no longer being used, so zero refcount nlm_host entries
    are left to expire in the cache after a time.

    Basically there's nothing holding a reference to an nlm_host between
    individual server-side NLM requests, but we can't afford the expense
    of recreating them for every new NLM request from a client. The
    nlm_host cache adds some lifetime hysteresis to entries in the cache
    so the next time a particular nlm_host is needed, it's likely to be
    discovered by a lookup rather than created from whole cloth.

    With the new implementation, client nlm_host cache items are no longer
    garbage collected, and are destroyed directly by a new release
    function specialized for client entries, nlmclnt_release_host(). They
    are cached in their own data structure, and have their own lookup
    logic, simplified and specialized for client nlm_host entries.

    However, the client nlm_host cache still shares reboot recovery logic
    with the server nlm_host cache. The NSM "peer rebooted" downcall for
    clients and servers still come through the same RPC call. This is a
    legacy formal API that would be difficult to alter, and besides, the
    user space NSM implementation can't tell the difference between peers
    that are clients or servers.

    For this reason, the client cache continues to share the
    nlm_host_mutex (and reboot recovery logic) with the server cache.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     
  • The nlm_release_call() function is invoked from both the server and
    the client side. We're about to introduce a distinct server- and
    client-side nlm_release_host(), so nlm_release_call() must first be
    split into a client-side and a server-side version.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     
  • Clean up. nlmdbg_cookie2a() is used only in svclock.c.

    Signed-off-by: Chuck Lever
    Tested-by: J. Bruce Fields
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

16 Nov, 2010

1 commit

  • Nick Bowler reports:
    There are no unusual messages on the client... but I just logged into
    the server and I see lots of messages of the following form:

    nfsd: request from insecure port (192.168.8.199:35766)!
    nfsd: request from insecure port (192.168.8.199:35766)!
    nfsd: request from insecure port (192.168.8.199:35766)!
    nfsd: request from insecure port (192.168.8.199:35766)!
    nfsd: request from insecure port (192.168.8.199:35766)!

    Bisected to commit 9247685088398cf21bcb513bd2832b4cd42516c4 (SUNRPC:
    Properly initialize sock_xprt.srcaddr in all cases)

    Apparently, removing the 'transport->srcaddr.ss_family = family' from
    xs_create_sock() triggers this due to nlmclnt_lookup_host() incorrectly
    initialising the srcaddr family to AF_UNSPEC.

    Reported-by: Nick Bowler
    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

22 Sep, 2009

2 commits

  • * 'for-2.6.32' of git://linux-nfs.org/~bfields/linux: (68 commits)
    nfsd4: nfsv4 clients should cross mountpoints
    nfsd: revise 4.1 status documentation
    sunrpc/cache: avoid variable over-loading in cache_defer_req
    sunrpc/cache: use list_del_init for the list_head entries in cache_deferred_req
    nfsd: return success for non-NFS4 nfs4_state_start
    nfsd41: Refactor create_client()
    nfsd41: modify nfsd4.1 backchannel to use new xprt class
    nfsd41: Backchannel: Implement cb_recall over NFSv4.1
    nfsd41: Backchannel: cb_sequence callback
    nfsd41: Backchannel: Setup sequence information
    nfsd41: Backchannel: Server backchannel RPC wait queue
    nfsd41: Backchannel: Add sequence arguments to callback RPC arguments
    nfsd41: Backchannel: callback infrastructure
    nfsd4: use common rpc_cred for all callbacks
    nfsd4: allow nfs4 state startup to fail
    SUNRPC: Defer the auth_gss upcall when the RPC call is asynchronous
    nfsd4: fix null dereference creating nfsv4 callback client
    nfsd4: fix whitespace in NFSPROC4_CLNT_CB_NULL definition
    nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel
    sunrpc/cache: simplify cache_fresh_locked and cache_fresh_unlocked.
    ...

    Linus Torvalds
     
  • Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

21 Aug, 2009

1 commit


18 Jun, 2009

1 commit

  • When rpc.statd starts up in user space at boot time, it attempts to
    write the latest NSM local state number into
    /proc/sys/fs/nfs/nsm_local_state.

    If lockd.ko isn't loaded yet (as is the case in most configurations),
    that file doesn't exist, thus the kernel's NSM state remains set to
    its initial value of zero during lockd operation.

    This is a problem because rpc.statd and lockd use the NSM state number
    to prevent repeated lock recovery on rebooted hosts. If lockd sends
    a zero NSM state, but then a delayed SM_NOTIFY with a real NSM state
    number is received, there is no way for lockd or rpc.statd to
    distinguish that stale SM_NOTIFY from an actual reboot. Thus lock
    recovery could be performed after the rebooted host has already
    started reclaiming locks, and those locks will be lost.

    We could change /etc/init.d/nfslock so it always modprobes lockd.ko
    before starting rpc.statd. However, if lockd.ko is ever unloaded
    and reloaded, we are back at square one, since the NSM state is not
    preserved across an unload/reload cycle. This may happen frequently
    on clients that use automounter. A period of NFS inactivity causes
    lockd.ko to be unloaded, and the kernel loses its NSM state setting.

    Instead, let's use the fact that rpc.statd plants the local system's
    NSM state in every SM_MON (and SM_UNMON) reply. lockd performs a
    synchronous SM_MON upcall to the local rpc.statd _before_ sending its
    first NLM request to a new remote. This would permit rpc.statd to
    provide the current NSM state to lockd, even after lockd.ko had been
    unloaded and reloaded.

    Note that NLMPROC_LOCK arguments are constructed before the
    nsm_monitor() call, so we have to rearrange argument construction very
    slightly to make this all work out.

    And, the kernel appears to treat NSM state as a u32 (see struct
    nlm_args and nsm_res). Make nsm_local_state a u32 as well, to ensure
    we don't get bogus comparison results.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

19 Mar, 2009

1 commit


11 Mar, 2009

1 commit

  • Clean up/micro-optimatization: Make the AF_INET-only version of
    nlm_cmp_addr() smaller. This matches the style of
    nlm_privileged_requester(), and makes the AF_INET-only version of
    nlm_cmp_addr() nearly the same size as it was before IPv6 support.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

07 Jan, 2009

20 commits

  • Clean up.

    For consistency, rewrite the IPv4 check to match the same style as the
    new IPv6 check. Note that ipv4_is_loopback() is somewhat broader in
    its interpretation of what is a loopback address than simply
    "127.0.0.1".

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Commit b85e4676 added the nlm_privileged_requester() helper to check
    whether an RPC request was sent from a local privileged caller. It
    recognizes IPv4 privileged callers (from "127.0.0.1"), and IPv6
    privileged callers (from "::1").

    However, IPV6_ADDR_LOOPBACK is not set for the mapped IPv4 loopback
    address (::ffff:7f00:0001), so the test breaks when the kernel's RPC
    service is IPv6-enabled but user space is calling via the IPv4
    loopback address. This is actually the most common case for IPv6-
    enabled RPC services on Linux.

    Rewrite the IPv6 check to handle the mapped IPv4 loopback address as
    well as a normal IPv6 loopback address.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: nsm_addr_in() is no longer used, and nsm_addr() is used only in
    fs/lockd/mon.c, so move it there.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: The include/linux/lockd/sm_inter.h header is nearly empty
    now. Remove it.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: nsm_find() now has only one caller, and that caller
    unconditionally sets the @create argument. Thus the @create
    argument is no longer needed.

    Since nsm_find() now has a more specific purpose, pick a more
    appropriate name for it.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Introduce a new API to fs/lockd/mon.c that allows nlm_host_rebooted()
    to lookup up nsm_handles via the contents of an nlm_reboot struct.

    The new function is equivalent to calling nsm_find() with @create set
    to zero, but it takes a struct nlm_reboot instead of separate
    arguments.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • The NLM XDR decoders for the NLMPROC_SM_NOTIFY procedure should treat
    their "priv" argument truly as an opaque, as defined by the protocol,
    and let the upper layers figure out what is in it.

    This will make it easier to modify the contents and interpretation of
    the "priv" argument, and keep knowledge about what's in "priv" local
    to fs/lockd/mon.c.

    For now, the NLM and NSM implementations should behave exactly as they
    did before.

    The formation of the address of the rebooted host in
    nlm_host_rebooted() may look a little strange, but it is the inverse
    of how nsm_init_private() forms the private cookie. Plus, it's
    going away soon anyway.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Pass the nlm_reboot data structure directly from the NLMPROC_SM_NOTIFY
    XDR decoders to nlm_host_rebooted(). This eliminates some packing and
    unpacking of the NLMPROC_SM_NOTIFY results, and prepares for passing
    these results, including the "priv" cookie, directly to a lookup
    routine in fs/lockd/mon.c.

    This patch changes code organization but should not cause any
    behavioral change.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Introduce a new data type, used by both the in-kernel NLM and NSM
    implementations, that is used to manage the opaque "priv" argument
    for the NSMPROC_MON and NLMPROC_SM_NOTIFY calls.

    Construct the "priv" cookie when the nsm_handle is created.

    The nsm_init_private() function may look a little strange, but it is
    roughly equivalent to how the XDR encoder formed the "priv" argument.
    It's going to go away soon.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • The nsm_find() function sets up fresh nsm_handle entries. This is
    where we will store the "priv" cookie used to lookup nsm_handles during
    reboot recovery. The cookie will be constructed when nsm_find()
    creates a new nsm_handle.

    As much as possible, I would like to keep everything that handles a
    "priv" cookie in fs/lockd/mon.c so that all the smarts are in one
    source file. That organization should make it pretty simple to see how
    all this works.

    To me, it makes more sense than the current arrangement to keep
    nsm_find() with nsm_monitor() and nsm_unmonitor().

    So, start reorganizing by moving nsm_find() into fs/lockd/mon.c. The
    nsm_release() function comes along too, since it shares the nsm_lock
    global variable.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: Move the RPC program and procedure numbers for NSM into the
    one source file that needs them: fs/lockd/mon.c.

    And, as with NLM, NFS, and rpcbind calls, use NSMPROC_FOO instead of
    SM_FOO for NSM procedure numbers.

    Finally, make a couple of comments more precise: what is referred to
    here as SM_NOTIFY is really the NLM (lockd) NLMPROC_SM_NOTIFY downcall,
    not NSMPROC_NOTIFY.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: NSM's XDR data structures are used only in fs/lockd/mon.c,
    so move them there.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up.

    Make the nlm_host argument "const," and move the public declaration to
    lockd.h. Add a documenting comment.

    Bruce observed that nsm_unmonitor()'s only caller doesn't care about
    its return code, so make nsm_unmonitor() return void.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • The nsm_handle's reference count is bumped in nlm_lookup_host(). It
    should be decremented in nlm_destroy_host() to make it easier to see
    the balance of these two operations.

    Move the nsm_release() call to fs/lockd/host.c.

    The h_nsmhandle pointer is set in nlm_lookup_host(), and never cleared.
    The nlm_destroy_host() function is never called for the same nlm_host
    twice, so h_nsmhandle won't ever be NULL when nsm_unmonitor() is
    called.

    All references to the nlm_host are gone before it is freed. We can
    skip making h_nsmhandle NULL just before the nlm_host is deallocated.

    It's also likely we can remove the h_nsmhandle NULL check in
    nlmsvc_is_client() as well, but we can do that later when rearchitect-
    ing the nlm_host cache.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up.

    Make the nlm_host argument "const," and move the public declaration to
    lockd.h with other NSM public function (nsm_release, eg) and global
    variable declarations.

    Add a documenting comment.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • The "mon_name" argument of the NSMPROC_MON and NSMPROC_UNMON upcalls
    is a string that contains the hostname or IP address of the remote peer
    to be notified when this host has rebooted. The sm-notify command uses
    this identifier to contact the peer when we reboot, so it must be
    either a well-qualified DNS hostname or a presentation format IP
    address string.

    When the "nsm_use_hostnames" sysctl is set to zero, the kernel's NSM
    provides a presentation format IP address in the "mon_name" argument.
    Otherwise, the "caller_name" argument from NLM requests is used,
    which is usually just the DNS hostname of the peer.

    To support IPv6 addresses for the mon_name argument, we use the
    nsm_handle's address eye-catcher, which already contains an appropriate
    presentation format address string. Using the eye-catcher string
    obviates the need to use a large buffer on the stack to form the
    presentation address string for the upcall.

    This patch also addresses a subtle bug.

    An NSMPROC_MON request and the subsequent NSMPROC_UNMON request for the
    same peer are required to use the same value for the "mon_name"
    argument. Otherwise, rpc.statd's NSMPROC_UNMON processing cannot
    locate the database entry for that peer and remove it.

    If the setting of nsm_use_hostnames is changed between the time the
    kernel sends an NSMPROC_MON request and the time it sends the
    NSMPROC_UNMON request for the same peer, the "mon_name" argument for
    these two requests may not be the same. This is because the value of
    "mon_name" is currently chosen at the moment the call is made based on
    the setting of nsm_use_hostnames

    To ensure both requests pass identical contents in the "mon_name"
    argument, we now select which string to use for the argument in the
    nsm_monitor() function. A pointer to this string is saved in the
    nsm_handle so it can be used for a subsequent NSMPROC_UNMON upcall.

    NB: There are other potential problems, such as how nlm_host_rebooted()
    might behave if nsm_use_hostnames were changed while hosts are still
    being monitored. This patch does not attempt to address those
    problems.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: I'm about to add another "char *" field to the nsm_handle
    structure. The sm_name field uses an older style of declaring a
    "char *" field. If I match that style for the new field, checkpatch.pl
    will complain.

    So, fix the sm_name field to use the new style.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Scope ID support is needed since the kernel's NSM implementation is
    about to use these displayed addresses as a mon_name in some cases.

    When nsm_use_hostnames is zero, without scope ID support NSM will fail
    to handle peers that contact us via a link-local address. Link-local
    addresses do not work without an interface ID, which is stored in the
    sockaddr's sin6_scope_id field.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • The h_name field in struct nlm_host is a just copy of
    h_nsmhandle->sm_name. Likewise, the contents of the h_addrbuf field
    should be identical to the sm_addrbuf field.

    The h_srcaddrbuf field is used only in one place for debugging. We can
    live without this until we get %pI formatting for printk().

    Currently these buffers are 48 bytes, but we need to support scope IDs
    in IPv6 presentation addresses, which means making the buffers even
    larger. Instead, let's find ways to eliminate them to save space.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Clean up: I'm about to add another "char *" field to the nlm_host
    structure. The h_name field, for example, uses an older style of
    declaring a "char *" field. If I match that style for the new field,
    checkpatch.pl will complain.

    So, fix pointer fields to use the new style.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     

24 Dec, 2008

1 commit

  • If the admin has specified the "noresvport" option for an NFS mount
    point, the kernel's NFS client uses an unprivileged source port for
    the main NFS transport. The kernel's lockd client should use an
    unprivileged port in this case as well.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

05 Oct, 2008

1 commit


04 Oct, 2008

5 commits

  • The nlm_reboot structure is used to store information provided by the
    NSM_NOTIFY procedure. This procedure is not specified by the NLM or NSM
    protocols, other than to say that the procedure can be used to transmit
    information private to a particular NLM/NSM implementation.

    For Linux, the callback arguments include the name of the monitored host,
    the new NSM state of the host, and a 16-byte private opaque.

    As a clean up, remove the unused fields and the server-side XDR logic that
    decodes them.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • lockd accepts SM_NOTIFY calls only from a privileged process on the
    local system. If lockd uses an AF_INET6 listener, the sender's address
    (ie the local rpc.statd) will be the IPv6 loopback address, not the
    IPv4 loopback address.

    Make sure the privilege test in nlmsvc_proc_sm_notify() and
    nlm4svc_proc_sm_notify() works for both AF_INET and AF_INET6 family
    addresses by refactoring the test into a helper and adding support for
    IPv6 addresses.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Adjust the signature and callers of nlmclnt_grant() to pass a "struct
    sockaddr *" instead of a "struct sockaddr_in *" in order to support IPv6
    addresses.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Fix up nlmsvc_lookup_host() to pass AF_INET6 source addresses to
    nlm_lookup_host().

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Pass a struct sockaddr * and a length to nlmclnt_lookup_host() to
    accomodate non-AF_INET family addresses.

    As a side benefit, eliminate the hostname_len argument, as the hostname
    is always NUL-terminated.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever