From owner-freebsd-rc@FreeBSD.ORG Wed Feb 8 07:29:06 2012 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 8C6651065686 for ; Wed, 8 Feb 2012 07:29:06 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 172-17-150-251.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 5C256151080; Wed, 8 Feb 2012 07:28:56 +0000 (UTC) Message-ID: <4F322437.5030100@FreeBSD.org> Date: Tue, 07 Feb 2012 23:28:55 -0800 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:10.0) Gecko/20120201 Thunderbird/10.0 MIME-Version: 1.0 To: freebsd-rc@FreeBSD.org X-Enigmail-Version: 1.3.5 OpenPGP: id=1A1ABC84 Content-Type: multipart/mixed; boundary="------------080809080101040000050201" Cc: Subject: Bringing sanity to the RPC/NFS related scripts X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Feb 2012 07:29:06 -0000 This is a multi-part message in MIME format. --------------080809080101040000050201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Howdy, Over the years I've been bothered by miscellaneous little "issues" with the NFS and RPC related scripts, but lately I've seen some real operational problems that have caused me to poke harder, and I think I've made some progress. So first the operational problem. I have a lot of systems for which NFS is mission-critical, and that includes lockd. However, we're seeing lockd fail to start because statd didn't start successfully (all the right knobs are there, but sometimes statd fails for unrelated reasons). Currently rc.d/lockd has this: if ! checkyesno rpcbind_enable && \ ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 then force_depend rpcbind || ret=1 fi which seems to be going the right direction, but a) doesn't include statd, and b) the test for "is it running?" is conditional on it not being _enable'd, which is counterproductive for a couple of reasons. (I can elaborate if necessary, but hopefully it's obvious?) So I'd like to propose removing the _enable check from all the relevant scripts that have this force_depend capability. For users who already have _enable for these services it will cause one extra call to forcestatus for them, but given that rc.d currently has no other way to ensure that required dependencies are running, I think it's worth it. The other thing about the status quo is the fact that statd and lockd check that either nfs_server or nfs_client is _enable'd before they run start or stop. This was added almost 5 years ago by mtm, but it creates a variety of problems, not the least of which is that it prevents users from using forcestart or onestart to start these services. Worse is the stop_precmd that also checks these knobs before proceeding. The attached patch does the following: 1. Makes force_depend conditional only on the forcestatus checks for the relevant services, as described above. 2. Removes the tests for nfs_{client|server}_enable from lockd and statd, described above. 3. Adds a check that statd is running to rc.d/lockd 4. Simplifies/standardizes various elements of the shell syntax. Doug -- It's always a long day; 86400 doesn't fit into a short. Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ --------------080809080101040000050201 Content-Type: text/plain; name="nfs-rpc-rcd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nfs-rpc-rcd.diff" Index: mountd =================================================================== --- mountd (revision 231185) +++ mountd (working copy) @@ -19,9 +19,7 @@ mountd_precmd() { - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1; then force_depend rpcbind || return 1 fi @@ -49,7 +47,6 @@ rm -f /var/db/mountdtab ( umask 022 ; > /var/db/mountdtab ) - return 0 } load_rc_config $name Index: nfsd =================================================================== --- nfsd (revision 231185) +++ nfsd (working copy) @@ -61,18 +61,13 @@ fi fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1; then force_depend rpcbind || return 1 fi - if ! checkyesno mountd_enable && \ - ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1 - then + if ! /etc/rc.d/mountd forcestatus 1>/dev/null 2>&1; then force_depend mountd || return 1 fi - return 0 } run_rc_command "$1" Index: amd =================================================================== --- amd (revision 231185) +++ amd (working copy) @@ -23,9 +23,7 @@ force_depend nfsclient || return 1 fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1; then force_depend rpcbind || return 1 fi @@ -49,7 +47,6 @@ command_args="> /var/run/amd.pid 2> /dev/null" ;; esac - return 0 } load_rc_config $name Index: lockd =================================================================== --- lockd (revision 231185) +++ lockd (working copy) @@ -15,7 +15,6 @@ rcvar=rpc_lockd_enable command="/usr/sbin/rpc.${name}" start_precmd='lockd_precmd' -stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable' status_precmd=$stop_precmd # Make sure that we are either an NFS client or server, and that we get @@ -23,20 +22,13 @@ # lockd_precmd() { - local ret - ret=0 - - if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable - then - ret=1 + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1; then + force_depend rpcbind || return 1 fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || ret=1 + if ! /etc/rc.d/statd forcestatus 1>/dev/null 2>&1; then + force_depend statd || return 1 fi rc_flags=${rpc_lockd_flags} - return ${ret} } load_rc_config $name Index: statd =================================================================== --- statd (revision 231185) +++ statd (working copy) @@ -15,7 +15,6 @@ rcvar=rpc_statd_enable command="/usr/sbin/rpc.${name}" start_precmd='statd_precmd' -stop_precmd='checkyesno nfs_server_enable || checkyesno nfs_client_enable' status_precmd=$stop_precmd # Make sure that we are either an NFS client or server, and that we get @@ -23,20 +22,10 @@ # statd_precmd() { - local ret - ret=0 - - if ! checkyesno nfs_server_enable && ! checkyesno nfs_client_enable - then - ret=1 + if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1; then + force_depend rpcbind || return 1 fi - if ! checkyesno rpcbind_enable && \ - ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1 - then - force_depend rpcbind || ret=1 - fi rc_flags=${rpc_statd_flags} - return ${ret} } load_rc_config $name --------------080809080101040000050201--