Пример #1
0
/*
 * Attempt to release the private state associated with a page
 * - Called if either PG_private or PG_fscache is set on the page
 * - Caller holds page lock
 * - Return true (may release page) or false (may not)
 */
static int nfs_release_page(struct page *page, gfp_t gfp)
{
	struct address_space *mapping = page->mapping;

	dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page);

	/* Always try to initiate a 'commit' if relevant, but only
	 * wait for it if __GFP_WAIT is set.  Even then, only wait 1
	 * second and only if the 'bdi' is not congested.
	 * Waiting indefinitely can cause deadlocks when the NFS
	 * server is on this machine, when a new TCP connection is
	 * needed and in other rare cases.  There is no particular
	 * need to wait extensively here.  A short wait has the
	 * benefit that someone else can worry about the freezer.
	 */
	if (mapping) {
		struct nfs_server *nfss = NFS_SERVER(mapping->host);
		nfs_commit_inode(mapping->host, 0);
		if ((gfp & __GFP_WAIT) &&
		    !bdi_write_congested(&nfss->backing_dev_info)) {
			wait_on_page_bit_killable_timeout(page, PG_private,
							  HZ);
			if (PagePrivate(page))
				set_bdi_congested(&nfss->backing_dev_info,
						  BLK_RW_ASYNC);
		}
	}
	/* If PagePrivate() is set, then the page is not freeable */
	if (PagePrivate(page))
		return 0;
	return nfs_fscache_release_page(page, gfp);
}
Пример #2
0
static int nfs_set_page_writeback(struct page *page)
{
	int ret = test_set_page_writeback(page);

	if (!ret) {
		struct inode *inode = page->mapping->host;
		struct nfs_server *nfss = NFS_SERVER(inode);

		if (atomic_long_inc_return(&nfss->writeback) >
				NFS_CONGESTION_ON_THRESH) {
			set_bdi_congested(&nfss->backing_dev_info,
						BLK_RW_ASYNC);
		}
	}
	return ret;
}