Skip to content

Commit

Permalink
mtd: fix merge conflict resolution breakage
Browse files Browse the repository at this point in the history
This patch fixes merge conflict resolution breakage introduced by merge
d3712b9 ("Merge tag 'for-linus' of git://github.com/prasad-joshi/logfs_upstream").

The commit changed 'mtd_can_have_bb()' function and made it always
return zero, which is incorrect.  Instead, we need it to return whether
the underlying flash device can have bad eraseblocks or not.  UBI needs
this information because it affects how it handles the underlying flash.
E.g., if the underlying flash is NOR, it cannot have bad blocks and any
write or erase error is fatal, and all we can do is to switch to R/O
mode.  We do not need to reserve a pool of good eraseblocks for bad
eraseblocks handling, and so on.

This patch also removes 'mtd_can_have_bb()' invocations from Logfs to
ensure correct Logfs behavior.

I've tested that with this patch UBI works on top of NOR and NAND
flashes emulated by mtdram and nandsim correspondingly.

This patch is based on patch from Linus Torvalds.

Signed-off-by: Artem Bityutskiy <[email protected]>
Acked-by: Jörn Engel <[email protected]>
Acked-by: Prasad Joshi <[email protected]>
Acked-by: Brian Norris <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dedekind authored and torvalds committed Feb 1, 2012
1 parent 62aa2b5 commit 7d73101
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions fs/logfs/dev_mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ static struct page *logfs_mtd_find_first_sb(struct super_block *sb, u64 *ofs)
filler_t *filler = logfs_mtd_readpage;
struct mtd_info *mtd = super->s_mtd;

if (!mtd_can_have_bb(mtd))
return NULL;

*ofs = 0;
while (mtd_block_isbad(mtd, *ofs)) {
*ofs += mtd->erasesize;
Expand All @@ -172,9 +169,6 @@ static struct page *logfs_mtd_find_last_sb(struct super_block *sb, u64 *ofs)
filler_t *filler = logfs_mtd_readpage;
struct mtd_info *mtd = super->s_mtd;

if (!mtd_can_have_bb(mtd))
return NULL;

*ofs = mtd->size - mtd->erasesize;
while (mtd_block_isbad(mtd, *ofs)) {
*ofs -= mtd->erasesize;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static inline int mtd_has_oob(const struct mtd_info *mtd)

static inline int mtd_can_have_bb(const struct mtd_info *mtd)
{
return 0;
return !!mtd->block_isbad;
}

/* Kernel-side ioctl definitions */
Expand Down

0 comments on commit 7d73101

Please sign in to comment.