亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? readahead.c

?? 最新最穩定的Linux內存管理模塊源代碼
?? C
字號:
/* * mm/readahead.c - address_space-level file readahead. * * Copyright (C) 2002, Linus Torvalds * * 09Apr2002	Andrew Morton *		Initial version. */#include <linux/kernel.h>#include <linux/fs.h>#include <linux/mm.h>#include <linux/module.h>#include <linux/blkdev.h>#include <linux/backing-dev.h>#include <linux/task_io_accounting_ops.h>#include <linux/pagevec.h>#include <linux/pagemap.h>void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page){}EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = {	.ra_pages	= VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE,	.state		= 0,	.capabilities	= BDI_CAP_MAP_COPY,	.unplug_io_fn	= default_unplug_io_fn,};EXPORT_SYMBOL_GPL(default_backing_dev_info);/* * Initialise a struct file's readahead state.  Assumes that the caller has * memset *ra to zero. */voidfile_ra_state_init(struct file_ra_state *ra, struct address_space *mapping){	ra->ra_pages = mapping->backing_dev_info->ra_pages;	ra->prev_pos = -1;}EXPORT_SYMBOL_GPL(file_ra_state_init);#define list_to_page(head) (list_entry((head)->prev, struct page, lru))/** * read_cache_pages - populate an address space with some pages & start reads against them * @mapping: the address_space * @pages: The address of a list_head which contains the target pages.  These *   pages have their ->index populated and are otherwise uninitialised. * @filler: callback routine for filling a single page. * @data: private data for the callback routine. * * Hides the details of the LRU cache etc from the filesystems. */int read_cache_pages(struct address_space *mapping, struct list_head *pages,			int (*filler)(void *, struct page *), void *data){	struct page *page;	int ret = 0;	while (!list_empty(pages)) {		page = list_to_page(pages);		list_del(&page->lru);		if (add_to_page_cache_lru(page, mapping,					page->index, GFP_KERNEL)) {			page_cache_release(page);			continue;		}		page_cache_release(page);		ret = filler(data, page);		if (unlikely(ret)) {			put_pages_list(pages);			break;		}		task_io_account_read(PAGE_CACHE_SIZE);	}	return ret;}EXPORT_SYMBOL(read_cache_pages);static int read_pages(struct address_space *mapping, struct file *filp,		struct list_head *pages, unsigned nr_pages){	unsigned page_idx;	int ret;	if (mapping->a_ops->readpages) {		ret = mapping->a_ops->readpages(filp, mapping, pages, nr_pages);		/* Clean up the remaining pages */		put_pages_list(pages);		goto out;	}	for (page_idx = 0; page_idx < nr_pages; page_idx++) {		struct page *page = list_to_page(pages);		list_del(&page->lru);		if (!add_to_page_cache_lru(page, mapping,					page->index, GFP_KERNEL)) {			mapping->a_ops->readpage(filp, page);		}		page_cache_release(page);	}	ret = 0;out:	return ret;}/* * do_page_cache_readahead actually reads a chunk of disk.  It allocates all * the pages first, then submits them all for I/O. This avoids the very bad * behaviour which would occur if page allocations are causing VM writeback. * We really don't want to intermingle reads and writes like that. * * Returns the number of pages requested, or the maximum amount of I/O allowed. * * do_page_cache_readahead() returns -1 if it encountered request queue * congestion. */static int__do_page_cache_readahead(struct address_space *mapping, struct file *filp,			pgoff_t offset, unsigned long nr_to_read,			unsigned long lookahead_size){	struct inode *inode = mapping->host;	struct page *page;	unsigned long end_index;	/* The last page we want to read */	LIST_HEAD(page_pool);	int page_idx;	int ret = 0;	loff_t isize = i_size_read(inode);	if (isize == 0)		goto out;	end_index = ((isize - 1) >> PAGE_CACHE_SHIFT);	/*	 * Preallocate as many pages as we will need.	 */	for (page_idx = 0; page_idx < nr_to_read; page_idx++) {		pgoff_t page_offset = offset + page_idx;		if (page_offset > end_index)			break;		rcu_read_lock();		page = radix_tree_lookup(&mapping->page_tree, page_offset);		rcu_read_unlock();		if (page)			continue;		page = page_cache_alloc_cold(mapping);		if (!page)			break;		page->index = page_offset;		list_add(&page->lru, &page_pool);		if (page_idx == nr_to_read - lookahead_size)			SetPageReadahead(page);		ret++;	}	/*	 * Now start the IO.  We ignore I/O errors - if the page is not	 * uptodate then the caller will launch readpage again, and	 * will then handle the error.	 */	if (ret)		read_pages(mapping, filp, &page_pool, ret);	BUG_ON(!list_empty(&page_pool));out:	return ret;}/* * Chunk the readahead into 2 megabyte units, so that we don't pin too much * memory at once. */int force_page_cache_readahead(struct address_space *mapping, struct file *filp,		pgoff_t offset, unsigned long nr_to_read){	int ret = 0;	if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))		return -EINVAL;	while (nr_to_read) {		int err;		unsigned long this_chunk = (2 * 1024 * 1024) / PAGE_CACHE_SIZE;		if (this_chunk > nr_to_read)			this_chunk = nr_to_read;		err = __do_page_cache_readahead(mapping, filp,						offset, this_chunk, 0);		if (err < 0) {			ret = err;			break;		}		ret += err;		offset += this_chunk;		nr_to_read -= this_chunk;	}	return ret;}/* * This version skips the IO if the queue is read-congested, and will tell the * block layer to abandon the readahead if request allocation would block. * * force_page_cache_readahead() will ignore queue congestion and will block on * request queues. */int do_page_cache_readahead(struct address_space *mapping, struct file *filp,			pgoff_t offset, unsigned long nr_to_read){	if (bdi_read_congested(mapping->backing_dev_info))		return -1;	return __do_page_cache_readahead(mapping, filp, offset, nr_to_read, 0);}/* * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a * sensible upper limit. */unsigned long max_sane_readahead(unsigned long nr){	return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE_FILE)		+ node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);}static int __init readahead_init(void){	int err;	err = bdi_init(&default_backing_dev_info);	if (!err)		bdi_register(&default_backing_dev_info, NULL, "default");	return err;}subsys_initcall(readahead_init);/* * Submit IO for the read-ahead request in file_ra_state. */static unsigned long ra_submit(struct file_ra_state *ra,		       struct address_space *mapping, struct file *filp){	int actual;	actual = __do_page_cache_readahead(mapping, filp,					ra->start, ra->size, ra->async_size);	return actual;}/* * Set the initial window size, round to next power of 2 and square * for small size, x 4 for medium, and x 2 for large * for 128k (32 page) max ra * 1-8 page = 32k initial, > 8 page = 128k initial */static unsigned long get_init_ra_size(unsigned long size, unsigned long max){	unsigned long newsize = roundup_pow_of_two(size);	if (newsize <= max / 32)		newsize = newsize * 4;	else if (newsize <= max / 4)		newsize = newsize * 2;	else		newsize = max;	return newsize;}/* *  Get the previous window size, ramp it up, and *  return it as the new window size. */static unsigned long get_next_ra_size(struct file_ra_state *ra,						unsigned long max){	unsigned long cur = ra->size;	unsigned long newsize;	if (cur < max / 16)		newsize = 4 * cur;	else		newsize = 2 * cur;	return min(newsize, max);}/* * On-demand readahead design. * * The fields in struct file_ra_state represent the most-recently-executed * readahead attempt: * *                        |<----- async_size ---------| *     |------------------- size -------------------->| *     |==================#===========================| *     ^start             ^page marked with PG_readahead * * To overlap application thinking time and disk I/O time, we do * `readahead pipelining': Do not wait until the application consumed all * readahead pages and stalled on the missing page at readahead_index; * Instead, submit an asynchronous readahead I/O as soon as there are * only async_size pages left in the readahead window. Normally async_size * will be equal to size, for maximum pipelining. * * In interleaved sequential reads, concurrent streams on the same fd can * be invalidating each other's readahead state. So we flag the new readahead * page at (start+size-async_size) with PG_readahead, and use it as readahead * indicator. The flag won't be set on already cached pages, to avoid the * readahead-for-nothing fuss, saving pointless page cache lookups. * * prev_pos tracks the last visited byte in the _previous_ read request. * It should be maintained by the caller, and will be used for detecting * small random reads. Note that the readahead algorithm checks loosely * for sequential patterns. Hence interleaved reads might be served as * sequential ones. * * There is a special-case: if the first page which the application tries to * read happens to be the first page of the file, it is assumed that a linear * read is about to happen and the window is immediately set to the initial size * based on I/O request size and the max_readahead. * * The code ramps up the readahead size aggressively at first, but slow down as * it approaches max_readhead. *//* * A minimal readahead algorithm for trivial sequential/random reads. */static unsigned longondemand_readahead(struct address_space *mapping,		   struct file_ra_state *ra, struct file *filp,		   bool hit_readahead_marker, pgoff_t offset,		   unsigned long req_size){	int	max = ra->ra_pages;	/* max readahead pages */	pgoff_t prev_offset;	int	sequential;	/*	 * It's the expected callback offset, assume sequential access.	 * Ramp up sizes, and push forward the readahead window.	 */	if (offset && (offset == (ra->start + ra->size - ra->async_size) ||			offset == (ra->start + ra->size))) {		ra->start += ra->size;		ra->size = get_next_ra_size(ra, max);		ra->async_size = ra->size;		goto readit;	}	prev_offset = ra->prev_pos >> PAGE_CACHE_SHIFT;	sequential = offset - prev_offset <= 1UL || req_size > max;	/*	 * Standalone, small read.	 * Read as is, and do not pollute the readahead state.	 */	if (!hit_readahead_marker && !sequential) {		return __do_page_cache_readahead(mapping, filp,						offset, req_size, 0);	}	/*	 * Hit a marked page without valid readahead state.	 * E.g. interleaved reads.	 * Query the pagecache for async_size, which normally equals to	 * readahead size. Ramp it up and use it as the new readahead size.	 */	if (hit_readahead_marker) {		pgoff_t start;		rcu_read_lock();		start = radix_tree_next_hole(&mapping->page_tree, offset,max+1);		rcu_read_unlock();		if (!start || start - offset > max)			return 0;		ra->start = start;		ra->size = start - offset;	/* old async_size */		ra->size = get_next_ra_size(ra, max);		ra->async_size = ra->size;		goto readit;	}	/*	 * It may be one of	 * 	- first read on start of file	 * 	- sequential cache miss	 * 	- oversize random read	 * Start readahead for it.	 */	ra->start = offset;	ra->size = get_init_ra_size(req_size, max);	ra->async_size = ra->size > req_size ? ra->size - req_size : ra->size;readit:	return ra_submit(ra, mapping, filp);}/** * page_cache_sync_readahead - generic file readahead * @mapping: address_space which holds the pagecache and I/O vectors * @ra: file_ra_state which holds the readahead state * @filp: passed on to ->readpage() and ->readpages() * @offset: start offset into @mapping, in pagecache page-sized units * @req_size: hint: total size of the read which the caller is performing in *            pagecache pages * * page_cache_sync_readahead() should be called when a cache miss happened: * it will submit the read.  The readahead logic may decide to piggyback more * pages onto the read request if access patterns suggest it will improve * performance. */void page_cache_sync_readahead(struct address_space *mapping,			       struct file_ra_state *ra, struct file *filp,			       pgoff_t offset, unsigned long req_size){	/* no read-ahead */	if (!ra->ra_pages)		return;	/* do read-ahead */	ondemand_readahead(mapping, ra, filp, false, offset, req_size);}EXPORT_SYMBOL_GPL(page_cache_sync_readahead);/** * page_cache_async_readahead - file readahead for marked pages * @mapping: address_space which holds the pagecache and I/O vectors * @ra: file_ra_state which holds the readahead state * @filp: passed on to ->readpage() and ->readpages() * @page: the page at @offset which has the PG_readahead flag set * @offset: start offset into @mapping, in pagecache page-sized units * @req_size: hint: total size of the read which the caller is performing in *            pagecache pages * * page_cache_async_ondemand() should be called when a page is used which * has the PG_readahead flag; this is a marker to suggest that the application * has used up enough of the readahead window that we should start pulling in * more pages. */voidpage_cache_async_readahead(struct address_space *mapping,			   struct file_ra_state *ra, struct file *filp,			   struct page *page, pgoff_t offset,			   unsigned long req_size){	/* no read-ahead */	if (!ra->ra_pages)		return;	/*	 * Same bit is used for PG_readahead and PG_reclaim.	 */	if (PageWriteback(page))		return;	ClearPageReadahead(page);	/*	 * Defer asynchronous read-ahead on IO congestion.	 */	if (bdi_read_congested(mapping->backing_dev_info))		return;	/* do read-ahead */	ondemand_readahead(mapping, ra, filp, true, offset, req_size);}EXPORT_SYMBOL_GPL(page_cache_async_readahead);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品在线观| 制服丝袜在线91| 日本中文一区二区三区| 国产欧美一二三区| 欧美精品一二三| 99久久伊人久久99| 国产一区二区免费在线| 亚洲成人精品在线观看| 日本一区二区三区视频视频| 欧美高清视频不卡网| 色综合久久88色综合天天免费| 毛片一区二区三区| 亚洲国产日日夜夜| 亚洲欧洲av色图| 国产视频911| 日韩一区二区精品葵司在线| 欧美在线视频全部完| 成人动漫一区二区| 国产精品 欧美精品| 精品一区二区久久| 秋霞影院一区二区| 亚洲成人免费观看| 一区二区三区精品| 亚洲狠狠丁香婷婷综合久久久| 国产亚洲精品免费| 欧美精品一区二区精品网| 制服丝袜激情欧洲亚洲| 欧美午夜视频网站| 色老头久久综合| 91在线视频网址| av一本久道久久综合久久鬼色| 国产99久久久国产精品潘金| 国产精品资源网站| 国产一区激情在线| 国产一区二区伦理片| 国内精品国产成人国产三级粉色| 久久福利视频一区二区| 另类综合日韩欧美亚洲| 精彩视频一区二区| 精品亚洲欧美一区| 国产乱码字幕精品高清av | 91丨porny丨国产| 成人三级在线视频| www.欧美.com| 在线观看视频一区二区| 欧美在线免费观看亚洲| 欧美日韩国产欧美日美国产精品| 欧美无人高清视频在线观看| 欧美精品三级在线观看| 欧美成人精品二区三区99精品| 日韩视频一区在线观看| 久久综合久久久久88| 国产视频一区不卡| 亚洲精品国久久99热| 亚洲午夜av在线| 免费欧美日韩国产三级电影| 激情另类小说区图片区视频区| 国产剧情一区二区三区| 不卡欧美aaaaa| 在线精品视频小说1| 91精品国产综合久久小美女| 精品国产91久久久久久久妲己 | 亚洲日本欧美天堂| 亚洲成av人片在www色猫咪| 日本欧美大码aⅴ在线播放| 经典三级视频一区| 99r国产精品| 欧美乱熟臀69xxxxxx| 久久蜜桃一区二区| 亚洲视频免费看| 免费观看日韩电影| 成人一道本在线| 欧美影院午夜播放| 精品国产乱码久久久久久夜甘婷婷| 国产欧美日韩久久| 亚洲成a人v欧美综合天堂下载| 精品一区二区免费在线观看| 91在线一区二区三区| 日韩视频免费观看高清完整版| 欧美高清在线精品一区| 亚洲成人三级小说| 国产激情一区二区三区| 欧美日韩精品一区二区三区| 久久久精品综合| 亚洲v日本v欧美v久久精品| 国产精品99久久久久久有的能看| 在线观看av不卡| 久久理论电影网| 亚洲一区二区三区视频在线 | 日韩高清不卡一区二区| 国产成人av影院| 欧美久久久久久蜜桃| 中文字幕av一区二区三区免费看| 午夜影视日本亚洲欧洲精品| 国产成都精品91一区二区三| 777欧美精品| 亚洲精选视频免费看| 国产美女视频91| 3d成人h动漫网站入口| 日韩毛片精品高清免费| 韩国三级在线一区| 欧美一区二区网站| 亚洲最快最全在线视频| 成人天堂资源www在线| 日韩欧美一卡二卡| 亚洲一区二区三区中文字幕在线 | 欧美一级视频精品观看| 亚洲人成精品久久久久| 成人一级片在线观看| 精品粉嫩超白一线天av| 五月开心婷婷久久| 日本久久精品电影| 成人免费一区二区三区视频| 国产福利精品导航| 欧美videos大乳护士334| 午夜精品一区二区三区三上悠亚| jlzzjlzz亚洲女人18| 久久精品在线免费观看| 麻豆久久久久久久| 欧美一区二区三区小说| 亚洲高清在线精品| 欧美日韩一区二区在线视频| 亚洲精品一卡二卡| 99精品国产99久久久久久白柏| 国产精品视频在线看| 国产一区不卡视频| 国产校园另类小说区| 国产在线观看一区二区| 精品入口麻豆88视频| 美日韩黄色大片| 日韩一级黄色大片| 捆绑调教一区二区三区| 91精品国产色综合久久不卡电影 | 亚洲v中文字幕| 欧美日韩黄色一区二区| 亚洲国产成人porn| 4hu四虎永久在线影院成人| 午夜精品久久久| 91精品国产综合久久福利| 日韩av成人高清| 日韩免费视频一区| 国产一区在线看| 国产精品日日摸夜夜摸av| 成人高清视频免费观看| 亚洲日本成人在线观看| 欧美伊人久久大香线蕉综合69| 亚洲午夜精品在线| 91精品国产色综合久久| 蜜臀久久99精品久久久画质超高清| 日韩视频在线你懂得| 韩国成人在线视频| 中文字幕av一区二区三区高 | 日本女优在线视频一区二区| 欧美大片国产精品| 国产精品99久久久久久宅男| 中文字幕在线不卡一区 | 国产人妖乱国产精品人妖| 成人高清免费观看| 亚洲国产综合在线| 精品日韩av一区二区| 成人丝袜18视频在线观看| 亚洲免费av高清| 91精品欧美一区二区三区综合在 | 国产精品99久久久久久似苏梦涵| 国产精品伦一区| 欧美伊人久久大香线蕉综合69 | 成人精品免费网站| 一区二区高清视频在线观看| 欧美一区二区三区在| 国产98色在线|日韩| 亚洲综合色噜噜狠狠| 日韩欧美第一区| 99re免费视频精品全部| 男女视频一区二区| 国产精品免费丝袜| 3d动漫精品啪啪一区二区竹菊| 东方欧美亚洲色图在线| 亚洲国产精品嫩草影院| 国产欧美精品一区二区色综合| 欧美在线不卡一区| 国产一区二区不卡老阿姨| 一区二区高清在线| 国产日韩精品一区二区浪潮av| 在线观看一区二区精品视频| 国内久久婷婷综合| 午夜亚洲国产au精品一区二区| 久久―日本道色综合久久 | 国产欧美一区二区精品性色超碰 | 日韩电影一区二区三区四区| 国产欧美日产一区| 91精品国产综合久久蜜臀| 99re热这里只有精品免费视频| 久久精工是国产品牌吗| 伊人色综合久久天天人手人婷| 精品国产免费久久| 国产精品1区二区.| 日本午夜一区二区| 亚洲精品视频观看| 国产精品美女一区二区| 精品日韩99亚洲|