Skip to contentSkip to conversation

xfs: improve error message when we can't allocate memory for xfs_buf

PATCH In review Darrick J. Wong 2 participants 2 messages Feb 21, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: improve error message when we can't allocate memory for xfs_buf

From: Darrick J. Wong <[email protected]>

If xfs_buf_get_map can't allocate enough memory for the buffer it's trying to create, it'll cough up an error about not being able to allocate "pagesn". That's not particularly helpful (and if we're really out of memory the message is very spammy) so change the message to tell us how many pages were actually requested, and ratelimit it too.

---
 fs/xfs/xfs_buf.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_buf.c +3 -2
index 0ceaa172545b..f8e4fee206ff 100644
@@ -727,8 +727,9 @@ xfs_buf_get_map(
 	if (!bp->b_addr) {
 		error = _xfs_buf_map_pages(bp, flags);
 		if (unlikely(error)) {
-			xfs_warn(target->bt_mount,
-				"%s: failed to map pagesn", __func__);
+			xfs_warn_ratelimited(target->bt_mount,
+				"%s: failed to map %u pages", __func__,
+				bp->b_page_count);
 			xfs_buf_relse(bp);
 			return error;
 		}
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If xfs_buf_get_map can't allocate enough memory for the buffer it's trying to create, it'll cough up an error about not being able to allocate "pagesn". That's not particularly helpful (and if we're really out of memory the message is very spammy) so change the message to tell us how many pages were actually requested, and ratelimit it too.

Looks good,