Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

brd: return -ENOSPC rather than -ENOMEM on page allocation failure

brd is effectively a thinly provisioned device. Thinly provisioned
devices return -ENOSPC when they can't write a new block. -ENOMEM is an
implementation detail that callers shouldn't know.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Cc: Dheeraj Reddy <dheeraj.reddy@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matthew Wilcox and committed by
Linus Torvalds
96f8d8e0 a72132c3

+3 -3
+3 -3
drivers/block/brd.c
··· 200 200 201 201 copy = min_t(size_t, n, PAGE_SIZE - offset); 202 202 if (!brd_insert_page(brd, sector)) 203 - return -ENOMEM; 203 + return -ENOSPC; 204 204 if (copy < n) { 205 205 sector += copy >> SECTOR_SHIFT; 206 206 if (!brd_insert_page(brd, sector)) 207 - return -ENOMEM; 207 + return -ENOSPC; 208 208 } 209 209 return 0; 210 210 } ··· 384 384 return -ERANGE; 385 385 page = brd_insert_page(brd, sector); 386 386 if (!page) 387 - return -ENOMEM; 387 + return -ENOSPC; 388 388 *kaddr = page_address(page); 389 389 *pfn = page_to_pfn(page); 390 390