[PATCH 07/10] ovl: mount overlay read-only on failure to verify index dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just like on failure to create work dir or index dir, when
index dir verification or cleanup fails, mount the overlay
read-only with a warning instead of failing the mount.

Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 fs/overlayfs/super.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 215b6d23d944..fbb317ad55f6 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1066,19 +1066,21 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 			/* Verify upper root is index dir origin */
 			err = ovl_verify_origin(ufs->indexdir, ufs->upper_mnt,
 						upperpath.dentry, true, true);
-			if (err)
-				pr_err("overlayfs: failed to verify index dir origin\n");
-
 			/* Cleanup bad/stale/orphan index entries */
 			if (!err)
 				err = ovl_indexdir_cleanup(ufs->indexdir,
 							   ufs->upper_mnt,
 							   stack, numlower);
+			if (err)
+				pr_warn("overlayfs: failed to verify index dir (err=%i); mounting read-only\n",
+					err);
+		}
+		if (err || !ufs->indexdir) {
+			pr_warn("overlayfs: delete index dir or mount with '-o index=off' to disable inodes index.\n");
+			sb->s_flags |= MS_RDONLY;
+			dput(ufs->indexdir);
+			ufs->indexdir = NULL;
 		}
-		if (err || !ufs->indexdir)
-			pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n");
-		if (err)
-			goto out_put_indexdir;
 	}
 
 	if (remote)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux