Skip to content

Commit 0029da3

Browse files
dedekindFrank Haverkamp
authored andcommitted
JFFS2: add UBI support
This patch make JFFS2 able to work with UBI volumes via the emulated MTD devices which are directly mapped to these volumes. Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
1 parent 801c135 commit 0029da3

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎fs/jffs2/fs.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,13 @@ static int jffs2_flash_setup(struct jffs2_sb_info *c) {
672672
return ret;
673673
}
674674

675+
/* and an UBI volume */
676+
if (jffs2_ubivol(c)) {
677+
ret = jffs2_ubivol_setup(c);
678+
if (ret)
679+
return ret;
680+
}
681+
675682
return ret;
676683
}
677684

@@ -690,4 +697,9 @@ void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
690697
if (jffs2_nor_wbuf_flash(c)) {
691698
jffs2_nor_wbuf_flash_cleanup(c);
692699
}
700+
701+
/* and an UBI volume */
702+
if (jffs2_ubivol(c)) {
703+
jffs2_ubivol_cleanup(c);
704+
}
693705
}

‎fs/jffs2/os-linux.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
9898
#define jffs2_nor_wbuf_flash(c) (0)
9999
#define jffs2_nor_wbuf_flash_setup(c) (0)
100100
#define jffs2_nor_wbuf_flash_cleanup(c) do {} while (0)
101+
#define jffs2_ubivol(c) (0)
102+
#define jffs2_ubivol_setup(c) (0)
103+
#define jffs2_ubivol_cleanup(c) do {} while (0)
101104

102105
#else /* NAND and/or ECC'd NOR support present */
103106

@@ -133,6 +136,9 @@ void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
133136
#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
134137
int jffs2_dataflash_setup(struct jffs2_sb_info *c);
135138
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
139+
#define jffs2_ubivol(c) (c->mtd->type == MTD_UBIVOLUME)
140+
int jffs2_ubivol_setup(struct jffs2_sb_info *c);
141+
void jffs2_ubivol_cleanup(struct jffs2_sb_info *c);
136142

137143
#define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE))
138144
int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c);

‎fs/jffs2/wbuf.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,3 +1208,27 @@ int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
12081208
void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c) {
12091209
kfree(c->wbuf);
12101210
}
1211+
1212+
int jffs2_ubivol_setup(struct jffs2_sb_info *c) {
1213+
c->cleanmarker_size = 0;
1214+
1215+
if (c->mtd->writesize == 1)
1216+
/* We do not need write-buffer */
1217+
return 0;
1218+
1219+
init_rwsem(&c->wbuf_sem);
1220+
1221+
c->wbuf_pagesize = c->mtd->writesize;
1222+
c->wbuf_ofs = 0xFFFFFFFF;
1223+
c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
1224+
if (!c->wbuf)
1225+
return -ENOMEM;
1226+
1227+
printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size);
1228+
1229+
return 0;
1230+
}
1231+
1232+
void jffs2_ubivol_cleanup(struct jffs2_sb_info *c) {
1233+
kfree(c->wbuf);
1234+
}

0 commit comments

Comments
 (0)