diff mbox

[OpenWrt-Devel,v4,kernel] upstream fix: mount overlayfs r/o if workdir cannot be created

Message ID 1432906684-26210-1-git-send-email-thomas@net.t-labs.tu-berlin.de
State Superseded
Headers show

Commit Message

Thomas Huehn May 29, 2015, 1:38 p.m. UTC
This is the case e.g. if JFFS2 partition is full.

see: https://www.mail-archive.com/linux-unionfs@vger.kernel.org/msg00246.html
(a small error in a logmessage was changed and reported upstream)

runtime tested on ar71xx with kernel 3.18.11 and r45772
this paritially fixes #19564

Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>
---
 ...-overlayfs-fallback-to-readonly-when-full.patch | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 target/linux/generic/patches-3.18/912-overlayfs-fallback-to-readonly-when-full.patch

Comments

Rafał Miłecki May 29, 2015, 2:13 p.m. UTC | #1
On 29 May 2015 at 15:38, Thomas Huehn <thomas@net.t-labs.tu-berlin.de> wrote:
> +Index: linux-3.18.14/fs/overlayfs/copy_up.c
> +===================================================================
> +--- linux-3.18.14.orig/fs/overlayfs/copy_up.c  2015-05-20 17:04:50.000000000 +0200
> ++++ linux-3.18.14/fs/overlayfs/copy_up.c       2015-05-29 13:58:51.281147554 +0200
> +@@ -300,6 +300,9 @@

Your patch seems to be wrongly formatted, please see
http://wiki.openwrt.org/doc/devel/patches
(and setup your ~/.quiltrc)
Christian Mehlis May 29, 2015, 4:43 p.m. UTC | #2
Am 29.05.2015 um 15:38 schrieb Thomas Huehn:
> This is the case e.g. if JFFS2 partition is full.
>
> see: https://www.mail-archive.com/linux-unionfs@vger.kernel.org/msg00246.html
> (a small error in a logmessage was changed and reported upstream)
>
> runtime tested on ar71xx with kernel 3.18.11 and r45772
> this paritially fixes #19564

this patch is superfluous because it's already merged...

http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=f521e44327cab409ba0e4557ba491ef8243cb23e

Best
Christian
Bastian Bittorf May 29, 2015, 5:02 p.m. UTC | #3
* Christian Mehlis <christian@m3hlis.de> [29.05.2015 19:00]:
> this patch is superfluous because it's already merged...

Thomas is right, i send it only for ar71xx, but it should
be in the generic 3.18-patchfolder. I'am already compiling
some other platforms and test it. if ok, i will send v5
which will revert the old and place the patch in generic...

bye, bastian
John Crispin May 29, 2015, 6:53 p.m. UTC | #4
On 29/05/2015 18:43, Christian Mehlis wrote:
> Am 29.05.2015 um 15:38 schrieb Thomas Huehn:
>> This is the case e.g. if JFFS2 partition is full.
>>
>> see:
>> https://www.mail-archive.com/linux-unionfs@vger.kernel.org/msg00246.html
>> (a small error in a logmessage was changed and reported upstream)
>>
>> runtime tested on ar71xx with kernel 3.18.11 and r45772
>> this paritially fixes #19564
> 
> this patch is superfluous because it's already merged...
> 
> http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=f521e44327cab409ba0e4557ba491ef8243cb23e
> 
> 

unfortunatley in the wrong folder and not for 4.0

i am working on the fix just now



> Best
> Christian
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Thomas Huehn May 30, 2015, 9:30 a.m. UTC | #5
Hi Rafal,

> Your patch seems to be wrongly formatted, please see
> http://wiki.openwrt.org/doc/devel/patches
> (and setup your ~/.quiltrc)

Thx for this hint … just updated my .quiltrc for proper future patch submissions :)

Greetings Thomas

> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
diff mbox

Patch

diff --git a/target/linux/generic/patches-3.18/912-overlayfs-fallback-to-readonly-when-full.patch b/target/linux/generic/patches-3.18/912-overlayfs-fallback-to-readonly-when-full.patch
new file mode 100644
index 0000000..9e5fad4
--- /dev/null
+++ b/target/linux/generic/patches-3.18/912-overlayfs-fallback-to-readonly-when-full.patch
@@ -0,0 +1,73 @@ 
+Index: linux-3.18.14/fs/overlayfs/copy_up.c
+===================================================================
+--- linux-3.18.14.orig/fs/overlayfs/copy_up.c	2015-05-20 17:04:50.000000000 +0200
++++ linux-3.18.14/fs/overlayfs/copy_up.c	2015-05-29 13:58:51.281147554 +0200
+@@ -300,6 +300,9 @@
+ 	struct cred *override_cred;
+ 	char *link = NULL;
+ 
++	if (WARN_ON(!workdir))
++		return -EROFS;
++
+ 	ovl_path_upper(parent, &parentpath);
+ 	upperdir = parentpath.dentry;
+ 
+Index: linux-3.18.14/fs/overlayfs/dir.c
+===================================================================
+--- linux-3.18.14.orig/fs/overlayfs/dir.c	2015-05-20 17:04:50.000000000 +0200
++++ linux-3.18.14/fs/overlayfs/dir.c	2015-05-29 14:00:55.727646504 +0200
+@@ -222,6 +222,9 @@
+ 	struct kstat stat;
+ 	int err;
+ 
++	if (WARN_ON(!workdir))
++		return ERR_PTR(-EROFS);
++
+ 	err = ovl_lock_rename_workdir(workdir, upperdir);
+ 	if (err)
+ 		goto out;
+@@ -322,6 +325,9 @@
+ 	struct dentry *newdentry;
+ 	int err;
+ 
++	if (WARN_ON(!workdir))
++		return -EROFS;
++
+ 	err = ovl_lock_rename_workdir(workdir, upperdir);
+ 	if (err)
+ 		goto out;
+@@ -506,6 +512,9 @@
+ 	struct dentry *opaquedir = NULL;
+ 	int err;
+ 
++	if (WARN_ON(!workdir))
++		return -EROFS;
++
+ 	if (is_dir) {
+ 		opaquedir = ovl_check_empty_and_clear(dentry);
+ 		err = PTR_ERR(opaquedir);
+Index: linux-3.18.14/fs/overlayfs/super.c
+===================================================================
+--- linux-3.18.14.orig/fs/overlayfs/super.c	2015-05-20 17:04:50.000000000 +0200
++++ linux-3.18.14/fs/overlayfs/super.c	2015-05-29 14:05:45.901472157 +0200
+@@ -740,9 +740,17 @@
+ 	ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
+ 	err = PTR_ERR(ufs->workdir);
+ 	if (IS_ERR(ufs->workdir)) {
+-		pr_err("overlayfs: failed to create directory %s/%s\n",
+-		       ufs->config.workdir, OVL_WORKDIR_NAME);
+-		goto out_put_lower_mnt;
++		if (err == -ENOSPC || err == -EROFS) {
++			pr_warning("overlayfs: failed to create work directory"
++				   " (%s), mounting read-only\n",
++				   err == ENOSPC ? "ENOSPC" : "EROFS");
++			sb->s_flags |= MS_RDONLY;
++			ufs->workdir = NULL;
++		} else {
++			pr_err("overlayfs: failed to create directory %s/%s\n",
++				ufs->config.workdir, OVL_WORKDIR_NAME);
++			goto out_put_lower_mnt;
++		}
+ 	}
+ 
+ 	/*