Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3358798ybb; Tue, 31 Mar 2020 03:43:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvQyY0ev0pW6vdCrSRIG7CD2QLNLZpuGooBTAK2NevBXdOMf7JRoE8WfL076L6bbdDflGVu X-Received: by 2002:a9d:468b:: with SMTP id z11mr4093654ote.311.1585651407233; Tue, 31 Mar 2020 03:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585651407; cv=none; d=google.com; s=arc-20160816; b=xiVGQ0qDHUnYxRfayMH88YKoTmhccqlumkjzaknGzKCZ7FO0uqx2vUCEyoEJG4inis loMF+Of4rJi4FWUWp27PvlN5yTfnTzPHQQW8SXzt9QtPRFMzU9qhIaa6/m9BzA8QHejX Squ1ggija9Rbhr6BPF9akdNMYzlcN/zXxcbmfzF8vHAz5DPD91WiZj5ZSAnJ+tW5D2qF vTSCNU2xBtF7iLcWyF/OmlQYFEhWU02TNM4IP1IoDyqPbonSJ0V2qYqU3wb/K7Xclrc5 D+O/kqvMFMV8ghAWSG4Bs5sZs6v/Dx/3+lEg3mrimQmqV0flcGo0kb1NS2LHeFROTNP4 UYuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=rW+XoWb3L4wfhehG0F7Htn7CpK2SOcpJO3vvez9UkVs=; b=CEk26n7e1Ls3B3b5ida/+S1/UnhaCjo+T6XRk1YB+WjyiVeAmV9ltLR1uSSS2SjMX3 ZfmjLTDq/KQF4ZTmwD23ofWyPAqtyrEQauDjVCcvo1b9+iIy06AqVfN4uLdvMnQenfgA oXCaMs/gh8xCUtVs2Q1990Z+mxEtXtAaAxfHtHCykaOYw5BpwnLa0/S9JEd1rjSO0qZm 5odeL8WHQQt6rO3DULpkyyQxEXXm1CFQujtFTKmITVVpku9L3vgrjuuwHFyTZBJwPuvD 8B+zTzAhqbF+4tqGCNeNoZbGXx+BrWt46rAxPhCYJdhKIEJnaGEYKQzw5KaIEGM7FD+e fxYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hsPfFunQ; 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 m81si6945913oig.190.2020.03.31.03.43.15; Tue, 31 Mar 2020 03:43:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hsPfFunQ; 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 S1730390AbgCaKmL (ORCPT + 99 others); Tue, 31 Mar 2020 06:42:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:41422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730358AbgCaKmK (ORCPT ); Tue, 31 Mar 2020 06:42:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B671208E0; Tue, 31 Mar 2020 10:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585651329; bh=qXYGan3lC779UiSGNbkx/irqz1ZRbNY3U4gPt+oVvNs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hsPfFunQ02BmTHKKFtir9ut35F9P9YjKaPlHLZW9hFH9J/xnm+jUJq5Mgs8bZQLtM WUSwDyTNB+Re535zwl1y9zC6ChhQW98qrQhHuxvSQ0SQ3U/v7f0kqXtA4HBZRlHKXy sWIj8NjtWv48J2xvfQtItUUZjY0dfuLRM03uOYz0= Date: Tue, 31 Mar 2020 12:05:26 +0200 From: Greg KH To: Xiaoming Ni Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, wangle6@huawei.com, zhangweimin12@huawei.com, yebin10@huawei.com, houtao1@huawei.com Subject: Re: [PATCH v4] mtd: clear cache_state to avoid writing to bad blocks repeatedly Message-ID: <20200331100526.GC1204199@kroah.com> References: <1585618319-119741-1-git-send-email-nixiaoming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1585618319-119741-1-git-send-email-nixiaoming@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 09:31:59AM +0800, Xiaoming Ni wrote: > 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 > --- > drivers/mtd/mtdblock.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) $ ./scripts/get_maintainer.pl --file drivers/mtd/mtdblock.c Miquel Raynal (maintainer:MEMORY TECHNOLOGY DEVICES (MTD)) Richard Weinberger (maintainer:MEMORY TECHNOLOGY DEVICES (MTD)) Vignesh Raghavendra (maintainer:MEMORY TECHNOLOGY DEVICES (MTD)) linux-mtd@lists.infradead.org (open list:MEMORY TECHNOLOGY DEVICES (MTD)) linux-kernel@vger.kernel.org (open list) No where on there is my name/email, so why am I getting these? confused, greg k-h