From owner-freebsd-bugs@freebsd.org Thu Nov 26 02:50:15 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A62047DDA2 for ; Thu, 26 Nov 2020 02:50:15 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4ChMgV6npDz4qS9 for ; Thu, 26 Nov 2020 02:50:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id E90E047DDA1; Thu, 26 Nov 2020 02:50:14 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E8CE247DC3A for ; Thu, 26 Nov 2020 02:50:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChMgV68X8z4qPN for ; Thu, 26 Nov 2020 02:50:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5B1A1C18B for ; Thu, 26 Nov 2020 02:50:14 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AQ2oEH3087802 for ; Thu, 26 Nov 2020 02:50:14 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 0AQ2oE01087801 for bugs@FreeBSD.org; Thu, 26 Nov 2020 02:50:14 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 251363] use unionfs as a disk-cache for NFS [feature] Date: Thu, 26 Nov 2020 02:50:15 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: raj@gusw.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 02:50:15 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251363 --- Comment #9 from Gunther Schadow --- For completeness sake, I updated the mount_unionfs.8 man file also. Full diff out of /usr/src with svnlite diff -x-w: Index: sbin/mount_unionfs/mount_unionfs.8 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sbin/mount_unionfs/mount_unionfs.8 (revision 368012) +++ sbin/mount_unionfs/mount_unionfs.8 (working copy) @@ -83,6 +83,16 @@ However, .Ar uniondir remains the mount point. +.It Cm copypolicy No =3D Cm onwrite | always +The normal behavior is copy-on-write with +.Cm onwrite +this is the standaed unionfs behavior. If +.Cm always +is spefied, then the a copy is made on the upper layer even if the +file or directory is accessed only for reading. This effectively +turns the upper layer into a cache which is an easy way to implement +a disk cache over an NFS filesystem, speeding up all subsequent accesses, +very useful for network booted systems. .It Cm copymode No =3D Cm traditional | transparent | masquerade Specifies the way to create a file or a directory in the upper layer automatically when needed. Index: sys/fs/unionfs/union.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/fs/unionfs/union.h (revision 368012) +++ sys/fs/unionfs/union.h (working copy) @@ -40,6 +40,12 @@ #ifdef _KERNEL +/* copy policy from lower to upper layer */ +typedef enum _unionfs_copypolicy { + UNIONFS_COPY_ON_WRITE =3D 0, + UNIONFS_COPY_ALWAYS +} unionfs_copypolicy; + /* copy method of attr from lower to upper */ typedef enum _unionfs_copymode { UNIONFS_TRADITIONAL =3D 0, @@ -57,6 +63,7 @@ struct vnode *um_lowervp; /* VREFed once */ struct vnode *um_uppervp; /* VREFed once */ struct vnode *um_rootvp; /* ROOT vnode */ + unionfs_copypolicy um_copypolicy; unionfs_copymode um_copymode; unionfs_whitemode um_whitemode; uid_t um_uid; Index: sys/fs/unionfs/union_vfsops.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/fs/unionfs/union_vfsops.c (revision 368012) +++ sys/fs/unionfs/union_vfsops.c (working copy) @@ -89,6 +89,7 @@ gid_t gid; u_short udir; u_short ufile; + unionfs_copypolicy copypolicy; unionfs_copymode copymode; unionfs_whitemode whitemode; struct nameidata nd, *ndp; @@ -102,6 +103,7 @@ gid =3D 0; udir =3D 0; ufile =3D 0; + copypolicy =3D UNIONFS_COPY_ON_WRITE; copymode =3D UNIONFS_TRANSPARENT; /* default */ whitemode =3D UNIONFS_WHITE_ALWAYS; ndp =3D &nd; @@ -190,6 +192,20 @@ return (EINVAL); } } + if (vfs_getopt(mp->mnt_optnew, "copypolicy", (void **)&tmp, + NULL) =3D=3D 0) { + if (tmp =3D=3D NULL) { + vfs_mount_error(mp, "Invalid copy policy"); + return (EINVAL); + } else if (strcasecmp(tmp, "always") =3D=3D 0) + copypolicy =3D UNIONFS_COPY_ALWAYS; + else if (strcasecmp(tmp, "onwrite") =3D=3D 0) + copypolicy =3D UNIONFS_COPY_ON_WRITE; + else { + vfs_mount_error(mp, "Invalid copy policy"); + return (EINVAL); + } + } if (vfs_getopt(mp->mnt_optnew, "copymode", (void **)&tmp, NULL) =3D=3D 0) { if (tmp =3D=3D NULL) { @@ -229,7 +245,7 @@ UNIONFSDEBUG("unionfs_mount: uid=3D%d, gid=3D%d\n", uid, gid); UNIONFSDEBUG("unionfs_mount: udir=3D0%03o, ufile=3D0%03o\n", udir, = ufile); - UNIONFSDEBUG("unionfs_mount: copymode=3D%d\n", copymode); + UNIONFSDEBUG("unionfs_mount: copypolicy=3D%d, copymode=3D%d, whitemode=3D%d\n", copypolicy, copymode, whitemode); /* * Find upper node @@ -265,6 +281,7 @@ ump->um_gid =3D gid; ump->um_udir =3D udir; ump->um_ufile =3D ufile; + ump->um_copypolicy =3D copypolicy; ump->um_copymode =3D copymode; ump->um_whitemode =3D whitemode; Index: sys/fs/unionfs/union_vnops.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/fs/unionfs/union_vnops.c (revision 368012) +++ sys/fs/unionfs/union_vnops.c (working copy) @@ -464,6 +464,7 @@ { int error; struct unionfs_node *unp; + struct unionfs_mount *ump; struct unionfs_node_status *unsp; struct vnode *uvp; struct vnode *lvp; @@ -477,6 +478,7 @@ error =3D 0; unp =3D VTOUNIONFS(ap->a_vp); + ump =3D MOUNTTOUNIONFSMOUNT(ap->a_vp->v_mount); uvp =3D unp->un_uppervp; lvp =3D unp->un_lowervp; targetvp =3D NULLVP; @@ -498,7 +500,7 @@ } if (targetvp =3D=3D NULLVP) { if (uvp =3D=3D NULLVP) { - if ((ap->a_mode & FWRITE) && lvp->v_type =3D=3D VRE= G) { + if (((ap->a_mode & FWRITE) || (ump->um_copypolicy = =3D=3D UNIONFS_COPY_ALWAYS)) && lvp->v_type =3D=3D VREG) { error =3D unionfs_copyfile(unp, !(ap->a_mode & O_TRUNC), cred, td); if (error !=3D 0) r --=20 You are receiving this mail because: You are the assignee for the bug.=