Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
Linus Torvalds
7d731019 62aa2b53

+1 -7
-6
fs/logfs/dev_mtd.c
··· 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; ··· 168 171 struct address_space *mapping = super->s_mapping_inode->i_mapping; 169 172 filler_t *filler = logfs_mtd_readpage; 170 173 struct mtd_info *mtd = super->s_mtd; 171 - 172 - if (!mtd_can_have_bb(mtd)) 173 - return NULL; 174 174 175 175 *ofs = mtd->size - mtd->erasesize; 176 176 while (mtd_block_isbad(mtd, *ofs)) {
+1 -1
include/linux/mtd/mtd.h
··· 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 */