From patchwork Fri May 21 01:40:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12271675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A97DEC433B4 for ; Fri, 21 May 2021 01:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D59C613B5 for ; Fri, 21 May 2021 01:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237438AbhEUBlz (ORCPT ); Thu, 20 May 2021 21:41:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:43892 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237378AbhEUBly (ORCPT ); Thu, 20 May 2021 21:41:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E7297ABD0; Fri, 21 May 2021 01:40:30 +0000 (UTC) MIME-Version: 1.0 From: "NeilBrown" To: "Steve Dickson" Cc: "Petr Vorel" , "J . Bruce Fields" , linux-nfs@vger.kernel.org, "Chuck Lever" , "Alexey Kodanev" Subject: [PATCH nfs-utils 1/2] Remove 'force' arg from cache_flush() In-reply-to: <162156113063.19062.9406037279407040033@noble.neil.brown.name> References: <20210422191803.31511-1-pvorel@suse.cz>, <20210422202334.GB25415@fieldses.org>, , <162035212343.24322.12361160756597283121@noble.neil.brown.name>, <162122673178.19062.96081788305923933@noble.neil.brown.name>, <289c5819-917a-39a7-9aa4-2a27ae7248c0@RedHat.com>, <162156113063.19062.9406037279407040033@noble.neil.brown.name> Date: Fri, 21 May 2021 11:40:22 +1000 Message-id: <162156122215.19062.11710239266795260824@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Since v4.17 the timestamp written to 'flush' is ignored, so there isn't much point choosing too precisely. For kernels since v4.3-rc3-13-g778620364ef5 it is safe to write 1 second beyond the current time. For earlier kernels, nothing is really safe (even the current behaviour), but writing one second beyond the current time isn't too bad in the unlikely case the people use a new nfs-utils on a 5 year old kernel. This remove a dependency for libnfs.a on 'etab' being declare, so svcgssd no longer needs to declare it. Signed-off-by: NeilBrown Reviewed-by: Petr Vorel --- support/export/auth.c | 2 +- support/include/nfslib.h | 2 +- support/nfs/cacheio.c | 17 ++++++++--------- utils/exportfs/exportfs.c | 4 ++-- utils/gssd/svcgssd.c | 1 - 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/support/export/auth.c b/support/export/auth.c index cea376300d01..17bdfc83748e 100644 --- a/support/export/auth.c +++ b/support/export/auth.c @@ -80,7 +80,7 @@ check_useipaddr(void) use_ipaddr = 0; if (use_ipaddr != old_use_ipaddr) - cache_flush(1); + cache_flush(); } unsigned int diff --git a/support/include/nfslib.h b/support/include/nfslib.h index 84d8270b330f..58eeb3382fcc 100644 --- a/support/include/nfslib.h +++ b/support/include/nfslib.h @@ -132,7 +132,7 @@ int wildmat(char *text, char *pattern); int qword_get(char **bpp, char *dest, int bufsize); int qword_get_int(char **bpp, int *anint); -void cache_flush(int force); +void cache_flush(void); void qword_add(char **bpp, int *lp, char *str); void qword_addhex(char **bpp, int *lp, char *buf, int blen); void qword_addint(char **bpp, int *lp, int n); diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 70ead94d64f0..73f4be4af9f9 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -32,8 +32,6 @@ #include #include -extern struct state_paths etab; - void qword_add(char **bpp, int *lp, char *str) { char *bp = *bpp; @@ -213,7 +211,7 @@ int qword_get_uint(char **bpp, unsigned int *anint) */ void -cache_flush(int force) +cache_flush(void) { struct stat stb; int c; @@ -234,12 +232,13 @@ cache_flush(int force) NULL }; now = time(0); - if (force || - stat(etab.statefn, &stb) != 0 || - stb.st_mtime > now) - stb.st_mtime = time(0); - - sprintf(stime, "%" PRId64 "\n", (int64_t)stb.st_mtime); + + /* Since v4.16-rc2-3-g3b68e6ee3cbd the timestamp written is ignored. + * It is safest always to flush caches if there is any doubt. + * For earlier kernels, writing the next second from now is + * the best we can do. + */ + sprintf(stime, "%" PRId64 "\n", (int64_t)now+1); for (c=0; cachelist[c]; c++) { int fd; sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]); diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index bc76aaaf8714..d586296796a9 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -188,7 +188,7 @@ main(int argc, char **argv) if (optind == argc && ! f_all) { if (force_flush) { - cache_flush(1); + cache_flush(); free_state_path_names(&etab); return 0; } else { @@ -235,7 +235,7 @@ main(int argc, char **argv) unexportfs(argv[i], f_verbose); } xtab_export_write(); - cache_flush(force_flush); + cache_flush(); free_state_path_names(&etab); export_freeall(); diff --git a/utils/gssd/svcgssd.c b/utils/gssd/svcgssd.c index 3ab2100b66bb..881207b3e8a2 100644 --- a/utils/gssd/svcgssd.c +++ b/utils/gssd/svcgssd.c @@ -67,7 +67,6 @@ #include "misc.h" #include "svcgssd_krb5.h" -struct state_paths etab; /* from cacheio.c */ static bool signal_received = false; static struct event_base *evbase = NULL; static int nullrpc_fd = -1; From patchwork Fri May 21 01:41:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12271677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32D50C433ED for ; Fri, 21 May 2021 01:41:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 065F1611AE for ; Fri, 21 May 2021 01:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237389AbhEUBmo convert rfc822-to-8bit (ORCPT ); Thu, 20 May 2021 21:42:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:44052 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237319AbhEUBmn (ORCPT ); Thu, 20 May 2021 21:42:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B6BAAAB6D; Fri, 21 May 2021 01:41:20 +0000 (UTC) MIME-Version: 1.0 From: "NeilBrown" To: "Steve Dickson" Cc: "Petr Vorel" , "J . Bruce Fields" , linux-nfs@vger.kernel.org, "Chuck Lever" , "Alexey Kodanev" Subject: [PATCH nfs-utils 2/2] Move declaration of etab and rmtab into libraries In-reply-to: <162156122215.19062.11710239266795260824@noble.neil.brown.name> References: <20210422191803.31511-1-pvorel@suse.cz>, <20210422202334.GB25415@fieldses.org>, , <162035212343.24322.12361160756597283121@noble.neil.brown.name>, <162122673178.19062.96081788305923933@noble.neil.brown.name>, <289c5819-917a-39a7-9aa4-2a27ae7248c0@RedHat.com>, <162156113063.19062.9406037279407040033@noble.neil.brown.name>, <162156122215.19062.11710239266795260824@noble.neil.brown.name> Date: Fri, 21 May 2021 11:41:12 +1000 Message-id: <162156127225.19062.3275458295434454950@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org There are two global "struct stat_paths" structures: etab and rmtab. They are currently needed by some library code so any program which is linked with that library code needs to declare the structures even if it doesn't use the functionality. This is clumsy and error-prone. Instead: have the library declare the structure and put the definition in a header file. Now programs only need to know about these structures if they use the functionality. 'rmtab' is now declared in libnfs.a (rmtab.c). 'etab' is declared in export.a (xtab.c). Signed-off-by: NeilBrown Reviewed-by: Petr Vorel --- support/export/auth.c | 2 -- support/export/xtab.c | 2 +- support/include/exportfs.h | 1 + support/include/nfslib.h | 1 + support/nfs/rmtab.c | 2 +- utils/exportd/exportd.c | 2 -- utils/exportfs/exportfs.c | 2 -- utils/mountd/mountd.c | 3 --- utils/mountd/rmtab.c | 2 -- 9 files changed, 4 insertions(+), 13 deletions(-) diff --git a/support/export/auth.c b/support/export/auth.c index 17bdfc83748e..03ce4b8a0e1e 100644 --- a/support/export/auth.c +++ b/support/export/auth.c @@ -41,8 +41,6 @@ static nfs_client my_client; extern int use_ipaddr; -extern struct state_paths etab; - /* void auth_init(void) diff --git a/support/export/xtab.c b/support/export/xtab.c index 00b25eaac07d..c888a80aa741 100644 --- a/support/export/xtab.c +++ b/support/export/xtab.c @@ -27,7 +27,7 @@ #include "misc.h" static char state_base_dirname[PATH_MAX] = NFS_STATEDIR; -extern struct state_paths etab; +struct state_paths etab; int v4root_needed; static void cond_rename(char *newfile, char *oldfile); diff --git a/support/include/exportfs.h b/support/include/exportfs.h index 7c1b74537186..9edf0d04732f 100644 --- a/support/include/exportfs.h +++ b/support/include/exportfs.h @@ -145,6 +145,7 @@ nfs_export * export_create(struct exportent *, int canonical); void exportent_release(struct exportent *); void export_freeall(void); +extern struct state_paths etab; int xtab_export_read(void); int xtab_export_write(void); diff --git a/support/include/nfslib.h b/support/include/nfslib.h index 58eeb3382fcc..6faba71bf0cd 100644 --- a/support/include/nfslib.h +++ b/support/include/nfslib.h @@ -106,6 +106,7 @@ void dupexportent(struct exportent *dst, struct exportent *src); int updateexportent(struct exportent *eep, char *options); +extern struct state_paths rmtab; int setrmtabent(char *type); struct rmtabent * getrmtabent(int log, long *pos); void putrmtabent(struct rmtabent *xep, long *pos); diff --git a/support/nfs/rmtab.c b/support/nfs/rmtab.c index 9f03167ddbe1..154b26fa3402 100644 --- a/support/nfs/rmtab.c +++ b/support/nfs/rmtab.c @@ -33,7 +33,7 @@ static FILE *rmfp = NULL; -extern struct state_paths rmtab; +struct state_paths rmtab; int setrmtabent(char *type) diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c index f36f51d215b5..2dd12cb6015b 100644 --- a/utils/exportd/exportd.c +++ b/utils/exportd/exportd.c @@ -25,8 +25,6 @@ extern void my_svc_run(void); -struct state_paths etab; - /* Number of mountd threads to start. Default is 1 and * that's probably enough unless you need hundreds of * clients to be able to mount at once. */ diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index d586296796a9..6ba615d1443d 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -52,8 +52,6 @@ static void release_lockfile(void); static const char *lockfile = EXP_LOCKFILE; static int _lockfd = -1; -struct state_paths etab; - /* * If we aren't careful, changes made by exportfs can be lost * when multiple exports process run at once: diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index 39e85fd53a87..bcf749fabbb3 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -43,9 +43,6 @@ int reverse_resolve = 0; int manage_gids; int use_ipaddr = -1; -struct state_paths etab; -struct state_paths rmtab; - /* PRC: a high-availability callout program can be specified with -H * When this is done, the program will receive callouts whenever clients * send mount or unmount requests -- the callout is not needed for 2.6 kernel */ diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c index c8962439ddd2..2da97615ca0f 100644 --- a/utils/mountd/rmtab.c +++ b/utils/mountd/rmtab.c @@ -28,8 +28,6 @@ extern int reverse_resolve; -extern struct state_paths rmtab; - /* If new path is a link do not destroy it but place the * file where the link points. */