Commit 7d731019218e49a9811f6d0adec4b1cfcb752bed

Authored by Artem Bityutskiy
Committed by Linus Torvalds
1 parent 62aa2b537c

mtd: fix merge conflict resolution breakage

This patch fixes merge conflict resolution breakage introduced by merge
d3712b9dfcf4 ("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 <artem.bityutskiy@linux.intel.com>
Acked-by: Jörn Engel <joern@logfs.org>
Acked-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 1 additions and 7 deletions Side-by-side Diff

... ... @@ -152,9 +152,6 @@
152 152 filler_t *filler = logfs_mtd_readpage;
153 153 struct mtd_info *mtd = super->s_mtd;
154 154  
155   - if (!mtd_can_have_bb(mtd))
156   - return NULL;
157   -
158 155 *ofs = 0;
159 156 while (mtd_block_isbad(mtd, *ofs)) {
160 157 *ofs += mtd->erasesize;
... ... @@ -171,9 +168,6 @@
171 168 struct address_space *mapping = super->s_mapping_inode->i_mapping;
172 169 filler_t *filler = logfs_mtd_readpage;
173 170 struct mtd_info *mtd = super->s_mtd;
174   -
175   - if (!mtd_can_have_bb(mtd))
176   - return NULL;
177 171  
178 172 *ofs = mtd->size - mtd->erasesize;
179 173 while (mtd_block_isbad(mtd, *ofs)) {
include/linux/mtd/mtd.h
... ... @@ -489,7 +489,7 @@
489 489  
490 490 static inline int mtd_can_have_bb(const struct mtd_info *mtd)
491 491 {
492   - return 0;
  492 + return !!mtd->block_isbad;
493 493 }
494 494  
495 495 /* Kernel-side ioctl definitions */