Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29764
b: refs/heads/master
c: 76d42bd
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Jun 25, 2006
1 parent 5ae9ac5 commit 268b844
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 78dbe706e22f54bce61571ad837238382e1ba5f9
refs/heads/master: 76d42bd96984832c4ea8bc8cbd74e496ac31409e
28 changes: 28 additions & 0 deletions trunk/mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,32 @@ grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
}
EXPORT_SYMBOL(grab_cache_page_nowait);

/*
* CD/DVDs are error prone. When a medium error occurs, the driver may fail
* a _large_ part of the i/o request. Imagine the worst scenario:
*
* ---R__________________________________________B__________
* ^ reading here ^ bad block(assume 4k)
*
* read(R) => miss => readahead(R...B) => media error => frustrating retries
* => failing the whole request => read(R) => read(R+1) =>
* readahead(R+1...B+1) => bang => read(R+2) => read(R+3) =>
* readahead(R+3...B+2) => bang => read(R+3) => read(R+4) =>
* readahead(R+4...B+3) => bang => read(R+4) => read(R+5) => ......
*
* It is going insane. Fix it by quickly scaling down the readahead size.
*/
static void shrink_readahead_size_eio(struct file *filp,
struct file_ra_state *ra)
{
if (!ra->ra_pages)
return;

ra->ra_pages /= 4;
printk(KERN_WARNING "Reducing readahead size to %luK\n",
ra->ra_pages << (PAGE_CACHE_SHIFT - 10));
}

/**
* do_generic_mapping_read - generic file read routine
* @mapping: address_space to be read
Expand Down Expand Up @@ -985,6 +1011,7 @@ void do_generic_mapping_read(struct address_space *mapping,
}
unlock_page(page);
error = -EIO;
shrink_readahead_size_eio(filp, &ra);
goto readpage_error;
}
unlock_page(page);
Expand Down Expand Up @@ -1522,6 +1549,7 @@ struct page *filemap_nopage(struct vm_area_struct *area,
* Things didn't work out. Return zero to tell the
* mm layer so, possibly freeing the page cache page first.
*/
shrink_readahead_size_eio(file, ra);
page_cache_release(page);
return NULL;
}
Expand Down

0 comments on commit 268b844

Please sign in to comment.