/* Return value: Number of page frames actually allocated  */
static unsigned long preallocate_image_pages(unsigned long nr_pages, gfp_t mask)
/* Return value: Number of page frames actually allocated  */
static unsigned long preallocate_image_pages(unsigned long nr_pages, gfp_t mask)
{
	unsigned long nr_alloc = 0;
	while (nr_pages > 0) {
		struct page *page;
		page = alloc_image_page(mask);
		if (!page)
			break;
		memory_bm_set_bit(&copy_bm, page_to_pfn(page));
		if (PageHighMem(page))
			alloc_highmem++;
		else
			alloc_normal++;
		nr_pages--;
		nr_alloc++;
	}
	return nr_alloc;
}