PAGE_CACHE_SIZE

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

 



Hello,

Could anyone please tell me what PAGE_CACHE_SIZE is for? I saw it here in /mm/filemap.c

Part of the code is as follows. Sorry for the messing up :P

TIA!

void do_generic_mapping_read(struct address_space *mapping,
			     struct file_ra_state *ra,
			     struct file * filp,
			     loff_t *ppos,
			     read_descriptor_t * desc,
			     read_actor_t actor)
{
	struct inode *inode = mapping->host;
	unsigned long index, offset;
	struct page *cached_page;
	int error;

	cached_page = NULL;
	index = *ppos >> PAGE_CACHE_SHIFT;
	offset = *ppos & ~PAGE_CACHE_MASK;

	if (unlikely(in_aio())) {
		unsigned long i, last, nr;
		/*
	 	 * Let the readahead logic know upfront about all
	 	 * the pages we'll need to satisfy this request while
		 * taking care to avoid repeat readaheads during retries.
		 * Required for reasonable IO ordering with multipage
		 * streaming AIO requests.
		 */
		if ((!is_retried_kiocb(io_wait_to_kiocb(current->io_wait)))
			|| (ra->prev_page + 1 == index)) {

			last = (*ppos + desc->count - 1) >> PAGE_CACHE_SHIFT;
			nr = max_sane_readahead(last - index + 1);

			for (i = 0; (i < nr) && ((i == 0)||(i < ra->ra_pages));
				i++) {
				page_cache_readahead(mapping, ra, filp,
				index + i);
				if (bdi_read_congested(
					mapping->backing_dev_info)) {
					break;
				}
			}
		}
	}

	for (;;) {
		struct page *page;
		unsigned long end_index, nr, ret;
		loff_t isize = i_size_read(inode);

		end_index = isize >> PAGE_CACHE_SHIFT;
			
		if (index > end_index)
			break;
		nr = PAGE_CACHE_SIZE;
---------------------------------------------------------------> why?

		if (index == end_index) {
			nr = isize & ~PAGE_CACHE_MASK;
			if (nr <= offset)
				break;
		}

		cond_resched();
		/*
		 * Take care to avoid disturbing the existing readahead
		 * window (concurrent reads may be active for the same fd,
		 * in the AIO case)
		 */
		if (!in_aio() || (ra->prev_page + 1 == index))
			page_cache_readahead(mapping, ra, filp, index);
		

		nr = nr - offset;
find_page:
		page = find_get_page(mapping, index);
		if (unlikely(page == NULL)) {
			handle_ra_miss(mapping, ra, index);
			goto no_cached_page;
		}
		if (!PageUptodate(page))
			goto page_not_up_to_date;
page_ok:
		/* If users can be writing to this page using arbitrary
		 * virtual addresses, take care about potential aliasing
		 * before reading the page on the kernel side.
		 */
		if (!prio_tree_empty(&mapping->i_mmap_shared) ||
			!list_empty(&mapping->i_mmap_nonlinear))
			flush_dcache_page(page);

		/*
		 * Mark the page accessed if we read the beginning.
		 */
		if (!offset)
			mark_page_accessed(page);

		/*
		 * Ok, we have the page, and it's up-to-date, so
		 * now we can copy it to user space...
		 *
		 * The actor routine returns how many bytes were actually used..
		 * NOTE! This may not be the same as how much of a user buffer
		 * we filled up (we may be padding etc), so we can only update
		 * "pos" here (the actor routine has to update the user buffer
		 * pointers and the remaining count).
		 */
		ret = actor(desc, page, offset, nr);
---------------------------------------> Read nr bytes to desc, I guess.

		offset += ret;
		index += offset >> PAGE_CACHE_SHIFT;
		offset &= ~PAGE_CACHE_MASK;

		page_cache_release(page);
		if (ret == nr && desc->count)
			continue;
		break;

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux