Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | From f210d7e19b721041f31b7f258a169f89dc850303 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jan Stancek <jstancek@redhat.com> |
| 3 | Date: Thu, 4 Jul 2019 16:45:23 +0200 |
| 4 | Subject: [PATCH] direct_io/diotest4: drop MAP_FIXED |
| 5 | |
| 6 | Hongzhi reports that this test is failing on mips64 with 5.1+: |
| 7 | diotest4 10 TBROK : diotest4.c:368: can't mmap file: Invalid argument |
| 8 | diotest4 11 TBROK : diotest4.c:368: Remaining cases broken |
| 9 | I could reproduce it on emulated 5kc-malta, running 5.2.0-rc7. |
| 10 | |
| 11 | Test is trying to map into area immediately following heap as MAP_SHARED, |
| 12 | but it used wrong alignment (fixed by 'lapi/mmap.h: include config.h'). |
| 13 | |
| 14 | Usage of MAP_FIXED seems unnecessary, so drop that too and let the kernel |
| 15 | pick an address. |
| 16 | |
| 17 | Reported-by: Hongzhi.Song <hongzhi.song@windriver.com> |
| 18 | Signed-off-by: Jan Stancek <jstancek@redhat.com> |
| 19 | Acked-by: Cyril Hrubis <chrubis@suse.cz> |
| 20 | |
| 21 | Upstream-Status: Backport |
| 22 | [https://github.com/linux-test-project/ltp/commit/f5444eeeabf252b8884b9465d277b6af853819e3] |
| 23 | |
| 24 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| 25 | --- |
| 26 | testcases/kernel/io/direct_io/diotest4.c | 8 ++------ |
| 27 | 1 file changed, 2 insertions(+), 6 deletions(-) |
| 28 | |
| 29 | diff --git a/testcases/kernel/io/direct_io/diotest4.c b/testcases/kernel/io/direct_io/diotest4.c |
| 30 | index e4616e4..bf200cd 100644 |
| 31 | --- a/testcases/kernel/io/direct_io/diotest4.c |
| 32 | +++ b/testcases/kernel/io/direct_io/diotest4.c |
| 33 | @@ -352,18 +352,14 @@ int main(int argc, char *argv[]) |
| 34 | total++; |
| 35 | |
| 36 | /* Test-10: read, write to a mmaped file */ |
| 37 | - shm_base = (char *)(((long)sbrk(0) + (shmsz - 1)) & ~(shmsz - 1)); |
| 38 | - if (shm_base == NULL) { |
| 39 | - tst_brkm(TBROK, cleanup, "sbrk failed: %s", strerror(errno)); |
| 40 | - } |
| 41 | offset = 4096; |
| 42 | count = bufsize; |
| 43 | if ((fd = open(filename, O_DIRECT | O_RDWR)) < 0) { |
| 44 | tst_brkm(TBROK, cleanup, "can't open %s: %s", |
| 45 | filename, strerror(errno)); |
| 46 | } |
| 47 | - shm_base = mmap(shm_base, 0x100000, PROT_READ | PROT_WRITE, |
| 48 | - MAP_SHARED | MAP_FIXED, fd, 0); |
| 49 | + shm_base = mmap(0, 0x100000, PROT_READ | PROT_WRITE, |
| 50 | + MAP_SHARED, fd, 0); |
| 51 | if (shm_base == (caddr_t) - 1) { |
| 52 | tst_brkm(TBROK, cleanup, "can't mmap file: %s", |
| 53 | strerror(errno)); |
| 54 | -- |
| 55 | 2.7.4 |
| 56 | |