public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* UBI : Atomic change LEB
@ 2007-09-13  8:02 Brijesh Singh
  2007-09-13 11:13 ` Artem Bityutskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Brijesh Singh @ 2007-09-13  8:02 UTC (permalink / raw)
  To: linux-mtd

I think there is a problem in atomic change LEB.
I was trying to think how ubi will behave when device is full.
Suppose device is full.And
LEBn maps to pebn
           i.e. Ln->pn
If we used automic_change_leb, wear-levelling has no free blocks as
all lebs are mapped to pebs.And no change in LEB is possible to any
LEB.
I think  we will need atleast one extra block at any instance of time
to avoid this situation.
This is similar to block movement situation where we need extra block
for block movement.

Code Snip:
    pnum = ubi_wl_get_peb(ubi, dtype);
>>Asking a new block before unmapping.
>>Wear-levelling has got no block.Logically we should get the block as
far as people are writing to Logical space provided by UBI

    if (pnum < 0) {
        ubi_free_vid_hdr(ubi, vid_hdr);
        leb_write_unlock(ubi, vol_id, lnum);
        return pnum;
    }

    dbg_eba("change LEB %d:%d, PEB %d, write VID hdr to PEB %d",
        vol_id, lnum, vol->eba_tbl[lnum], pnum);

    err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr);
    if (err) {
        ubi_warn("failed to write VID header to LEB %d:%d, PEB %d",
             vol_id, lnum, pnum);
        goto write_error;
    }

    err = ubi_io_write_data(ubi, buf, pnum, 0, len);
    if (err) {
        ubi_warn("failed to write %d bytes of data to PEB %d",
             len, pnum);
        goto write_error;
    }
>>>> Freeing the block after new is written to provide automicity..

    if (vol->eba_tbl[lnum] >= 0) {
        err = ubi_wl_put_peb(ubi, vol->eba_tbl[lnum], 1);
        if (err) {
            ubi_free_vid_hdr(ubi, vid_hdr);
            leb_write_unlock(ubi, vol_id, lnum);
            return err;
        }
    }

    vol->eba_tbl[lnum] = pnum;
    leb_write_unlock(ubi, vol_id, lnum);
    ubi_free_vid_hdr(ubi, vid_hdr);
    return 0;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-09-13 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-13  8:02 UBI : Atomic change LEB Brijesh Singh
2007-09-13 11:13 ` Artem Bityutskiy
2007-09-13 13:02   ` Brijesh Singh
2007-09-13 13:16     ` Artem Bityutskiy
2007-09-13 14:38     ` Jamie Lokier
2007-09-13 15:46       ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox