Skip to content

Commit 96f8d8e

Browse files
Matthew Wilcoxtorvalds
authored andcommitted
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>
1 parent a72132c commit 96f8d8e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/block/brd.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ static int copy_to_brd_setup(struct brd_device *brd, sector_t sector, size_t n)
200200

201201
copy = min_t(size_t, n, PAGE_SIZE - offset);
202202
if (!brd_insert_page(brd, sector))
203-
return -ENOMEM;
203+
return -ENOSPC;
204204
if (copy < n) {
205205
sector += copy >> SECTOR_SHIFT;
206206
if (!brd_insert_page(brd, sector))
207-
return -ENOMEM;
207+
return -ENOSPC;
208208
}
209209
return 0;
210210
}
@@ -384,7 +384,7 @@ static int brd_direct_access(struct block_device *bdev, sector_t sector,
384384
return -ERANGE;
385385
page = brd_insert_page(brd, sector);
386386
if (!page)
387-
return -ENOMEM;
387+
return -ENOSPC;
388388
*kaddr = page_address(page);
389389
*pfn = page_to_pfn(page);
390390

0 commit comments

Comments
 (0)