Commit 934d1076 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: simplify the b_page_count calculation

Ever since we stopped using the Linux page cache to back XFS buffers
there is no need to take the start sector into account for
calculating the number of pages in a buffer, as the data always
start from the beginning of the buffer.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
[dgc: modified to suit this series]
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 54cd3aa6
...@@ -348,14 +348,13 @@ xfs_buf_alloc_kmem( ...@@ -348,14 +348,13 @@ xfs_buf_alloc_kmem(
static int static int
xfs_buf_alloc_pages( xfs_buf_alloc_pages(
struct xfs_buf *bp, struct xfs_buf *bp,
uint page_count,
xfs_buf_flags_t flags) xfs_buf_flags_t flags)
{ {
gfp_t gfp_mask = xb_to_gfp(flags); gfp_t gfp_mask = xb_to_gfp(flags);
long filled = 0; long filled = 0;
/* Make sure that we have a page list */ /* Make sure that we have a page list */
bp->b_page_count = page_count; bp->b_page_count = DIV_ROUND_UP(BBTOB(bp->b_length), PAGE_SIZE);
if (bp->b_page_count <= XB_PAGES) { if (bp->b_page_count <= XB_PAGES) {
bp->b_pages = bp->b_page_array; bp->b_pages = bp->b_page_array;
} else { } else {
...@@ -409,7 +408,6 @@ xfs_buf_allocate_memory( ...@@ -409,7 +408,6 @@ xfs_buf_allocate_memory(
uint flags) uint flags)
{ {
size_t size; size_t size;
xfs_off_t start, end;
int error; int error;
/* /*
...@@ -424,11 +422,7 @@ xfs_buf_allocate_memory( ...@@ -424,11 +422,7 @@ xfs_buf_allocate_memory(
if (!error) if (!error)
return 0; return 0;
} }
return xfs_buf_alloc_pages(bp, flags);
start = BBTOB(bp->b_maps[0].bm_bn) >> PAGE_SHIFT;
end = (BBTOB(bp->b_maps[0].bm_bn + bp->b_length) + PAGE_SIZE - 1)
>> PAGE_SHIFT;
return xfs_buf_alloc_pages(bp, end - start, flags);
} }
/* /*
...@@ -922,7 +916,6 @@ xfs_buf_get_uncached( ...@@ -922,7 +916,6 @@ xfs_buf_get_uncached(
int flags, int flags,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
unsigned long page_count;
int error; int error;
struct xfs_buf *bp; struct xfs_buf *bp;
DEFINE_SINGLE_BUF_MAP(map, XFS_BUF_DADDR_NULL, numblks); DEFINE_SINGLE_BUF_MAP(map, XFS_BUF_DADDR_NULL, numblks);
...@@ -934,8 +927,7 @@ xfs_buf_get_uncached( ...@@ -934,8 +927,7 @@ xfs_buf_get_uncached(
if (error) if (error)
return error; return error;
page_count = PAGE_ALIGN(numblks << BBSHIFT) >> PAGE_SHIFT; error = xfs_buf_alloc_pages(bp, flags);
error = xfs_buf_alloc_pages(bp, page_count, flags);
if (error) if (error)
goto fail_free_buf; goto fail_free_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment