Skip to content

Commit d6713fc

Browse files
committed
CHANGE handling arguments of devdax_alloc()
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 1a2ce63 commit d6713fc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ static umf_result_t devdax_alloc(void *provider, size_t size, size_t alignment,
243243
}
244244

245245
if (IS_NOT_ALIGNED(size, DEVDAX_PAGE_SIZE_2MB)) {
246-
size = ALIGN_UP(size, DEVDAX_PAGE_SIZE_2MB);
246+
LOG_ERR("wrong size: %zu (not a multiple of the page size (%zu))", size,
247+
DEVDAX_PAGE_SIZE_2MB);
248+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
247249
}
248250

249251
devdax_memory_provider_t *devdax_provider =

test/provider_devdax_memory.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ TEST_P(umfProviderTest, alloc_2page_align_page_size) {
199199
PURGE_NONE);
200200
}
201201

202-
TEST_P(umfProviderTest, alloc_page64_align_page_div_2) {
203-
test_alloc_free_success(provider.get(), page_plus_64, page_size / 2,
202+
TEST_P(umfProviderTest, alloc_page_align_page_div_2) {
203+
test_alloc_free_success(provider.get(), page_size, page_size / 2,
204204
PURGE_NONE);
205205
}
206206

@@ -214,6 +214,11 @@ TEST_P(umfProviderTest, purge_force) {
214214

215215
// negative tests using test_alloc_failure
216216

217+
TEST_P(umfProviderTest, alloc_page64_align_page_div_2) {
218+
test_alloc_failure(provider.get(), page_plus_64, page_size / 2,
219+
UMF_RESULT_ERROR_INVALID_ARGUMENT, 0);
220+
}
221+
217222
TEST_P(umfProviderTest, alloc_page64_align_page_minus_1_WRONG_ALIGNMENT_1) {
218223
test_alloc_failure(provider.get(), page_plus_64, page_size - 1,
219224
UMF_RESULT_ERROR_INVALID_ARGUMENT, 0);

0 commit comments

Comments
 (0)