Date: Sun, 23 Apr 2017 22:56:40 +0000 From: Rick Macklem <rmacklem@uoguelph.ca> To: "freebsd-fs@freebsd.org" <freebsd-fs@freebsd.org> Subject: optionally enable the NFSv4 server to allow write opens for reading Message-ID: <YTXPR01MB01897D428DD829C7A9DEC284DD1C0@YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
When a client such as the FreeBSD one does a write of a partial block, it will first
read the block in. If the file is opened Write only over NFSv4, the client can try
using this open for the Read. If the server (such as the FreeBSD one in head, etc)
doesn't allow this, it can reply with NFSERR_OPENMODE and the client must find
another way to do the Read, such as using what are called a "special stateid".
The attached patch modifies the FreeBSD NFSv4 server to allow use of a Write Open
for Read operations (this is allowed by the RFCs).
Does this sound reasonable to others to do? rick
ps: You can review/test the patch, but I am mainly wondering if doing this seems like
a good idea to others?
[-- Attachment #2 --]
--- fs/nfsserver/nfs_nfsdstate.c.orig 2017-04-15 10:58:38.043390000 -0400
+++ fs/nfsserver/nfs_nfsdstate.c 2017-04-23 09:59:30.678592000 -0400
@@ -75,6 +75,11 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, writedel
&nfsrv_writedelegifpos, 0,
"Issue a write delegation for read opens if possible");
+static int nfsrv_allowreadforwriteopen = 1;
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, allowreadforwriteopen, CTLFLAG_RW,
+ &nfsrv_allowreadforwriteopen, 0,
+ "Allow Reads to be done with Write Access StateIDs");
+
/*
* Hash lists for nfs V4.
*/
@@ -1873,7 +1878,8 @@ tryagain:
mystp->ls_flags & NFSLCK_ACCESSBITS)) ||
((new_stp->ls_flags & (NFSLCK_CHECK|NFSLCK_READACCESS)) ==
(NFSLCK_CHECK | NFSLCK_READACCESS) &&
- !(mystp->ls_flags & NFSLCK_READACCESS)) ||
+ !(mystp->ls_flags & NFSLCK_READACCESS) &&
+ nfsrv_allowreadforwriteopen == 0) ||
((new_stp->ls_flags & (NFSLCK_CHECK|NFSLCK_WRITEACCESS)) ==
(NFSLCK_CHECK | NFSLCK_WRITEACCESS) &&
!(mystp->ls_flags & NFSLCK_WRITEACCESS))) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YTXPR01MB01897D428DD829C7A9DEC284DD1C0>
