Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186206
b: refs/heads/master
c: 0141450
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Mar 6, 2010
1 parent 5a90809 commit a07e22c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 42e49608683ab25fbbbf9c40edb944601e543882
refs/heads/master: 0141450f66c3c12a3aaa869748caa64241885cdf
3 changes: 3 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ struct inodes_stat_t {
*/
#define FMODE_NOCMTIME ((__force fmode_t)2048)

/* Expect random access pattern */
#define FMODE_RANDOM ((__force fmode_t)4096)

/*
* The below are the various read and write types that we support. Some of
* them include behavioral modifiers that send information down to the
Expand Down
10 changes: 9 additions & 1 deletion trunk/mm/fadvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
switch (advice) {
case POSIX_FADV_NORMAL:
file->f_ra.ra_pages = bdi->ra_pages;
spin_lock(&file->f_lock);
file->f_mode &= ~FMODE_RANDOM;
spin_unlock(&file->f_lock);
break;
case POSIX_FADV_RANDOM:
file->f_ra.ra_pages = 0;
spin_lock(&file->f_lock);
file->f_mode |= FMODE_RANDOM;
spin_unlock(&file->f_lock);
break;
case POSIX_FADV_SEQUENTIAL:
file->f_ra.ra_pages = bdi->ra_pages * 2;
spin_lock(&file->f_lock);
file->f_mode &= ~FMODE_RANDOM;
spin_unlock(&file->f_lock);
break;
case POSIX_FADV_WILLNEED:
if (!mapping->a_ops->readpage) {
Expand Down
6 changes: 6 additions & 0 deletions trunk/mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ void page_cache_sync_readahead(struct address_space *mapping,
if (!ra->ra_pages)
return;

/* be dumb */
if (filp->f_mode & FMODE_RANDOM) {
force_page_cache_readahead(mapping, filp, offset, req_size);
return;
}

/* do read-ahead */
ondemand_readahead(mapping, ra, filp, false, offset, req_size);
}
Expand Down

0 comments on commit a07e22c

Please sign in to comment.