unionfs a little improvement

From: Daichi GOTO <daichi_at_freebsd.org>
Date: Wed, 18 Aug 2010 17:52:33 +0900
Hi Ed and unionfs fan gyus.

Ed pointed out a contradict behavior between current
unionfs implementation and its manual, and sent me a
patch.

Thanks Ed ;)

----
Index: sys/fs/unionfs/union_vfsops.c
===================================================================
--- sys/fs/unionfs/union_vfsops.c	(revision 211093)
+++ sys/fs/unionfs/union_vfsops.c	(working copy)
_at__at_ -89,7 +89,6 _at__at_
  	u_short		ufile;
  	unionfs_copymode copymode;
  	unionfs_whitemode whitemode;
-	struct componentname fakecn;
  	struct nameidata nd, *ndp;
  	struct vattr	va;

_at__at_ -280,26 +279,6 _at__at_
  	mp->mnt_flag |= ump->um_uppervp->v_mount->mnt_flag & MNT_RDONLY;

  	/*
-	 * Check whiteout
-	 */
-	if ((mp->mnt_flag & MNT_RDONLY) == 0) {
-		memset(&fakecn, 0, sizeof(fakecn));
-		fakecn.cn_nameiop = LOOKUP;
-		fakecn.cn_thread = td;
-		error = VOP_WHITEOUT(ump->um_uppervp, &fakecn, LOOKUP);
-		if (error) {
-			if (below) {
-				VOP_UNLOCK(ump->um_uppervp, 0);
-				vrele(upperrootvp);
-			} else
-				vput(ump->um_uppervp);
-			free(ump, M_UNIONFSMNT);
-			mp->mnt_data = NULL;
-			return (error);
-		}
-	}
-
-	/*
  	 * Unlock the node
  	 */
  	VOP_UNLOCK(ump->um_uppervp, 0);

----

Ed's message here:

----
Just for fun I was hacking on a writable bootcd, using unionfs and
tmpfs. I noticed tmpfs doesn't support whiteouts (yet). This prevents
unionfs from mounting tmpfs on top. I do want to be able to use tmpfs,
even if it means we can't get any whiteouts.

The manpage says the following:

     Without whiteout support from the file system backing the upper layer,
     there is no way that delete and rename operations on lower layer 
objects
     can be done.  EROFS is returned for this kind of operations along with
     any others which would make modifications to the lower layer, such as
     chmod(1).

This seems to contradict the current behaviour, which is to deny the
mount altogether. The attached patch makes it work, but instead of
EROFS, it now returns EOPNOTSUPP, as generated by VOP_WHITEOUT().
----


It looks like reasonable and patch is simple and effective I guess.
If you unionfs guys or fs guys have some ideas around this patch,
please teach me.

After some tests and a couple of weeks after, I'll commit ed's patch
if there is no objections.


-- 
Daichi GOTO
81-42-316-7945 | daichi_at_ongs.co.jp | http://www.ongs.co.jp
LinkedIn: http://linkedin.com/in/daichigoto
Received on Wed Aug 18 2010 - 07:10:54 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:06 UTC