diff options
author | NeilBrown <neilb@suse.de> | 2021-05-22 11:06:13 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2021-05-22 11:18:56 -0400 |
commit | 7a4e2d1de904a65496db051dbc9d4c7e510a5fd8 (patch) | |
tree | ddadc5d0cb61ede98612abec5acc4385f1fd779c | |
parent | c5528f40f9db5061e06dcf1f9b7fce5185b376c6 (diff) | |
download | nfs-utils-7a4e2d1de904a65496db051dbc9d4c7e510a5fd8.tar.gz |
Remove 'force' arg from cache_flush()
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.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | support/export/auth.c | 2 | ||||
-rw-r--r-- | support/include/nfslib.h | 2 | ||||
-rw-r--r-- | support/nfs/cacheio.c | 17 | ||||
-rw-r--r-- | utils/exportfs/exportfs.c | 4 | ||||
-rw-r--r-- | 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 cea37630..17bdfc83 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 84d8270b..58eeb338 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 70ead94d..73f4be4a 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -32,8 +32,6 @@ #include <time.h> #include <errno.h> -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 bc76aaaf..d5862967 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 3ab2100b..881207b3 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; |