Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp277452ybg; Wed, 3 Jun 2020 00:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqMvuri15/vr/x4oT8iLnZcta8nz3T2hmdYIn6yzPT//MLXR8WQpgtMaRLOXs6LW+1pU95 X-Received: by 2002:a50:b082:: with SMTP id j2mr30521729edd.201.1591167975152; Wed, 03 Jun 2020 00:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591167975; cv=none; d=google.com; s=arc-20160816; b=ZeNYTu6/T5HgHJcvfycfUpcgaXmDsjescg723fL7IoXWRER4QqnQysoxQSxIvXOyRW zKr9WvZ8RpSwDXFem2cQAnU++JEfc/LzKFjj+oVOvY9414SN1pTAqHhTiIGv/xy4ZkmP epNZ8mPHBuJ5dwB6LgEhH1aD/edAxW5GYCsNvoOLBlJTeZ2qatY/3aQogTAD6v/VgUlk UTpMKp4yWRIZfAspk74tw6xtI5brTFwjQVbFLsXihd/8JXkE1a/g0lU6fFNcyShBdnUX XAEa47FMld2mlL2g3iuHfASO8Bl0fbfp7lkWT1HEW8grc6Ab+88CLBcBrAwt8bp5S9W4 SHuA== 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=QzVzuQF02fR+c0YY6XKBCSbJXl7wL1vS1Ln1HL3oxGw=; b=NBf+O+qEcjidzxB6xpof0Wt0ubr6s48Ze9Vm21gbnPmUsFPifAifPPAht1t1unjEmT Vxj8qOiBAzZRTb0SZLTWCJIB3sTMPZ0JnVQDBIOV/gUbka20sLbWlVxDZywkkmAtS3Ld yfc4GLGN9QvawuIOdycW/Tz/R44VhN9WProjHPvrnR6wXm8ZfFNni3Wl0wq+S3ZhNXC3 kFkH93XnDx1jhdYjLmd5EgsTL6cKA5Ub4n/S+SZ2k8QYgt8bhMxkjl/T+JvsR9rCzMmE PcPJomX1PPpZ+AdLWWvfcgVdYfn1xWB6mV3KABlIdN2/o4s8viS+BJXmkiE+sLd3LeoH 41xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hvP2SxRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id du15si788887ejc.591.2020.06.03.00.05.42; Wed, 03 Jun 2020 00:06:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hvP2SxRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1725884AbgFCHDy (ORCPT + 99 others); Wed, 3 Jun 2020 03:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbgFCHDy (ORCPT ); Wed, 3 Jun 2020 03:03:54 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 106B4C05BD43 for ; Wed, 3 Jun 2020 00:03:54 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id q8so1121958qkm.12 for ; Wed, 03 Jun 2020 00:03:54 -0700 (PDT) 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=QzVzuQF02fR+c0YY6XKBCSbJXl7wL1vS1Ln1HL3oxGw=; b=hvP2SxRps2n5aDrbSR8AAQbnQC0t0zBApBAx25ugAFYja0lvhsnGmNibf86F7WvKGg J+O6rwI5Za3ngxG/RuczGwvXZ3CddVudqhO6xw7M7+73T2uBDtS7ELpJWP2naiVjX2H2 CUUDBo8X/Wj/yf47+Ks7aZYgLdUeFkRoGjh3cdwA5sXdAsmV5J6+cQcqppbz4qujvnsL E67tZfym83Fdq1LejN6YfBTcKeO6oORXbhs+wk7R7Gy2OqWZHE9MOPoAQS/lnrQFzyyG AjE9anYFv4LZXRYmgdLwgbr9woyk8RnVX049/PQ0knkZFQzkAmEDQi+vxY7QJ6WXUua9 yONQ== 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=QzVzuQF02fR+c0YY6XKBCSbJXl7wL1vS1Ln1HL3oxGw=; b=Z1cmeNPgh9jpzqqW5boo9IDgJkJgnnrxPhNLGtObrHQq7tahcNfFN25nKtTKwpFxN5 kqgV374dhH64jBnL7QotcYDk5YLpkhcisKsMwlorCChBxUdz+iCapOZMps5r46xwwroq ify5kBQ8SeF1kz6/GXzcuooc4QGx09AIl9iah+O+X6RoRMP4qumhe15rcxrfLYR655GU ChNoSpLLCzMTUrUgJH2Um1+U3i0ZKKnOmONebn3zt+rLm95x3wWTXV6p1GkEsp6Uan43 tlOfFWxmalAM1iL3AuHvFB8U+ktWjNUrCGnoOL/6C9J6Y9iMQsyxNAZ3WZZw925d8xap sckg== X-Gm-Message-State: AOAM5338XqA3EAN/wKlt1bgX5LQyRAa66Aezw8Y5epm5udT7AcatARYR S90uwIY4ofTJkzRVqM4juRkinlpqMGMMF/cPu0aunphQ X-Received: by 2002:a05:620a:15f4:: with SMTP id p20mr26692587qkm.283.1591167833314; Wed, 03 Jun 2020 00:03:53 -0700 (PDT) MIME-Version: 1.0 References: <20200423025827.48736-1-lizhe67@huawei.com> In-Reply-To: <20200423025827.48736-1-lizhe67@huawei.com> From: Richard Weinberger Date: Wed, 3 Jun 2020 09:03:42 +0200 Message-ID: Subject: Re: [PATCH v2] jffs2: fix jffs2 mounting failure To: Zhe Li Cc: David Woodhouse , linux-mtd@lists.infradead.org, LKML 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 Thu, Apr 23, 2020 at 4:58 AM Zhe Li wrote: > > Mounting jffs2 on nand flash will get message "failed: I/O error" > with the steps listed below. > 1.erase nand flash > 2.mount jffs2 on it (this mounting operation will be successful) > 3.do chown or chmod to the mount point directory > 4.umount jffs2 > 5.mount jffs2 on nand flash > After step 5, we will get message "mount ... failed: I/O error". The important step is missing. You need to unmount before jffs2 is done with erasing. > if (c->nr_erasing_blocks) { > - if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { > + if (!c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks) != c->nr_blocks || bad_blocks == c->nr_blocks) && > + !(has_root_inode(c) && !has_other_inode(c))) { I see the problem but I don't think it is wise to implement such a workaround. IIUC the real issue is that c->used_size being zero but c->nr_free_blocks+empty_blocks+bad_blocks does not sum up correctly in this situation. -- Thanks, //richard