Date: Tue, 15 May 2012 12:50:49 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r235473 - projects/nfsv4.1-client/sys/fs/nfsclient Message-ID: <201205151250.q4FConxx088575@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Tue May 15 12:50:49 2012 New Revision: 235473 URL: http://svn.freebsd.org/changeset/base/235473 Log: Add a flag to the NFSv4.1 pNFS client that marks a file as being opened for writing. Use this flag to decide to get a RW layout for a read, if it is set. Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clvnops.c projects/nfsv4.1-client/sys/fs/nfsclient/nfsnode.h Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Tue May 15 12:08:51 2012 (r235472) +++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clrpcops.c Tue May 15 12:50:49 2012 (r235473) @@ -5338,8 +5338,11 @@ if (error == 2) printf("rwacc=0x%x\n", r if (layp == NULL) { /* Try and get a Layout, if it is supported. */ stateid.seqid = 0; - iolaymode = (rwaccess == NFSV4OPEN_ACCESSWRITE) ? - NFSLAYOUTIOMODE_RW : NFSLAYOUTIOMODE_READ; + if (rwaccess == NFSV4OPEN_ACCESSWRITE || + (np->n_flag & NWRITEOPENED) != 0) + iolaymode = NFSLAYOUTIOMODE_RW; + else + iolaymode = NFSLAYOUTIOMODE_READ; error = nfsrpc_getlayout(nmp, vp, np->n_fhp, iolaymode, NULL, &stateid, &layp, newcred, p); if (error != 0) { Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clvnops.c Tue May 15 12:08:51 2012 (r235472) +++ projects/nfsv4.1-client/sys/fs/nfsclient/nfs_clvnops.c Tue May 15 12:50:49 2012 (r235473) @@ -604,7 +604,12 @@ nfs_open(struct vop_open_args *ap) } np->n_directio_opens++; } + + /* If opened for writing via NFSv4.1 or later, mark that for pNFS. */ + if (NFSHASPNFS(VFSTONFS(vp->v_mount)) && (fmode & FWRITE) != 0) + np->n_flag |= NWRITEOPENED; mtx_unlock(&np->n_mtx); + vnode_create_vobject(vp, vattr.va_size, ap->a_td); return (0); } Modified: projects/nfsv4.1-client/sys/fs/nfsclient/nfsnode.h ============================================================================== --- projects/nfsv4.1-client/sys/fs/nfsclient/nfsnode.h Tue May 15 12:08:51 2012 (r235472) +++ projects/nfsv4.1-client/sys/fs/nfsclient/nfsnode.h Tue May 15 12:50:49 2012 (r235473) @@ -155,6 +155,7 @@ struct nfsnode { #define NLOCK 0x00008000 /* Sleep lock the node */ #define NLOCKWANT 0x00010000 /* Want the sleep lock */ #define NNOLAYOUT 0x00020000 /* Can't get a layout for this file */ +#define NWRITEOPENED 0x00040000 /* Has been opened for writing */ /* * Convert between nfsnode pointers and vnode pointers
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205151250.q4FConxx088575>