summaryrefslogtreecommitdiffstats
path: root/utils/statd/statd.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2007-04-02 13:25:40 +1000
committerNeil Brown <neilb@suse.de>2007-04-02 13:25:40 +1000
commitdda3455d8b96a7b078bc00c113e1af15ed421d5b (patch)
tree50d1c08a904ff99714f69d1cea1422cd8d196143 /utils/statd/statd.c
parentca5f2d1e16a6451c1df203bccfd8944ee84c728f (diff)
downloadnfs-utils-dda3455d8b96a7b078bc00c113e1af15ed421d5b.tar.gz
nfs-utils-dda3455d8b96a7b078bc00c113e1af15ed421d5b.tar.xz
nfs-utils-dda3455d8b96a7b078bc00c113e1af15ed421d5b.zip
Tell NFS/lockd client what that local state number is.
Both SM_STAT and SM_MON can return the state of an NSM, but it is unclear which NSM they return the state of, so the value cannot be used, and lockd doesn't use it. Document this confusion, and give the current state to the kernel via a sysctl if that sysctl is available (since about 2.6.19). This should make is possible for the NFS server to detect a small class of bad SM_NOTIFY packets and not flush locks in that case. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/statd/statd.c')
-rw-r--r--utils/statd/statd.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/utils/statd/statd.c b/utils/statd/statd.c
index 091ced9..8337b64 100644
--- a/utils/statd/statd.c
+++ b/utils/statd/statd.c
@@ -76,6 +76,7 @@ static struct option longopts[] =
extern void sm_prog_1 (struct svc_req *, register SVCXPRT *);
extern int statd_get_socket(void);
+static void load_state_number(void);
#ifdef SIMULATIONS
extern void simulator (int, char **);
@@ -483,7 +484,7 @@ int main (int argc, char **argv)
* pass on any SM_NOTIFY that arrives
*/
load_state();
-
+ load_state_number();
pmap_unset (SM_PROG, SM_VERS);
/* this registers both UDP and TCP services */
@@ -526,3 +527,23 @@ int main (int argc, char **argv)
}
return 0;
}
+
+static void
+load_state_number(void)
+{
+ int fd;
+
+ if ((fd = open(SM_STAT_PATH, O_RDONLY)) == -1)
+ return;
+
+ read(fd, &MY_STATE, sizeof(MY_STATE));
+ close(fd);
+ fd = open("/proc/sys/fs/nfs/nsm_local_state",O_WRONLY);
+ if (fd >= 0) {
+ char buf[20];
+ snprintf(buf, sizeof(buf), "%d", MY_STATE);
+ write(fd, buf, strlen(buf));
+ close(fd);
+ }
+
+}