* [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly
@ 2016-07-13 12:59 Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 2/3] ltp-aiodio/dio_sparse: add offset support Eryu Guan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eryu Guan @ 2016-07-13 12:59 UTC (permalink / raw)
To: ltp
From posix_memalign(3) the value of errno is indeterminate after a call
to posix_memalign(). So TERRNO doesn't work in this case.
dio_sparse 1 TBROK : dio_sparse.c:75: posix_memalign(): errno=SUCCESS(0): Success
Report posix_memalign() errors by calling strerror on the return value.
dio_sparse 1 TBROK : dio_sparse.c:74: posix_memalign(): EINVAL
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v3:
- take use of TEST() macro when calling posix_memalign()
v2:
- include "test.h" when needed to avoid compile error
testcases/kernel/io/ltp-aiodio/aiodio_append.c | 8 ++++++--
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c | 5 +++--
testcases/kernel/io/ltp-aiodio/dio_append.c | 9 +++++++--
testcases/kernel/io/ltp-aiodio/dio_sparse.c | 6 ++++--
testcases/kernel/io/ltp-aiodio/dio_truncate.c | 14 ++++++++++----
5 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_append.c b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
index 56e9c09..877b972 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_append.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
@@ -28,11 +28,14 @@
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <libaio.h>
+#include "test.h"
+
#define NUM_CHILDREN 8
char *check_zero(unsigned char *buf, int size)
@@ -115,8 +118,9 @@ void aiodio_append(char *filename)
io_queue_init(NUM_AIO, &myctx);
for (i = 0; i < NUM_AIO; i++) {
- if (posix_memalign(&bufptr, 4096, AIO_SIZE)) {
- perror("cannot malloc aligned memory");
+ TEST(posix_memalign(&bufptr, 4096, AIO_SIZE));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
return;
}
memset(bufptr, 0, AIO_SIZE);
diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
index 944e12b..49a0915 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
@@ -97,8 +97,9 @@ int aiodio_sparse(char *filename, int align, int writesize, int filesize,
for (i = 0; i < num_aio; i++) {
void *bufptr;
- if (posix_memalign(&bufptr, align, writesize)) {
- tst_resm(TBROK | TERRNO, "posix_memalign()");
+ TEST(posix_memalign(&bufptr, align, writesize));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot allocate aligned memory");
close(fd);
unlink(filename);
return 1;
diff --git a/testcases/kernel/io/ltp-aiodio/dio_append.c b/testcases/kernel/io/ltp-aiodio/dio_append.c
index 878c465..94235a2 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_append.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_append.c
@@ -35,11 +35,14 @@
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <memory.h>
#include <limits.h>
+
+#include "test.h"
#define NUM_CHILDREN 8
char *check_zero(unsigned char *buf, int size)
@@ -107,8 +110,10 @@ void dio_append(char *filename)
return;
}
- if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
- perror("cannot malloc aligned memory");
+ TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
+ close(fd);
return;
}
diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index 7ad5f80..df43d5e 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
@@ -68,9 +69,10 @@ int dio_sparse(char *filename, int align, int writesize, int filesize)
SAFE_FTRUNCATE(cleanup, fd, filesize);
- if (posix_memalign(&bufptr, align, writesize)) {
+ TEST(posix_memalign(&bufptr, align, writesize));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot allocate aligned memory");
close(fd);
- tst_resm(TBROK | TERRNO, "posix_memalign()");
return 1;
}
diff --git a/testcases/kernel/io/ltp-aiodio/dio_truncate.c b/testcases/kernel/io/ltp-aiodio/dio_truncate.c
index 7458a19..a2a201d 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_truncate.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_truncate.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
@@ -37,6 +38,8 @@
#include <string.h>
#include <limits.h>
+#include "test.h"
+
#define NUM_CHILDREN 8
char *check_zero(unsigned char *buf, int size)
@@ -68,8 +71,9 @@ int dio_read(char *filename)
int r;
void *bufptr;
- if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
- perror("cannot malloc aligned memory");
+ TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
return -1;
}
@@ -112,8 +116,10 @@ void dio_append(char *filename, int fill)
return;
}
- if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
- perror("cannot malloc aligned memory");
+ TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+ if (TEST_RETURN) {
+ tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
+ close(fd);
return;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v3 2/3] ltp-aiodio/dio_sparse: add offset support
2016-07-13 12:59 [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Eryu Guan
@ 2016-07-13 12:59 ` Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 3/3] ltp-aiodio: new dio_sparse tests specifying offset Eryu Guan
2016-07-15 11:22 ` [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Jan Stancek
2 siblings, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2016-07-13 12:59 UTC (permalink / raw)
To: ltp
Introduce a new option "-o" to specify the write offset.
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v3:
- no change in v3
v2:
- add a missing declare of "i", which causes compile error
testcases/kernel/io/ltp-aiodio/dio_sparse.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index df43d5e..41b9929 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -54,7 +54,7 @@ int TST_TOTAL = 1;
/*
* Write zeroes using O_DIRECT into sparse file.
*/
-int dio_sparse(char *filename, int align, int writesize, int filesize)
+int dio_sparse(char *filename, int align, int writesize, int filesize, int offset)
{
int fd;
void *bufptr;
@@ -77,7 +77,8 @@ int dio_sparse(char *filename, int align, int writesize, int filesize)
}
memset(bufptr, 0, writesize);
- for (i = 0; i < filesize;) {
+ lseek(fd, offset, SEEK_SET);
+ for (i = offset; i < filesize;) {
if ((w = write(fd, bufptr, writesize)) != writesize) {
tst_resm(TBROK | TERRNO, "write() returned %d", w);
close(fd);
@@ -96,7 +97,7 @@ int dio_sparse(char *filename, int align, int writesize, int filesize)
void usage(void)
{
fprintf(stderr, "usage: dio_sparse [-d] [-n children] [-s filesize]"
- " [-w writesize]\n");
+ " [-w writesize] [-o offset]]\n");
exit(1);
}
@@ -109,11 +110,12 @@ int main(int argc, char **argv)
long alignment = 512;
int writesize = 65536;
int filesize = 100 * 1024 * 1024;
+ int offset = 0;
int c;
int children_errors = 0;
int ret;
- while ((c = getopt(argc, argv, "dw:n:a:s:")) != -1) {
+ while ((c = getopt(argc, argv, "dw:n:a:s:o:")) != -1) {
char *endp;
switch (c) {
case 'd':
@@ -131,6 +133,10 @@ int main(int argc, char **argv)
filesize = strtol(optarg, &endp, 0);
filesize = scale_by_kmg(filesize, *endp);
break;
+ case 'o':
+ offset = strtol(optarg, &endp, 0);
+ offset = scale_by_kmg(offset, *endp);
+ break;
case 'n':
num_children = atoi(optarg);
if (num_children > NUM_CHILDREN) {
@@ -168,7 +174,7 @@ int main(int argc, char **argv)
}
tst_sig(FORK, DEF_HANDLER, cleanup);
- ret = dio_sparse(filename, alignment, writesize, filesize);
+ ret = dio_sparse(filename, alignment, writesize, filesize, offset);
tst_resm(TINFO, "Killing childrens(s)");
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v3 3/3] ltp-aiodio: new dio_sparse tests specifying offset
2016-07-13 12:59 [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 2/3] ltp-aiodio/dio_sparse: add offset support Eryu Guan
@ 2016-07-13 12:59 ` Eryu Guan
2016-07-15 11:22 ` [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Jan Stancek
2 siblings, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2016-07-13 12:59 UTC (permalink / raw)
To: ltp
The first 4 tests are to cover the second issue described in this patch
direct-io: fix direct write stale data exposure from concurrent buffered read
https://patchwork.ozlabs.org/patch/622065/
Other tests are added to test various offsets.
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v3:
- no change in v3
v2:
- no change in v2
runtest/ltp-aiodio.part2 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/runtest/ltp-aiodio.part2 b/runtest/ltp-aiodio.part2
index 28a84ac..00b9abf 100644
--- a/runtest/ltp-aiodio.part2
+++ b/runtest/ltp-aiodio.part2
@@ -78,3 +78,11 @@ ADSP076 dio_sparse -a 8k -w 8192k -s 8192k -n 64
ADSP077 dio_sparse -a 8k -w 518192k -s 18192k -n 128
ADSP078 dio_sparse -a 8k -w 518192k -s 518192k -n 512
ADSP079 dio_sparse -a 8k -w 518192k -s 518192k -n 1000
+ADSP080 dio_sparse -a 4k -w 4k -s 2k -o 2k -n 2
+ADSP081 dio_sparse -a 2k -w 2k -s 1k -o 1k -n 2
+ADSP082 dio_sparse -a 1k -w 1k -s 512 -o 512 -n 2
+ADSP083 dio_sparse -a 4k -w 4k -s 2k -o 3k -n 2
+ADSP084 dio_sparse -a 4k -w 4k -s 4k -o 4k -n 2
+ADSP085 dio_sparse -a 4k -w 4k -s 4k -o 6k -n 2
+ADSP086 dio_sparse -a 4k -w 4k -s 4k -o 8k -n 2
+ADSP087 dio_sparse -a 4k -w 16k -s 8k -o 8k -n 2
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly
2016-07-13 12:59 [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 2/3] ltp-aiodio/dio_sparse: add offset support Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 3/3] ltp-aiodio: new dio_sparse tests specifying offset Eryu Guan
@ 2016-07-15 11:22 ` Jan Stancek
2 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2016-07-15 11:22 UTC (permalink / raw)
To: ltp
----- Original Message -----
> From: "Eryu Guan" <eguan@redhat.com>
> To: ltp@lists.linux.it
> Sent: Wednesday, 13 July, 2016 2:59:00 PM
> Subject: [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly
>
> From posix_memalign(3) the value of errno is indeterminate after a call
> to posix_memalign(). So TERRNO doesn't work in this case.
> dio_sparse 1 TBROK : dio_sparse.c:75: posix_memalign():
> errno=SUCCESS(0): Success
>
> Report posix_memalign() errors by calling strerror on the return value.
> dio_sparse 1 TBROK : dio_sparse.c:74: posix_memalign(): EINVAL
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
Series pushed. I tested it on 4.7.0-rc7 (which contains your patch),
it completed OK. New cases are very fast, it added just couple ms on
my KVM guest.
Regards,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-15 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 12:59 [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 2/3] ltp-aiodio/dio_sparse: add offset support Eryu Guan
2016-07-13 12:59 ` [LTP] [PATCH v3 3/3] ltp-aiodio: new dio_sparse tests specifying offset Eryu Guan
2016-07-15 11:22 ` [LTP] [PATCH v3 1/3] ltp-aiodio: report posix_memalign errors properly Jan Stancek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox