From: Artem Bityutskiy <dedekind1@gmail.com>
To: "Matthew L. Creech" <mlcreech@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH v3 2/3] ubifs: add ubifs_fixup_free_space()
Date: Fri, 06 May 2011 18:02:48 +0300 [thread overview]
Message-ID: <1304694168.7222.68.camel@localhost> (raw)
In-Reply-To: <BANLkTinVHD1QYpqSTG0_WcLy-aA1ere34g@mail.gmail.com>
On Thu, 2011-05-05 at 16:33 -0400, Matthew L. Creech wrote:
> +/**
> + * fixup_leb_free_space - remap/unmap a LEB containing free space.
> + * @c: UBIFS file-system description object
> + * @lnum: LEB number
> + * @len: number of used bytes in LEB (starting at offset 0)
> + *
> + * This function reads the contents of the given LEB, then remaps it to a
> + * new PEB, so that any empty pages are actually erased on flash (rather than
> + * being just all-0xff real data). If the LEB is completely empty, it is
> + * simply unmappped.
> + */
> +static int fixup_leb_free_space(struct ubifs_info *c, int lnum, int len)
> +{
> + int err = 0, aligned_len;
> + void *sbuf = c->sbuf;
> +
> + ubifs_assert(len >= 0);
> + ubifs_assert(len % c->min_io_size == 0);
So if this is true.
> + ubifs_assert(len < c->leb_size);
> +
> + if (len == 0) {
> + /* LEB has no valid data, unmap it (no-op if it's unused) */
> + dbg_mnt("unmap empty LEB %d", lnum);
> + return ubi_leb_unmap(c->ubi, lnum);
> + }
> +
> + dbg_mnt("fixup partially-empty LEB %d (len %d)", lnum, len);
> +
> + /* Read the existing valid data for this LEB */
> + err = ubi_read(c->ubi, lnum, sbuf, 0, len);
> + if (err && err != -EBADMSG)
> + return err;
> +
> + /* Pad if necessary */
> + aligned_len = ALIGN(len, c->min_io_size);
> + if (aligned_len > len) {
This will be always false and the below code can be removed, right?
> + int pad_len = aligned_len - ALIGN(len, 8);
> +
> + if (pad_len > 0) {
> + void *buf = sbuf + aligned_len - pad_len;
> +
> + ubifs_pad(c, buf, pad_len);
> + }
> + }
> +
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
next prev parent reply other threads:[~2011-05-06 15:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 20:33 [PATCH v3 2/3] ubifs: add ubifs_fixup_free_space() Matthew L. Creech
2011-05-06 15:02 ` Artem Bityutskiy [this message]
2011-05-06 15:18 ` Matthew L. Creech
2011-05-06 15:17 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1304694168.7222.68.camel@localhost \
--to=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=mlcreech@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox