namei: Add cn_flags bits for OPENREAD and OPENWRITE

VOP_LOOKUP() is called with cn_flags bits ISLASTCN and ISOPEN
to indicate that the lookup is for the last component of a pathname
when doing open.

If the cn_flags also indicates if the open is for Reading, Writing or Both,
the NFSv4 client can do an NFSv4 Open operation in the same compound
RPC as Lookup, often avoiding the additional Open RPC now done when
VOP_OPEN() is called.

This patch defines two new cn_flags bits called OPENREAD and OPENWRITE
and sets these in open2nameif() based on FREAD, FWRITE flag bits.
This will allow a subsequent patch to the NFSv4 client to do the Open
operation in the same RPC as Lookup.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D31431
This commit is contained in:
Rick Macklem 2021-08-06 18:41:11 -07:00
parent fd0ffba3b4
commit c18c74a87c
2 changed files with 6 additions and 2 deletions

View File

@ -205,6 +205,10 @@ open2nameif(int fmode, u_int vn_open_flags)
res |= RBENEATH;
if ((fmode & O_EMPTY_PATH) != 0)
res |= EMPTYPATH;
if ((fmode & FREAD) != 0)
res |= OPENREAD;
if ((fmode & FWRITE) != 0)
res |= OPENWRITE;
if ((vn_open_flags & VN_OPEN_NOAUDIT) == 0)
res |= AUDITVNODE1;
if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0)

View File

@ -183,8 +183,8 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status,
#define AUDITVNODE1 0x00040000 /* audit the looked up vnode information */
#define AUDITVNODE2 0x00080000 /* audit the looked up vnode information */
#define NOCAPCHECK 0x00100000 /* do not perform capability checks */
/* UNUSED 0x00200000 */
/* UNUSED 0x00400000 */
#define OPENREAD 0x00200000 /* open for reading */
#define OPENWRITE 0x00400000 /* open for writing */
/* UNUSED 0x00800000 */
#define HASBUF 0x01000000 /* has allocated pathname buffer */
#define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */