Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2054400imj; Fri, 8 Feb 2019 11:46:03 -0800 (PST) X-Google-Smtp-Source: AHgI3IaYh6QpHJy1stbfaE/IW5MOrUTz/sw+72DajCz8lNz1xxijGRJfwpMH2yHSqNsgn3ym2KMo X-Received: by 2002:a62:35c7:: with SMTP id c190mr24485102pfa.76.1549655163353; Fri, 08 Feb 2019 11:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549655163; cv=none; d=google.com; s=arc-20160816; b=BoWhAXlvhBzoasPVubbBVvXmwaPJO7OGBkcQI6D1eRRE8e3OZlhlkmI8pEUL1GYZRB 1aq6fuf6Mk7gGodSNiWFilNRLWShVcQJsYqxdYDIHWSNLDkAtpxj90x14b4iAJF2vpEq snr2Sknlx6bubwBSiGEl/DRFY78TJUVwFfmKuHl/7R+BDKnGuedXoyj/6f/oEd1rSCsa ASaBdWMmmO1pQ0NSAtsGs/6GhybZb2EEnnC3B/phyG0KV0FsT6tKKrI0Xpjxvh96EZDD bZpShzdIh/TlvN7AC9Uyguw1A8OHeNjqpjjyr1+g2UtcrWUSrcuLhqe4IWlR2lRRVZ0W 1fuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xFueFI5/071Fx4axLAZxH/HE1WMNUNILwffGRVBAAcs=; b=NHbqjcy9QeJuA3RgiCshei6j0D/Cd6xhQEIoP6NHpWc0XQlitB7iWaar2d7T1h7+EO jsHCHE7wyBLI66Msk9QEcytQcolt+fBBFBTjfD6HwUW5nLJY2WqwhWG3f9zOLkA+WIWi FWNhqrhm82pFRDHQXAgqk1PiaQ0hsKisEFKK3bwWUgn0iUYwLgkd8ctxZacNyq2N9v+G 0jnCMnR3nE3lUPoYmSbTEC2K/ZsyPJ707CRkRY7iv6/JwQVN8HrjkxPICU5Tz/LCg4er JhvcI6rNETGqZurFXQgayx7m3ot/PlgD4o/uiJH2nMJYiw0HiRMa546spTEmUF+2oLLg mqng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bP2zqmDF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si2831215pgj.416.2019.02.08.11.45.46; Fri, 08 Feb 2019 11:46:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bP2zqmDF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727481AbfBHTpg (ORCPT + 99 others); Fri, 8 Feb 2019 14:45:36 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40572 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727187AbfBHTpe (ORCPT ); Fri, 8 Feb 2019 14:45:34 -0500 Received: by mail-pl1-f196.google.com with SMTP id u18so2172564plq.7 for ; Fri, 08 Feb 2019 11:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xFueFI5/071Fx4axLAZxH/HE1WMNUNILwffGRVBAAcs=; b=bP2zqmDFlGbZFLq7cF0xho2Haq7gG7uYD9PGUkLeQ1fKjp6ZXgoyRi6fjYuMkm1G4U k+KwyuQUg+pA7x5FnN5bJRDN5u9WZ7oQMcDhYoZ4m8fmzeNAswsEAYaFyFjcbT/6O8uH QIGAs81pPpE1pnjH0Wk72n6KMfC/M0mSCo/8KE8ZF2ygRro2WLLEcqwUeqlVhV2Ci5Jn HEy2HNQX3DMru5wa742Yl+FrpclgfcXrVl9EhRWqP1xTGvy5ZwEWt/xr1oK+mMThki9R mNW2sIYUSPrAnOwZTEw+Wr0qduJzbqG1skqGkoMt5gDaVSbhCmyVSKfJKudHdGQKw64O /T8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xFueFI5/071Fx4axLAZxH/HE1WMNUNILwffGRVBAAcs=; b=ek0ddd3U90cDQikShFnEgUdEZUmW7x+2fXx/509D1jGL9bEBsIJxdScvYA16Q2T/W8 or6hrVYABADkD9XFkY/OaBvqmKykxF14Pzq7uOTYBPA+T/b+3DD/ODzBT7ERCcYV72su WK4yamKh9Xg1hK2orIvALxiSTGcZOOYOha5cHiXrGB7gaY1z9j4AxA5GvYTp6GRENYE4 o8QrCciKCA5B4eLisHzLvatgqSq8QqEcwNhVxiEo13wjbHg6Vejnncn670PKbZwlmqCV dGDCvXGzjHtiDUxtstDDGxconu3zdLd30L5dHtTyinCEay2Ia1grlLlJ4AYwbhHhI2/6 SiqQ== X-Gm-Message-State: AHQUAuYk8pk2GHPjzofmnWiKUTcOZFDDfTlkuCriSe3oTFJamPDpnP6r MxEUHYIby09rd0Z4DoTmMgJ0O1z8/wPjqXePWIexLl9w X-Received: by 2002:a17:902:a50e:: with SMTP id s14mr12599375plq.311.1549655133249; Fri, 08 Feb 2019 11:45:33 -0800 (PST) MIME-Version: 1.0 References: <20181022134048.19693-1-david.engraf@sysgo.com> <20181030151805.5519-1-david.engraf@sysgo.com> In-Reply-To: <20181030151805.5519-1-david.engraf@sysgo.com> From: Andy Shevchenko Date: Fri, 8 Feb 2019 21:45:21 +0200 Message-ID: Subject: Re: [PATCH RESEND] initramfs: cleanup incomplete rootfs To: David Engraf Cc: Dominik Brodowski , Andrew Morton , Greg Kroah-Hartman , Philippe Ombredanne , Arnd Bergmann , Luc Van Oostenryck , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 5:22 PM David Engraf wrote: > > Unpacking an external initrd may fail e.g. not enough memory. This leads > to an incomplete rootfs because some files might be extracted already. > Fixed by cleaning the rootfs so the kernel is not using an incomplete > rootfs. This breaks my setup where I have U-boot provided more size of initramfs than needed. This allows a bit of flexibility to increase or decrease initramfs compressed image without taking care of bootloader. The proper solution is to do this if we sure that we didn't get enough memory, otherwise I can't consider the error fatal to clean up rootfs. Andrew, what it be good idea to revert for now? > Signed-off-by: David Engraf > --- > init/initramfs.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/init/initramfs.c b/init/initramfs.c > index 640557788026..aa3a46cfcb4e 100644 > --- a/init/initramfs.c > +++ b/init/initramfs.c > @@ -548,7 +548,6 @@ static void __init free_initrd(void) > initrd_end = 0; > } > > -#ifdef CONFIG_BLK_DEV_RAM > #define BUF_SIZE 1024 > static void __init clean_rootfs(void) > { > @@ -595,7 +594,6 @@ static void __init clean_rootfs(void) > ksys_close(fd); > kfree(buf); > } > -#endif > > static int __init populate_rootfs(void) > { > @@ -638,8 +636,10 @@ static int __init populate_rootfs(void) > printk(KERN_INFO "Unpacking initramfs...\n"); > err = unpack_to_rootfs((char *)initrd_start, > initrd_end - initrd_start); > - if (err) > + if (err) { > printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); > + clean_rootfs(); > + } > free_initrd(); > #endif > } > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko