/* Allocate a page array capable of holding a specified number of pages, and point the page buf at it.  */
STATIC int _xfs_buf_get_pages(xfs_buf_t *bp, int page_count, xfs_buf_flags_t flags)
/* Allocate a page array capable of holding a specified number of pages, and point the page buf at it.  */
STATIC int _xfs_buf_get_pages(xfs_buf_t *bp, int page_count, xfs_buf_flags_t flags)
{
	if (bp->b_pages == NULL) {
		bp->b_offset = xfs_buf_poff(bp->b_file_offset);
		bp->b_page_count = page_count;
		if (page_count <= XB_PAGES) {
			bp->b_pages = bp->b_page_array;
		} else {
			bp->b_pages = kmem_alloc(sizeof(struct page *) *
					page_count, xb_to_km(flags));
			if (bp->b_pages == NULL)
				return -ENOMEM;
		}
		memset(bp->b_pages, 0, sizeof(struct page *) * page_count);
	}
	return 0;
}