Re: [PATCH rfc] nfsd: offer write delegation for O_WRONLY opens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 07/07/2024 14:06, Jeff Layton wrote:
On Sun, 2024-07-07 at 01:42 +0300, Sagi Grimberg wrote:
Many applications open files with O_WRONLY, fully intending to write
into the opened file. There is no reason why these applications should
not enjoy a write delegation handed to them.

Cc: Dai Ngo <dai.ngo@xxxxxxxxxx>
Signed-off-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
---
Note: I couldn't find any reason to why the initial implementation chose
to offer write delegations only to NFS4_SHARE_ACCESS_BOTH, but it seemed
like an oversight to me. So I figured why not just send it out and see who
objects...

  fs/nfsd/nfs4state.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a20c2c9d7d45..69d576b19eb6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -5784,15 +5784,15 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
  	 *  "An OPEN_DELEGATE_WRITE delegation allows the client to handle,
  	 *   on its own, all opens."
  	 *
-	 * Furthermore the client can use a write delegation for most READ
-	 * operations as well, so we require a O_RDWR file here.
-	 *
-	 * Offer a write delegation in the case of a BOTH open, and ensure
-	 * we get the O_RDWR descriptor.
+	 * Offer a write delegation in the case of a BOTH open (ensure
+	 * a O_RDWR descriptor) Or WRONLY open (with a O_WRONLY descriptor).
  	 */
  	if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) == NFS4_SHARE_ACCESS_BOTH) {
  		nf = find_rw_file(fp);
  		dl_type = NFS4_OPEN_DELEGATE_WRITE;
+	} else if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) {
+		nf = find_writeable_file(fp);
+		dl_type = NFS4_OPEN_DELEGATE_WRITE;
  	}
/*

I *think* the main reason we limited this before is because a write
delegation is really a read/write delegation. There is no such thing as
a write-only delegation.

Suppose the user is prevented from doing reads against the inode (by
permission bits or ACLs). The server gives out a WRITE delegation on a
O_WRONLY open. Will the client allow cached opens for read regardless
of the server's permissions? Or, does it know to check vs. the server
if the client tries to do an open for read in this situation?

That is a good point. As far as I can tell, the client will still send ACCESS to the server
in this case...

looks like vfs do_open->may_open will call inode_permission -> nfs_permission -> nfs_do_access...
I don't see any type of bypass if a delegation is present (correctly afaiu).

iiuc the only user that can omit talking to the server for access is the permissions field that is returned in the delegation, and nfsd keeps it cleared, so all users will need to issue access (if not already cached).




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux