13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/kernel.h>
17 #include <linux/time.h>
25 loff_t
pos,
unsigned len,
unsigned copied,
26 struct page *
pg,
void *fsdata);
28 loff_t
pos,
unsigned len,
unsigned flags,
29 struct page **pagep,
void **fsdata);
30 static int jffs2_readpage (
struct file *filp,
struct page *
pg);
78 .readpage = jffs2_readpage,
79 .write_begin = jffs2_write_begin,
80 .write_end = jffs2_write_end,
87 unsigned char *pg_buf;
90 jffs2_dbg(2,
"%s(): ino #%lu, page at offset 0x%lx\n",
101 ClearPageUptodate(pg);
117 int ret = jffs2_do_readpage_nolock(inode, pg);
123 static int jffs2_readpage (
struct file *filp,
struct page *pg)
135 loff_t
pos,
unsigned len,
unsigned flags,
136 struct page **pagep,
void **fsdata)
139 struct inode *inode = mapping->
host;
150 if (pageofs > inode->
i_size) {
171 jffs2_dbg(1,
"Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
172 (
unsigned int)inode->
i_size, pageofs);
174 memset(&ri, 0,
sizeof(ri));
209 jffs2_dbg(1,
"Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n",
225 if (!PageUptodate(pg)) {
226 ret = jffs2_do_readpage_nolock(inode, pg);
242 loff_t pos,
unsigned len,
unsigned copied,
243 struct page *pg,
void *fsdata)
248 struct inode *inode = mapping->
host;
253 unsigned end = start + copied;
254 unsigned aligned_start = start & ~3;
258 jffs2_dbg(1,
"%s(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n",
259 __func__, inode->
i_ino, pg->
index << PAGE_CACHE_SHIFT,
260 start, end, pg->
flags);
266 BUG_ON(!PageUptodate(pg));
279 jffs2_dbg(1,
"%s(): Allocation of raw inode failed\n",
299 (pg->
index << PAGE_CACHE_SHIFT) + aligned_start,
300 end - aligned_start, &writtenlen);
310 writtenlen -=
min(writtenlen, (start - aligned_start));
313 if (inode->
i_size < pos + writtenlen) {
314 inode->
i_size = pos + writtenlen;
323 if (start+writtenlen < end) {
327 jffs2_dbg(1,
"%s(): Not all bytes written. Marking page !uptodate\n",
330 ClearPageUptodate(pg);
334 __func__, writtenlen > 0 ? writtenlen : ret);
337 return writtenlen > 0 ? writtenlen :
ret;