Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2505877ybb; Mon, 30 Mar 2020 07:29:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvx8mzrQGhXpzoML4wSvWOe2PYL3OuKl55vCxN8zPlFzoL0le7MNbGGHvE9cPJlcLKFq0bj X-Received: by 2002:a9d:943:: with SMTP id 61mr9511802otp.3.1585578558928; Mon, 30 Mar 2020 07:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585578558; cv=none; d=google.com; s=arc-20160816; b=QL1OgO2AowSDBuYVRDQFQ0QHq0RbyY7GQrQMThgtyPtn0rALvp/E4VqRE5spdtXE09 Xmw8bXtIvbeuQe5R7HnL4KQKOKSaGYayHkDGpVLA7EtVAB3fI1uOW2PncfcmOKjZ6qSC 6I53CNK5B7jOQgSj681Da1PrqK6FdkF0xkoYg9+ameM5rHitq/5e9HDYtd9SyqPMEg2N iP1q41SQRyFkMlyuHOkj22osZa9S2oZglLNRbHMyPJ6SZEMUwUAoKC0Umn67kzdcMZ2b QY+HiKRb8nxoFRjvHs8QrMTaK4HxwEcIYKICv3nSe1v6UpFKsXB5YaG/SeBIKK2pRH0Z Pdkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=1mWXBX0q92J41qUn4srDWom+8qxcz2R2QQAnp3J4yIw=; b=RlDMlEl4ZFdfPRdTKx76YERfLoxGQCdpkI5OT3MdUKFDMiiyFp0ETrZjmB5Xq/KP/R bhACqvaw1H1e6vBD4u7ZuWVQXeOTj6CV4YWN4mXO0jekOkNTwE12wE9BzLsITyAkyC49 scCxsLW4fAYa79RgnZrM5/RFE3UQH5IupTiG4ubaTGbsDVYBmwerka1eNoIWp7/du8/G z4iFp6ZqCGyv+NHGUOQdMCOmA6sF/YwjoFRCvodsr4FzZoW3Wc2yR/q8f94L/uS22R6i 1fOxaC007JkwwjBdmFAjaz53fx39pdbK6ex5gciFDxuh+4/6VgfCAEMLSaIzD1RT/ZkD +Usw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si5892843ooj.61.2020.03.30.07.29.05; Mon, 30 Mar 2020 07:29:18 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbgC3O0J (ORCPT + 99 others); Mon, 30 Mar 2020 10:26:09 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:42568 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725268AbgC3O0J (ORCPT ); Mon, 30 Mar 2020 10:26:09 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id EF5D03B0274E1140F657; Mon, 30 Mar 2020 22:26:05 +0800 (CST) Received: from [127.0.0.1] (10.67.102.197) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 30 Mar 2020 22:25:56 +0800 Subject: Re: [PATCH v3] mtd:fix cache_state to avoid writing to bad blocks repeatedly To: Miquel Raynal CC: , , , , , , , , , References: <1585575925-84017-1-git-send-email-nixiaoming@huawei.com> <20200330155222.20359293@xps13> From: Xiaoming Ni Message-ID: <5bf71fe1-2dd1-f45a-5858-433f340b167e@huawei.com> Date: Mon, 30 Mar 2020 22:25:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200330155222.20359293@xps13> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.197] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/30 21:52, Miquel Raynal wrote: > Hi Xiaoming, > > Xiaoming Ni wrote on Mon, 30 Mar 2020 21:45:25 > +0800: > >> The function call process is as follows: >> mtd_blktrans_work() >> while (1) >> do_blktrans_request() >> mtdblock_writesect() >> do_cached_write() >> write_cached_data() /*if cache_state is STATE_DIRTY*/ >> erase_write() >> >> write_cached_data() returns failure without modifying cache_state >> and cache_offset. So when do_cached_write() is called again, >> write_cached_data() will be called again to perform erase_write() >> on the same cache_offset. >> >> But if this cache_offset points to a bad block, erase_write() will >> always return -EIO. Writing to this mtdblk is equivalent to losing >> the current data, and repeatedly writing to the bad block. >> >> Repeatedly writing a bad block has no real benefits, >> but brings some negative effects: >> 1 Lost subsequent data >> 2 Loss of flash device life >> 3 erase_write() bad blocks are very time-consuming. For example: >> the function do_erase_oneblock() in chips/cfi_cmdset_0020.c or >> chips/cfi_cmdset_0002.c may take more than 20 seconds to return >> >> Therefore, when erase_write() returns -EIO in write_cached_data(), >> clear cache_state to avoid writing to bad blocks repeatedly. >> >> Signed-off-by: Xiaoming Ni >> Reviewed-by: Miquel Raynal >> Cc: stable@vger.kernel.org > > Still missing: > * Fixes: tag > * Wrong title prefix > Fixes: 1da177e4c3f41524e88 "Linux-2.6.12-rc2" Is it described like this? Do I need to go to https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git to trace back the older commit records? Thanks Xiaoming Ni