Skip to contentSkip to conversation

ovl: disable uuid when redirect_dir is used

PATCH In review Vyacheslav Yurkov 2 participants 6 messages May 27, 2021 Overlay filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 ovl: disable uuid when redirect_dir is used

From: Vyacheslav Yurkov <[email protected]>

Currently decoding origin with lower null uuid is not allowed when user opted-in to one of the new features that require following the lower inode of non-dir upper (index, xino, metacopy). Now we add redirect_dir too to that feature list.

---
 fs/overlayfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/super.c +1 -1
index b01d4147520d..97ea35fdd933 100644
@@ -1600,7 +1600,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
 	 * lower inode of non-dir upper.
 	 */
 	if (!ofs->config.index && !ofs->config.metacopy &&
-	    ofs->config.xino != OVL_XINO_ON &&
+	    !ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON &&
 	    uuid_is_null(uuid))
 		return false;
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/3 ovl: add ovl_allow_offline_changes() helper

From: Vyacheslav Yurkov <[email protected]>

Allows to check whether any of extended features are enabled

---
 fs/overlayfs/overlayfs.h | 12 ++++++++++++
 fs/overlayfs/super.c     |  4 +---
 2 files changed, 13 insertions(+), 3 deletions(-)
fs/overlayfs/overlayfs.h +12 -0
index 6ec73db4bf9e..29d71f253db4 100644
@@ -262,6 +262,18 @@ static inline bool ovl_open_flags_need_copy_up(int flags)
 	return ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC));
 }
 
+static inline bool ovl_allow_offline_changes(struct ovl_fs *ofs)
+{
+	/*
+	 * To avoid regressions in existing setups with overlay lower offline
+	 * changes, we allow lower changes only if none of the new features
+	 * are used.
+	 */
+	return (!ofs->config.index && !ofs->config.metacopy &&
+		!ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON);
+}
+
+
 /* util.c */
 int ovl_want_write(struct dentry *dentry);
 void ovl_drop_write(struct dentry *dentry);
fs/overlayfs/super.c +1 -3
index 97ea35fdd933..a248cbad9a8c 100644
@@ -1599,9 +1599,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
 	 * user opted-in to one of the new features that require following the
 	 * lower inode of non-dir upper.
 	 */
-	if (!ofs->config.index && !ofs->config.metacopy &&
-	    !ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON &&
-	    uuid_is_null(uuid))
+	if (!ovl_allow_offline_changes(ofs) && uuid_is_null(uuid))
 		return false;
 
 	for (i = 0; i < ofs->numfs; i++) {
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH v2 2/3] ovl: add ovl_allow_offline_changes() helper

Quoted 39 lines · Vyacheslav Yurkov

From: Vyacheslav Yurkov <[email protected]>

Allows to check whether any of extended features are enabled

---
 fs/overlayfs/overlayfs.h | 12 ++++++++++++
 fs/overlayfs/super.c     |  4 +---
 2 files changed, 13 insertions(+), 3 deletions(-)
fs/overlayfs/overlayfs.h +12 -0
index 6ec73db4bf9e..29d71f253db4 100644
@@ -262,6 +262,18 @@ static inline bool ovl_open_flags_need_copy_up(int flags)
        return ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC));
 }
 
+static inline bool ovl_allow_offline_changes(struct ovl_fs *ofs)
+{
+       /*
+        * To avoid regressions in existing setups with overlay lower offline
+        * changes, we allow lower changes only if none of the new features
+        * are used.
+        */
+       return (!ofs->config.index && !ofs->config.metacopy &&
+               !ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON);
+}
+
+
 /* util.c */
 int ovl_want_write(struct dentry *dentry);
 void ovl_drop_write(struct dentry *dentry);
fs/overlayfs/super.c +0 -0
index 97ea35fdd933..a248cbad9a8c 100644

fs/overlayfs/super.c static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid) · line 1602

Quoted 7 lines
fs/overlayfs/super.c +1 -3
@@ -1599,9 +1599,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
         * user opted-in to one of the new features that require following the
         * lower inode of non-dir upper.
         */
-       if (!ofs->config.index && !ofs->config.metacopy &&
-           !ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON &&
-           uuid_is_null(uuid))
+       if (!ovl_allow_offline_changes(ofs) && uuid_is_null(uuid))

You accidently negated the condition.
IOW, allow_lower_changes and null_uuid are conflicting features.

