Commit f2933e86 authored by Joern Engel's avatar Joern Engel Committed by Prasad Joshi

Logfs: Allow NULL block_isbad() methods

Not all mtd drivers define block_isbad().  Let's assume no bad blocks
instead of refusing to mount.
Signed-off-by: default avatarJoern Engel <joern@logfs.org>
parent bbe01387
...@@ -150,14 +150,13 @@ static struct page *mtd_find_first_sb(struct super_block *sb, u64 *ofs) ...@@ -150,14 +150,13 @@ static struct page *mtd_find_first_sb(struct super_block *sb, u64 *ofs)
filler_t *filler = mtd_readpage; filler_t *filler = mtd_readpage;
struct mtd_info *mtd = super->s_mtd; struct mtd_info *mtd = super->s_mtd;
if (!mtd->block_isbad)
return NULL;
*ofs = 0; *ofs = 0;
while (mtd->block_isbad(mtd, *ofs)) { if (mtd->block_isbad) {
*ofs += mtd->erasesize; while (mtd->block_isbad(mtd, *ofs)) {
if (*ofs >= mtd->size) *ofs += mtd->erasesize;
return NULL; if (*ofs >= mtd->size)
return NULL;
}
} }
BUG_ON(*ofs & ~PAGE_MASK); BUG_ON(*ofs & ~PAGE_MASK);
return read_cache_page(mapping, *ofs >> PAGE_SHIFT, filler, sb); return read_cache_page(mapping, *ofs >> PAGE_SHIFT, filler, sb);
...@@ -170,14 +169,13 @@ static struct page *mtd_find_last_sb(struct super_block *sb, u64 *ofs) ...@@ -170,14 +169,13 @@ static struct page *mtd_find_last_sb(struct super_block *sb, u64 *ofs)
filler_t *filler = mtd_readpage; filler_t *filler = mtd_readpage;
struct mtd_info *mtd = super->s_mtd; struct mtd_info *mtd = super->s_mtd;
if (!mtd->block_isbad)
return NULL;
*ofs = mtd->size - mtd->erasesize; *ofs = mtd->size - mtd->erasesize;
while (mtd->block_isbad(mtd, *ofs)) { if (mtd->block_isbad) {
*ofs -= mtd->erasesize; while (mtd->block_isbad(mtd, *ofs)) {
if (*ofs <= 0) *ofs -= mtd->erasesize;
return NULL; if (*ofs <= 0)
return NULL;
}
} }
*ofs = *ofs + mtd->erasesize - 0x1000; *ofs = *ofs + mtd->erasesize - 0x1000;
BUG_ON(*ofs & ~PAGE_MASK); BUG_ON(*ofs & ~PAGE_MASK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment