summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nfsclient/nfs_vnops.c')
-rw-r--r--sys/nfsclient/nfs_vnops.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 872317b..ca9edad 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -507,6 +507,7 @@ nfs_open(struct vop_open_args *ap)
struct vattr vattr;
int error;
int fmode = ap->a_mode;
+ struct ucred *cred;
if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK)
return (EOPNOTSUPP);
@@ -563,7 +564,22 @@ nfs_open(struct vop_open_args *ap)
}
np->n_directio_opens++;
}
+
+ /*
+ * If this is an open for writing, capture a reference to the
+ * credentials, so they can be used by nfs_putpages(). Using
+ * these write credentials is preferable to the credentials of
+ * whatever thread happens to be doing the VOP_PUTPAGES() since
+ * the write RPCs are less likely to fail with EACCES.
+ */
+ if ((fmode & FWRITE) != 0) {
+ cred = np->n_writecred;
+ np->n_writecred = crhold(ap->a_cred);
+ } else
+ cred = NULL;
mtx_unlock(&np->n_mtx);
+ if (cred != NULL)
+ crfree(cred);
vnode_create_vobject(vp, vattr.va_size, ap->a_td);
return (0);
}
OpenPOWER on IntegriCloud