19 Mar, 2009
1 commit
-
The base versions handle constant folding now, none of these headers
are exported to userspace, so the __ prefixed versions are not
necessary.Signed-off-by: Harvey Harrison
Reviewed-by: NeilBrown
Signed-off-by: J. Bruce Fields
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
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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_hostnamesTo 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 -
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 -
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 -
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 -
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
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
05 Oct, 2008
1 commit
-
Clean up: Now that lockd_up() starts listeners for both transports, the
"proto" argument is no longer needed.Signed-off-by: Chuck Lever
Cc: Neil Brown
Signed-off-by: J. Bruce Fields
04 Oct, 2008
7 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 -
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 -
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 -
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 -
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 -
Do all the grace period checks in svclock.c. This simplifies the code a
bit, and will ease some later changes.Signed-off-by: J. Bruce Fields
-
Rewrite grace period code to unify management of grace period across
lockd and nfsd. The current code has lockd and nfsd cooperate to
compute a grace period which is satisfactory to them both, and then
individually enforce it. This creates a slight race condition, since
the enforcement is not coordinated. It's also more complicated than
necessary.Here instead we have lockd and nfsd each inform common code when they
enter the grace period, and when they're ready to leave the grace
period, and allow normal locking only after both of them are ready to
leave.We also expect the locks_start_grace()/locks_end_grace() interface here
to be simpler to build on for future cluster/high-availability work,
which may require (for example) putting individual filesystems into
grace, or enforcing grace periods across multiple cluster nodes.Signed-off-by: J. Bruce Fields
30 Sep, 2008
5 commits
-
Update the nlm_cmp_addr() helper to support AF_INET6 as well as AF_INET
addresses. New version takes two "struct sockaddr *" arguments instead of
"struct sockaddr_in *" arguments.Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields -
To store larger addresses in the nsm_handle structure, make sm_addr a
sockaddr_storage.Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields -
To store larger addresses in the nlm_host structure, make h_saddr a
sockaddr_storage. And let's call it something more self-explanatory:
"saddr" could easily be mistaken for "server address".Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields -
To store larger addresses in the nlm_host structure, make h_addr a
sockaddr_storage, and add an address length field.Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields -
Knowing which source address is used for communicating with remote NLM
services can be helpful for debugging configuration problems on hosts
with multiple addresses.Keep the dprintk debugging here, but adapt it so it displays AF_INET6
addresses properly. There are also a couple of dprintk clean-ups as
well.At some point we will aggregate the helpers that display presentation
format addresses into a single set of shared helpers.Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields
16 Jul, 2008
3 commits
-
Pass a more generic socket address type to nlmsvc_unlock_all_by_ip() to
allow for future support of IPv6. Also provide additional sanity
checking in failover_unlock_ip() when constructing the server's IP
address.As an added bonus, provide clean kerneldoc comments on related NLM
interfaces which were recently added.Signed-off-by: Chuck Lever
Signed-off-by: J. Bruce Fields -
nlmsvc_lock calls nlmsvc_lookup_host to find a nlm_host struct. The
callers of this function, however, call nlmsvc_retrieve_args or
nlm4svc_retrieve_args, which also return a nlm_host struct.Change nlmsvc_lock to take a host arg instead of calling
nlmsvc_lookup_host itself and change the callers to pass a pointer to
the nlm_host they've already found.Since nlmsvc_testlock() now just uses the caller's reference, we no
longer need to get or release it.Signed-off-by: Jeff Layton
Signed-off-by: J. Bruce Fields -
nlmsvc_testlock calls nlmsvc_lookup_host to find a nlm_host struct. The
callers of this functions, however, call nlmsvc_retrieve_args or
nlm4svc_retrieve_args, which also return a nlm_host struct.Change nlmsvc_testlock to take a host arg instead of calling
nlmsvc_lookup_host itself and change the callers to pass a pointer to
the nlm_host they've already found.We take a reference to host in the place where nlmsvc_testlock()
previous did a new lookup, so the reference counting is unchanged from
before.Signed-off-by: Jeff Layton
Signed-off-by: J. Bruce Fields
26 Apr, 2008
1 commit
-
Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.:
shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem
so that a filesystem can be unmounted before allowing a peer nfsd to
take over nfs service for the filesystem.Signed-off-by: S. Wendy Cheng
Cc: Lon Hohberger
Cc: Christoph Hellwig
Signed-off-by: J. Bruce Fieldsfs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++-----
fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++
include/linux/lockd/lockd.h | 7 ++++
3 files changed, 131 insertions(+), 7 deletions(-)