From patchwork Fri May 29 13:38:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huehn X-Patchwork-Id: 477893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AB956140F95 for ; Fri, 29 May 2015 23:38:34 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EF580286F89; Fri, 29 May 2015 15:36:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id BBCD5281685 for ; Fri, 29 May 2015 15:36:38 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -7.6 Received: from mail.net.t-labs.tu-berlin.de (mail.net.t-labs.tu-berlin.de [130.149.220.252]) by arrakis.dune.hu (Postfix) with ESMTP for ; Fri, 29 May 2015 15:36:38 +0200 (CEST) Received: from bob.bowl.t-labs.tu-berlin.de (unknown [130.149.221.98]) by mail.net.t-labs.tu-berlin.de (Postfix) with ESMTPSA id 5871E84EBE; Fri, 29 May 2015 15:38:07 +0200 (CEST) From: Thomas Huehn To: openwrt-devel@lists.openwrt.org Date: Fri, 29 May 2015 15:38:04 +0200 Message-Id: <1432906684-26210-1-git-send-email-thomas@net.t-labs.tu-berlin.de> X-Mailer: git-send-email 2.4.0 Cc: nbd@nbd.name Subject: [OpenWrt-Devel] [PATCH v4] [kernel] upstream fix: mount overlayfs r/o if workdir cannot be created X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 Signed-off-by: Bastian Bittorf --- ...-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 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; ++ } + } + + /*