summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-01-18 19:42:08 +0000
committerdelphij <delphij@FreeBSD.org>2013-01-18 19:42:08 +0000
commitadf92df6259d2b75c695710bf9ac765fb00c4857 (patch)
tree5751011bf6b15048deede38b024016b2985f2095
parent2b37b49e2c7c15e146a64b6c209e549ad8517555 (diff)
downloadFreeBSD-src-adf92df6259d2b75c695710bf9ac765fb00c4857.zip
FreeBSD-src-adf92df6259d2b75c695710bf9ac765fb00c4857.tar.gz
Make it possible to force async at server side on new NFS server, similar
to the old one's nfs.nfsrv.async. Please note that by enabling this option (default is disabled), the system could potentionally have silent data corruption if the server crashes before write is committed to non-volatile storage, as the client side have no way to tell if the data is already written. Submitted by: rmacklem MFC after: 2 weeks
-rw-r--r--sys/fs/nfsserver/nfs_nfsdserv.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 85fbbd2..307b1f6 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -55,6 +55,11 @@ extern int nfs_rootfhset;
extern int nfsrv_enable_crossmntpt;
#endif /* !APPLEKEXT */
+static int nfs_async = 0;
+SYSCTL_DECL(_vfs_nfsd);
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0,
+ "Tell client that writes were synced even though they were not");
+
/*
* This list defines the GSS mechanisms supported.
* (Don't ask me how you get these strings from the RFC stuff like
@@ -912,7 +917,13 @@ nfsrvd_write(struct nfsrv_descript *nd, __unused int isdgram,
goto out;
NFSM_BUILD(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(retlen);
- if (stable == NFSWRITE_UNSTABLE)
+ /*
+ * If nfs_async is set, then pretend the write was FILESYNC.
+ * Warning: Doing this violates RFC1813 and runs a risk
+ * of data written by a client being lost when the server
+ * crashes/reboots.
+ */
+ if (stable == NFSWRITE_UNSTABLE && nfs_async == 0)
*tl++ = txdr_unsigned(stable);
else
*tl++ = txdr_unsigned(NFSWRITE_FILESYNC);
OpenPOWER on IntegriCloud