From patchwork Wed Jul 18 07:09:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/5] ubi: introduce ubi->bad_peb_limit Date: Tue, 17 Jul 2012 21:09:19 -0000 From: Artem Bityutskiy X-Patchwork-Id: 171604 Message-Id: <1342595359.31927.11.camel@brekeke> To: Shmulik Ladkani Cc: Russell King , Richard Genoud , Richard Weinberger , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Andrew Victor , linux-arm-kernel@lists.infradead.org On Wed, 2012-07-04 at 11:06 +0300, Shmulik Ladkani wrote: > Introduce 'ubi->bad_peb_limit', which specifies an upper limit of PEBs > ubi expects to go bad. > Currently, it is initialized to a fixed percentage of total PEBs in the > ubi device (configurable via CONFIG_MTD_UBI_BEB_LIMIT). > > The 'bad_peb_limit' is intended to be used for calculating the amount of > PEBs ubi needs to reserve for bad eraseblock handling. > > Signed-off-by: Shmulik Ladkani Created branch "beb" and pushed this patch there with minor amendments (see diff below). Let's use this branch in UBI tree for this work and merge it as soon as it is ready. diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index c33e25b..dee90b7 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -668,13 +668,12 @@ static int io_init(struct ubi_device *ubi) ubi->bad_allowed = 1; if (CONFIG_MTD_UBI_BEB_LIMIT > 0) { int percent = CONFIG_MTD_UBI_BEB_LIMIT; - int beb_limit; + int limit = mult_frac(ubi->peb_count, percent, 100); - beb_limit = mult_frac(ubi->peb_count, percent, 100); - /* round it up */ - if (mult_frac(beb_limit, 100, percent) < ubi->peb_count) - beb_limit++; - ubi->bad_peb_limit = beb_limit; + /* Round it up */ + if (mult_frac(limit, 100, percent) < ubi->peb_count) + limit += 1; + ubi->bad_peb_limit = limit; } }