[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I/O error copying file to jffs, no obvous problem in jffs log?



Ok, how about this?
This seems to work too :)

Vipin


Index: inode-v23.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v23.c,v
retrieving revision 1.60
diff -u -r1.60 inode-v23.c
--- inode-v23.c 2001/02/10 21:19:53 1.60
+++ inode-v23.c 2001/02/21 21:01:20
@@ -718,7 +718,7 @@
 {
  void *buf;
  unsigned long read_len;
- int result = -EIO;
+ int result;
  struct inode *inode = (struct inode*)page->mapping->host;
  struct jffs_file *f = (struct jffs_file *)inode->u.generic_ip;
  struct jffs_control *c = (struct jffs_control *)inode->i_sb->u.generic_sbp;
@@ -737,32 +737,39 @@
  D3(printk (KERN_NOTICE "readpage(): down biglock\n"));
  down(&c->fmc->biglock);

+ read_len = 0;
+ result = 0;
+
  offset = page->index << PAGE_CACHE_SHIFT;
  if (offset < inode->i_size) {
   read_len = jffs_min(inode->i_size - offset, PAGE_SIZE);
   r = jffs_read_data(f, buf, offset, read_len);
-  if (r == read_len) {
-   if (read_len < PAGE_SIZE) {
-    memset(buf + read_len, 0,
-     PAGE_SIZE - read_len);
-   }
-   SetPageUptodate(page);
-   result = 0;
+  if (r != read_len) {
+   result = -EIO;
+   D(
+           printk("***jffs_readpage(): Read error! "
+           "Wanted to read %lu bytes but only "
+           "read %d bytes.\n", read_len, r);
+     );
   }
-  D(else {
-   printk("***jffs_readpage(): Read error! "
-    "Wanted to read %lu bytes but only "
-    "read %d bytes.\n", read_len, r);
-  });
+
  }
-
+
+ /* This handles the case of partial or no read in above */
+ if(read_len < PAGE_SIZE){
+         memset(buf + read_len, 0,
+         PAGE_SIZE - read_len);
+ }
+
  D3(printk (KERN_NOTICE "readpage(): up biglock\n"));
  up(&c->fmc->biglock);
-
+
  if (result) {
-  memset(buf, 0, PAGE_SIZE);
   SetPageError(page);
+ }else {
+         SetPageUptodate(page);
  }
+
  flush_dcache_page(page);

  put_page(page);





David Woodhouse wrote:

> vmalik@xxxxxxx.com said:
> > You mean like thus? Seems to work.
> > Vipin
>
> Cool. Now it works but I don't like it. There are still error cases where it
> doesn't zero the rest of the page.
>
> We could clean it up a little by doing the "if(read_len < PAGE_SIZE) memset"
> bit outside the if(offset < i_size) statement.
>
>  read_len = 0;
>  if (offset < inode->i_size) {
>         r = jffs_read_data();
>         if (r != read_len) {
>                 err = -EIO;
>         }
>  }
>  if (read_len < PAGE_CACHE_SIZE)
>         memset();
>
>  if (err)
>         SetPageError(page)
>  else
>         SetPageUptodate(page);
>
>  /* rest of cleanup */
>  return err;
>
>
> --
> dwmw2
>
> To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
> the body of a message to majordomo@xxxxxxx.com


To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com