Thanks,
Amir.

Quoted 6 lines
fs/overlayfs/super.c +0 -1
                return false;
 
        for (i = 0; i < ofs->numfs; i++) {
--

2.25.1

#3 lore raw

PATCH v2 3/3 ovl: do not set overlay.opaque for new directories

In reply to Vyacheslav Yurkov

From: Vyacheslav Yurkov <[email protected]>

Disable optimizations if user opted-in for any of extended features. If optimization is enabled, it breaks existing use case when a lower layer directory appears after directory was created on a merged layer. If overlay.opaque is applied, new files on lower layer are not visible.

Consider the following scenario:
- /lower and /upper are mounted to /merged
- directory /merged/new-dir is created with a file test1
- overlay is unmounted
- directory /lower/new-dir is created with a file test2
- overlay is mounted again

If opaque is applied by default, file test2 is not going to be visible without explicitly clearing the overlay.opaque attribute

---
 fs/overlayfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/overlayfs/dir.c +3 -1
index 93efe7048a77..03a22954fe61 100644
@@ -320,6 +320,7 @@ static bool ovl_type_origin(struct dentry *dentry)
 static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
 			    struct ovl_cattr *attr)
 {
+	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
 	struct inode *udir = upperdir->d_inode;
 	struct dentry *newdentry;
@@ -338,7 +339,8 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
 	if (IS_ERR(newdentry))
 		goto out_unlock;
 
-	if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry)) {
+	if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry) &&
+	    !ovl_allow_offline_changes(ofs)) {
 		/* Setting opaque here is just an optimization, allow to fail */
 		ovl_set_opaque(dentry, newdentry);
 	}
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH v2 3/3] ovl: do not set overlay.opaque for new directories

Quoted 4 lines · Vyacheslav Yurkov

From: Vyacheslav Yurkov <[email protected]>

Disable optimizations if user opted-in for any of extended features.

The code is correct. The comment is negated.
Your setup is a default setup - you did NOT opt-in to any new feature. Only in setups like those we disable the optimization.

Thanks,
Amir.

Quoted 44 lines

If optimization is enabled, it breaks existing use case when a lower layer directory appears after directory was created on a merged layer. If overlay.opaque is applied, new files on lower layer are not visible.

Consider the following scenario:
- /lower and /upper are mounted to /merged
- directory /merged/new-dir is created with a file test1
- overlay is unmounted
- directory /lower/new-dir is created with a file test2
- overlay is mounted again

If opaque is applied by default, file test2 is not going to be visible without explicitly clearing the overlay.opaque attribute

---
 fs/overlayfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/overlayfs/dir.c +3 -2
index 93efe7048a77..03a22954fe61 100644
@@ -320,6 +320,7 @@ static bool ovl_type_origin(struct dentry *dentry)
 static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
                            struct ovl_cattr *attr)
 {
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
        struct inode *udir = upperdir->d_inode;
        struct dentry *newdentry;
@@ -338,7 +339,8 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
        if (IS_ERR(newdentry))
                goto out_unlock;
 
-       if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry)) {
+       if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry) &&
+           !ovl_allow_offline_changes(ofs)) {
                /* Setting opaque here is just an optimization, allow to fail */
                ovl_set_opaque(dentry, newdentry);
        }
--

2.25.1

maintainer
#5 lore raw
In reply to Vyacheslav Yurkov
Quoted 5 lines · Vyacheslav Yurkov

From: Vyacheslav Yurkov <[email protected]>

Currently decoding origin with lower null uuid is not allowed when user opted-in to one of the new features that require following the lower inode

Confusing. It is not allowed *unless* user opted-in... I admit the comment could have been more clear.

The commit subject is also not accurate, maybe:
"ovl: disable decoding null uuid with redirect dir"

Thanks,
Amir.

Quoted 24 lines

of non-dir upper (index, xino, metacopy). Now we add redirect_dir too to that feature list.

---
 fs/overlayfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/super.c +1 -2
index b01d4147520d..97ea35fdd933 100644
@@ -1600,7 +1600,7 @@ static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
         * lower inode of non-dir upper.
         */
        if (!ofs->config.index && !ofs->config.metacopy &&
-           ofs->config.xino != OVL_XINO_ON &&
+           !ofs->config.redirect_dir && ofs->config.xino != OVL_XINO_ON &&
            uuid_is_null(uuid))
                return false;
 
--

2.25.1