Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf914a7d authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds
Browse files

readahead: split ondemand readahead interface into two functions



Split ondemand readahead interface into two functions.  I think this makes it
a little clearer for non-readahead experts (like Rusty).

Internally they both call ondemand_readahead(), but the page argument is
changed to an obvious boolean flag.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarFengguang Wu <wfg@mail.ustc.edu.cn>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe3cba17
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -139,10 +139,10 @@ static int ext3_readdir(struct file * filp,
			pgoff_t index = map_bh.b_blocknr >>
					(PAGE_CACHE_SHIFT - inode->i_blkbits);
			if (!ra_has_index(&filp->f_ra, index))
				page_cache_readahead_ondemand(
				page_cache_sync_readahead(
					sb->s_bdev->bd_inode->i_mapping,
					&filp->f_ra, filp,
					NULL, index, 1);
					index, 1);
			filp->f_ra.prev_index = index;
			bh = ext3_bread(NULL, inode, blk, 0, &err);
		}
+2 −2
Original line number Diff line number Diff line
@@ -138,10 +138,10 @@ static int ext4_readdir(struct file * filp,
			pgoff_t index = map_bh.b_blocknr >>
					(PAGE_CACHE_SHIFT - inode->i_blkbits);
			if (!ra_has_index(&filp->f_ra, index))
				page_cache_readahead_ondemand(
				page_cache_sync_readahead(
					sb->s_bdev->bd_inode->i_mapping,
					&filp->f_ra, filp,
					NULL, index, 1);
					index, 1);
			filp->f_ra.prev_index = index;
			bh = ext4_bread(NULL, inode, blk, 0, &err);
		}
+3 −3
Original line number Diff line number Diff line
@@ -295,8 +295,8 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
	 * readahead/allocate the rest and fill in the holes.
	 */
	if (spd.nr_pages < nr_pages)
		page_cache_readahead_ondemand(mapping, &in->f_ra, in,
				NULL, index, req_pages - spd.nr_pages);
		page_cache_sync_readahead(mapping, &in->f_ra, in,
				index, req_pages - spd.nr_pages);

	error = 0;
	while (spd.nr_pages < nr_pages) {
@@ -352,7 +352,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
		page = pages[page_nr];

		if (PageReadahead(page))
			page_cache_readahead_ondemand(mapping, &in->f_ra, in,
			page_cache_async_readahead(mapping, &in->f_ra, in,
					page, index, req_pages - page_nr);

		/*
+14 −6
Original line number Diff line number Diff line
@@ -1138,12 +1138,20 @@ int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
			pgoff_t offset, unsigned long nr_to_read);
int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
			pgoff_t offset, unsigned long nr_to_read);
unsigned long page_cache_readahead_ondemand(struct address_space *mapping,

void page_cache_sync_readahead(struct address_space *mapping,
			       struct file_ra_state *ra,
			       struct file *filp,
			  struct page *page,
			       pgoff_t offset,
			       unsigned long size);

void page_cache_async_readahead(struct address_space *mapping,
				struct file_ra_state *ra,
				struct file *filp,
				struct page *pg,
				pgoff_t offset,
				unsigned long size);

unsigned long max_sane_readahead(unsigned long nr);

/* Do stack extension */
+5 −5
Original line number Diff line number Diff line
@@ -894,15 +894,15 @@ void do_generic_mapping_read(struct address_space *mapping,
find_page:
		page = find_get_page(mapping, index);
		if (!page) {
			page_cache_readahead_ondemand(mapping,
					&ra, filp, page,
			page_cache_sync_readahead(mapping,
					&ra, filp,
					index, last_index - index);
			page = find_get_page(mapping, index);
			if (unlikely(page == NULL))
				goto no_cached_page;
		}
		if (PageReadahead(page)) {
			page_cache_readahead_ondemand(mapping,
			page_cache_async_readahead(mapping,
					&ra, filp, page,
					index, last_index - index);
		}
@@ -1348,14 +1348,14 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
	 */
	if (VM_SequentialReadHint(vma)) {
		if (!page) {
			page_cache_readahead_ondemand(mapping, ra, file, page,
			page_cache_sync_readahead(mapping, ra, file,
							   vmf->pgoff, 1);
			page = find_lock_page(mapping, vmf->pgoff);
			if (!page)
				goto no_cached_page;
		}
		if (PageReadahead(page)) {
			page_cache_readahead_ondemand(mapping, ra, file, page,
			page_cache_async_readahead(mapping, ra, file, page,
							   vmf->pgoff, 1);
		}
	}
Loading