From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758921AbcIPKPA (ORCPT ); Fri, 16 Sep 2016 06:15:00 -0400 Received: from b.ns.miles-group.at ([95.130.255.144]:44723 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753446AbcIPKOx (ORCPT ); Fri, 16 Sep 2016 06:14:53 -0400 Subject: Re: [PATCH v2 11/17] UBI: simplify recover_peb() code To: Boris Brezillon , Artem Bityutskiy References: <1473087908-27862-1-git-send-email-boris.brezillon@free-electrons.com> <1473087908-27862-12-git-send-email-boris.brezillon@free-electrons.com> Cc: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org From: Richard Weinberger Message-ID: Date: Fri, 16 Sep 2016 12:14:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <1473087908-27862-12-git-send-email-boris.brezillon@free-electrons.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Boris, On 05.09.2016 17:05, Boris Brezillon wrote: > + * This function is called in case of a write failure and moves all good data > + * from the potentially bad physical eraseblock to a good physical eraseblock. > + * This function also writes the data which was not written due to the failure. > + * Returns 0 in case of success, and a negative error code in case of failure. > + * This function tries %UBI_IO_RETRIES before giving up. > + */ > +static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, > + const void *buf, int offset, int len) > +{ > + int err, idx = vol_id2idx(ubi, vol_id), tries; > + struct ubi_volume *vol = ubi->volumes[idx]; > + struct ubi_vid_hdr *vid_hdr; > + > + vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); > + if (!vid_hdr) > + return -ENOMEM; > + > + for (tries = 0; tries <= UBI_IO_RETRIES; tries++) { > + err = try_recover_peb(vol, pnum, lnum, buf, offset, len, > + vid_hdr); > + if (!err || err == -ENOSPC) > + break; Why do you handle ENOSPC as fatal error? Since the loop is bound by UBI_IO_RETRIES IMHO we can retry also upon ENOSPC. Thanks, //richard