From patchwork Sun Jun 19 11:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 637674 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rXXdl4HQrz9sxR for ; Sun, 19 Jun 2016 22:01:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=G79dSUT9; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bEbNv-0006Bc-1O; Sun, 19 Jun 2016 11:59:27 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bEbNs-00067o-E7 for lede-dev@lists.infradead.org; Sun, 19 Jun 2016 11:59:26 +0000 Received: by mail-wm0-x242.google.com with SMTP id a66so2620399wme.2 for ; Sun, 19 Jun 2016 04:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version; bh=zYw8S6wtPghHcfW6kiP4WZ30tQVU5wGzOSI3UgZSB/0=; b=G79dSUT92kJt812dTVfdOrX5kbHSYVOVlzIjARDUZwpBL4mp2cf9eY/mkdWAzVHYRi 3bwYaYnmpDvUIdmLH9aucJH9Ldj9zKgNoWhkWMhu6guZNEYAY43/6+IDUuiAuakv/bHt NOPXSGW4ifXYmfHk5lHJoJiF8PtARGR3cW7Rfd8C4x2+hgQIKZwZvnfhQpL11nmGEUfX k/an4VczHH+wLh3p5DLbS75ZH/u0gZ35kHe4ssM3lPJtwEmKiwOl+TZ+NsSFcfA61hQc cI7/B5bbhS7JssSjMWuUpze4wWMfobW5CoUl/4M14jcnKFNbB2YYY9aLStKFPVyRX4Xt RLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=zYw8S6wtPghHcfW6kiP4WZ30tQVU5wGzOSI3UgZSB/0=; b=IIRLtxN8eU6nxuGDEyDCkRP9HSD4giE8oEpwAqD0cUkXA9JkwbdTFSTeKjz3k3ywlu ovGmw8pmr1zg69kmWViBvwIzszTMwPoh1umBEli72fi3fmt8fsnLeUuHPK/tpuBQG7Iy tLdvb4QAaUaanPDs1v2MxPqbbvFr+oqTJPY27Icwhi0jQ0UbOYAfgd0eMKriYErm7GF/ ZHHL1hVM336pKOVG8bRdUN5Wo7T9t4imvWOHGu3oWhnEafUqDhsArcmqeLqvd3X1zedJ GtMPTouNq3n8QDteCkAhQleWYzQXywZHQyYGh6Qo/84eCzyXFwUo7zTGxDx1mZ6FLdUs 2uSw== X-Gm-Message-State: ALyK8tJdcmsBVcQvYh7o2Ksr8Ixwn1YgJzxAUY8HVhaK5iOvUH5Sqg6gh0QojAEpYnyWdw== X-Received: by 10.194.139.162 with SMTP id qz2mr10053669wjb.111.1466337542466; Sun, 19 Jun 2016 04:59:02 -0700 (PDT) Received: from ?IPv6:2a02:810b:8c40:1414:78e9:a59b:caa0:2d95? ([2a02:810b:8c40:1414:78e9:a59b:caa0:2d95]) by smtp.gmail.com with ESMTPSA id q6sm30491735wjt.46.2016.06.19.04.59.01 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Jun 2016 04:59:01 -0700 (PDT) To: lede-dev@lists.infradead.org From: Josua Mayer Message-ID: <5768f92a-d15a-37f5-28c7-e7a78d6703ac@gmail.com> Date: Sun, 19 Jun 2016 13:59:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160619_045924_805310_65EE1A4F X-CRM114-Status: GOOD ( 29.84 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (josua.mayer97[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (josua.mayer97[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] fstools: ext4 overlay support - rootfs mounted twice bug X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hi everybody, Some of you might remember that there was a bug where an ext4 rootfs was mounted twice, first as / and then as overlay. After staring down the mount_root.c file I think I spotted the reason for it. Sadly I was not able to reproduce the original problem so I am looking for somebody who had this issue and would be willing to try out a patch of mine. Please get back at me if you can. For any interested people I am attaching the patch to this mail (this is not yet a patch submission, just discussion). br Josua Mayer From 01139eeee6474898dff8024ea411e1385d3b5858 Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Thu, 16 Jun 2016 18:35:30 +0200 Subject: [PATCH 2/2] mount_root: Don't mount ext4 rootfs twice When there is a) no rootfs_data overlay partition, and b) /dev/root points to an ext4 partition the partition would be mounted twice, once as / and then as /overlay. The essence of this change is to return before mounting /overlay, if /dev/root has been mounted as /. --- mount_root.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/mount_root.c b/mount_root.c index 608ce5d..13e5772 100644 --- a/mount_root.c +++ b/mount_root.c @@ -37,25 +37,45 @@ start(int argc, char *argv[1]) if (!getenv("PREINIT") && stat("/tmp/.preinit", &s)) return -1; + /* + * When the default overlay partition name rootfs_data can not be found, + * fall back to the special /dev/root device. + */ if (!data) { root = volume_find("rootfs"); volume_init(root); + + // mount /dev/root at / ULOG_NOTE("mounting /dev/root\n"); mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT, 0); - } - /* - * Before trying to mount and use "rootfs_data" let's check if there is - * extroot configured. Following call will handle reading config from - * the "rootfs_data" on its own. - */ - extroot_prefix = ""; - if (!mount_extroot()) { - ULOG_NOTE("switched to extroot\n"); + /* + * Now that / has been mounted, and there is no overlay device, + * see if extroot is configured. + * + * The following call will handle reading configuration from + * rootfs on its own. + */ + extroot_prefix = ""; + if (!mount_extroot()) { + ULOG_NOTE("switched to extroot\n"); + /* + * extroot succeeded mounting an overlay partition, return. + */ + return 0; + } + + /* + * Even if extroot was not configured, considering that no overlay + * partition was found, and / was mounted, return now. + */ return 0; } - /* There isn't extroot, so just try to mount "rootfs_data" */ + /* + * neither /dev/root nor extroot were used. + * Attempt to mount the overlay partition. + */ switch (volume_identify(data)) { case FS_NONE: ULOG_WARN("no usable overlay filesystem found, using tmpfs overlay\n"); -- 2.8.4