aiocp.c: TCONF on O_DIRECT on tmpfs
PATCH 1/3 aiocp.c: TCONF on O_DIRECT on tmpfs
From: Petr Vorel <[email protected]>
O_DIRECT is not supported on tmpfs. This flag is added by -f option, thus cannot be filtered with .skip_filesystems.
--- testcases/kernel/io/ltp-aiodio/aiocp.c | 3 +++ 1 file changed, 3 insertions(+)
testcases/kernel/io/ltp-aiodio/aiocp.c +3 -0
@@ -240,6 +240,9 @@ static void setup(void)if (strncmp (str_oflag,"SYNC" ,4 ) ==0 ) { dstflags |=O_SYNC ; }else if (strncmp (str_oflag,"DIRECT" ,6 ) ==0 ) { +if (tst_fs_type ("." ) ==TST_TMPFS_MAGIC ) +tst_brk (TCONF ,"O_DIRECT not supported on tmpfs" ); + srcflags |=O_DIRECT ; dstflags |=O_DIRECT ; }
Signature · 5 lines
2.39.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/3 aiocp: Don't use O_DIRECT when writing random file
The initial write doesn't need to use O_DIRECT and could fail because the write sizes were not aligned. This drops O_DIRECT on the initial write.
Also it switches to using the static data from tst_rand_data. This is better for reproducibility.
--- testcases/kernel/io/ltp-aiodio/aiocp.c | 36 ++++++-------------------- 1 file changed, 8 insertions(+), 28 deletions(-)
testcases/kernel/io/ltp-aiodio/aiocp.c +8 -28
@@ -27,6 +27,8 @@#include <sys/stat.h> #include "common.h" +#include "tst_rand_data.h" +static const char *srcname ="srcfile.bin" ;static const char *dstname ="dstfile.bin" ;
@@ -55,35 +57,13 @@ static int iocb_free_count;static void fill_with_rand_data (int fd,long long size) { -const int bufsize =64 *1024 ; -const int lower ='a' ; -const int upper ='z' ; -char buf[bufsize]; -long long i =0 , j; -long long length, towrite; - -srand (time (NULL )); - -for (j =0 ; j < bufsize; j++) - buf[j] = (rand () % (upper - lower +1 )) + lower; +long long i = size; -if (size <= bufsize) { -SAFE_WRITE (0 , fd, buf, size); -return ; +while (i >0 ) { +SAFE_WRITE (1 , fd, tst_rand_data, +MIN ((long long )tst_rand_data_len, i)); + i -= tst_rand_data_len; } - -while (i < size) { -if (!tst_remaining_runtime ()) -tst_brk (TCONF ,"Out of runtime!" ); - - length =rand () % (bufsize /2 ) + bufsize /2 ; - towrite =MIN (length, size - i); - - i += towrite; - -SAFE_WRITE (1 , fd, buf, towrite); - } -SAFE_FSYNC (fd); }
@@ -266,7 +246,7 @@ static void setup(void)tst_res (TINFO ,"Fill %s with random data" , srcname); - srcfd =SAFE_OPEN (srcname, srcflags |O_RDWR |O_CREAT ,0666 ); + srcfd =SAFE_OPEN (srcname, (srcflags & ~O_DIRECT ) |O_RDWR |O_CREAT ,0666 );fill_with_rand_data (srcfd, filesize);SAFE_CLOSE (srcfd); }
Signature · 5 lines
2.39.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/3 aiocp: Don't try to get tmpfs blocksize
In reply to Richard Palethorpe via ltpTMPFS is backed by RAM and RAM is partitioned into "pages" not "blocks". I don't know if TMPFS has a block size defined somewhere and if this is accessible. Regardless it makes no sense to get it's backing block device properties.
--- testcases/kernel/io/ltp-aiodio/aiocp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
testcases/kernel/io/ltp-aiodio/aiocp.c +4 -1
@@ -228,7 +228,10 @@ static void setup(void) } } - alignment =tst_dev_block_size ("." ); +if (tst_fs_type ("." ) ==TST_TMPFS_MAGIC ) + alignment =getpagesize (); +else + alignment =tst_dev_block_size ("." );if (dstflags &O_DIRECT && aio_blksize % alignment)tst_brk (TCONF ,"Block size is not multiple of drive block size" );
Signature · 5 lines
2.39.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp