From patchwork Thu Mar 5 09:22:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 1249476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=u7dz1+GM; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Y4pn2kgMz9sPg for ; Thu, 5 Mar 2020 20:15:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+qzgy/jjXTIbAVDvhM9p3/OE4WoOocVBWiYmtWUAfww=; b=u7dz1+GMm4a256 Knfb1cRObj3u0hBVbuMZNruladoTr6tKJ18bbTBNWscMyz97yzhN6lbxkvN24jcs6StoADE3Ca/oE c2mSO0/GgIG99DsDy7RIBAsMtYjn9HM3OTJ6Tado9TzrQOSSrkReT/R/gO88WKBzCMw6V5ZslmfOk jLhGQg2MmOcCPHRDtN0itUtarMTptrNsaCAxforDESO8/yzu5IqCJQ5XGS9K/bunLO8zDyUQva4Ib ha2qnxBSp80U8XOSxuHD1vHmOTGprp+B4jWw2X6AEEUYtUDAn13qhmC6veKNhLlRIWQ76/xRQaPJm uxAScTVOVQFG4mfoy4GA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9mbG-0003Dx-1O; Thu, 05 Mar 2020 09:15:26 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9mb9-0002g1-Iv for linux-mtd@lists.infradead.org; Thu, 05 Mar 2020 09:15:21 +0000 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9E89F3C5D7818ADE1930; Thu, 5 Mar 2020 17:15:01 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 5 Mar 2020 17:14:51 +0800 From: Hou Tao To: , Richard Weinberger Subject: [PATCH v3 0/2] fix potential race between ubifs_tnc_locate() and GC Date: Thu, 5 Mar 2020 17:22:03 +0800 Message-ID: <20200305092205.127758-1-houtao1@huawei.com> X-Mailer: git-send-email 2.25.0.4.g0ad7144999 MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200305_011519_826253_6EBB00E5 X-CRM114-Status: UNSURE ( 7.51 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carson.Li1@unisoc.com, Adrian Hunter , houtao1@huawei.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hi, The patchset tries to fix the problem reported by 李傲傲 [1]. It happens because there are races between ubifs_tnc_locate() and GC when ubifs_tnc_locate() finds the target LEB is used as write-buffers or buds. And the patchset fixes it by only reading the node from write-buffer when the node is fully contained in write-buffer. Comments are welcome. Regards, Tao --- v3: -- add Link: tag -- add UBIFS_CHK_FORCE_DUMP_BAD_NODE flag for error message control [1]: https://www.spinics.net/lists/linux-mtd/msg10771.html Hou Tao (2): ubifs: factor out helper ubifs_check_node_buf() ubifs: read node from wbuf when it fully sits in wbuf fs/ubifs/io.c | 109 +++++++++++++++++++++++------------------------ fs/ubifs/tnc.c | 81 +++++++++++++++++++++++++++++++++-- fs/ubifs/ubifs.h | 5 +++ 3 files changed, 136 insertions(+), 59 deletions(-)