11 #include <linux/sched.h>
12 #include <linux/slab.h>
14 #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1))
16 static int logfs_mtd_read(
struct super_block *
sb, loff_t ofs,
size_t len,
23 ret =
mtd_read(mtd, ofs, len, &retlen, buf);
35 static int loffs_mtd_write(
struct super_block *
sb, loff_t ofs,
size_t len,
41 loff_t page_start, page_end;
52 ret =
mtd_write(mtd, ofs, len, &retlen, buf);
53 if (ret || (retlen != len))
67 static void logfs_erase_callback(
struct erase_info *ei)
72 static int logfs_mtd_erase_mapping(
struct super_block *sb, loff_t ofs,
80 for (index = ofs >> PAGE_SHIFT; index < (ofs + len) >>
PAGE_SHIFT; index++) {
90 static int logfs_mtd_erase(
struct super_block *sb, loff_t ofs,
size_t len,
102 memset(&ei, 0,
sizeof(ei));
115 return logfs_mtd_erase_mapping(sb, ofs, len);
125 static int logfs_mtd_readpage(
void *_sb,
struct page *page)
138 ClearPageUptodate(page);
141 SetPageUptodate(page);
142 ClearPageError(page);
148 static struct page *logfs_mtd_find_first_sb(
struct super_block *sb,
u64 *ofs)
158 if (*ofs >= mtd->
size)
165 static struct page *logfs_mtd_find_last_sb(
struct super_block *sb,
u64 *ofs)
169 filler_t *filler = logfs_mtd_readpage;
191 for (i = 0; i < nr_pages; i++) {
205 static void logfs_mtd_writeseg(
struct super_block *sb,
u64 ofs,
size_t len)
210 if (super->
s_flags & LOGFS_SB_FLAG_RO)
226 __logfs_mtd_writeseg(sb, ofs, ofs >> PAGE_SHIFT, len >> PAGE_SHIFT);
234 static int logfs_mtd_can_write_buf(
struct super_block *sb,
u64 ofs)
243 err = logfs_mtd_read(sb, ofs, super->
s_writesize, buf);
254 .find_first_sb = logfs_mtd_find_first_sb,
255 .find_last_sb = logfs_mtd_find_last_sb,
256 .readpage = logfs_mtd_readpage,
257 .writeseg = logfs_mtd_writeseg,
258 .erase = logfs_mtd_erase,
259 .can_write_buf = logfs_mtd_can_write_buf,
260 .sync = logfs_mtd_sync,
261 .put_device = logfs_mtd_put_device,