Remove the check for an existing b_pages array as this function is always
called right after allocating a buffer, so this can't happen. Also
use kmem_zalloc to allocate the page array instead of doing a manual
memset gіven that the inline array is already pre-zeroed as part of the
freshly allocated buffer anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_buf.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 392b85d059bff5..9c64c374411081 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -281,19 +281,18 @@ _xfs_buf_get_pages(
struct xfs_buf *bp,
int page_count)
{
- /* Make sure that we have a page list */
- if (bp->b_pages == NULL) {
- 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, KM_NOFS);
- if (bp->b_pages == NULL)
- return -ENOMEM;
- }
- memset(bp->b_pages, 0, sizeof(struct page *) * page_count);
+ ASSERT(bp->b_pages == NULL);
+
+ bp->b_page_count = page_count;
+ if (page_count > XB_PAGES) {
+ bp->b_pages = kmem_zalloc(sizeof(struct page *) * page_count,
+ KM_NOFS);
+ if (!bp->b_pages)
+ return -ENOMEM;
+ } else {
+ bp->b_pages = bp->b_page_array;
}
+
return 0;
}
--
2.30.2