/* Clip the earned share of dirty pages to that which is actually available. This avoids exceeding the total dirty_limit when the floating averages fluctuate too quickly.  */
static void clip_bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty, unsigned long *pbdi_dirty)
/* Clip the earned share of dirty pages to that which is actually available. This avoids exceeding the total dirty_limit when the floating averages fluctuate too quickly.  */
static void clip_bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty, unsigned long *pbdi_dirty)
{
	unsigned long avail_dirty;
	avail_dirty = global_page_state(NR_FILE_DIRTY) +
		 global_page_state(NR_WRITEBACK) +
		 global_page_state(NR_UNSTABLE_NFS) +
		 global_page_state(NR_WRITEBACK_TEMP);
	if (avail_dirty < dirty)
		avail_dirty = dirty - avail_dirty;
	else
		avail_dirty = 0;
	avail_dirty += bdi_stat(bdi, BDI_RECLAIMABLE) +
		bdi_stat(bdi, BDI_WRITEBACK);
	*pbdi_dirty = min(*pbdi_dirty, avail_dirty);
}