aiodio: Remove dirty freeblocks
PATCH 1/1 aiodio: Remove dirty freeblocks
At the beginning of the test it attempts to write some junk data to disk in order to increase the chance that the blocks allocated are not filled with zeroes.
It does this by memory mapping a new file and writing 0xaa to the mapped memory, then syncs and unlinks the file. This uses buffered I/O which should not be mixed with direct I/O.
Possibly we could use direct I/O to create the dirty blocks or ensure the buffers have been completely flushed and any writes finalised before continuing. However it seems unlikely that this is either effective or necessary. It seems much simpler and thorough to run the test many times, which we do.
--- .../kernel/io/ltp-aiodio/aiodio_sparse.c | 2 -- .../kernel/io/ltp-aiodio/common_sparse.h | 33 ------------------- testcases/kernel/io/ltp-aiodio/dio_sparse.c | 2 -- 3 files changed, 37 deletions(-)
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c +0 -2
@@ -258,8 +258,6 @@ int main(int argc, char **argv) }setup (); -tst_resm (TINFO ,"Dirtying free blocks" ); -dirty_freeblocks (filesize); fd =SAFE_OPEN (cleanup, filename,O_DIRECT |O_WRONLY |O_CREAT |O_EXCL ,0600 );
testcases/kernel/io/ltp-aiodio/common_sparse.h +0 -33
@@ -21,39 +21,6 @@#include "common_checkzero.h" -/* -* This code tries to create dirty free blocks on -* the HDD so there is a chance that blocks to be allocated -* for a file are filled with something else than zeroes. -* -* The usefulness of this is IMHO questionable. -*/ -static void dirty_freeblocks (int size) -{ -int fd; -void *p; -int pg; -char *filename ="dirty_freeblocks" ; - - pg =getpagesize (); - size = ((size + pg -1 ) / pg) * pg; - - fd =open (filename,O_CREAT |O_RDWR |O_EXCL ,0600 ); - -if (fd <0 ) -tst_brkm (TBROK |TERRNO , cleanup,"failed to open '%s'" , filename); - -SAFE_FTRUNCATE (cleanup, fd, size); - - p =SAFE_MMAP (cleanup,NULL , size,PROT_WRITE |PROT_READ ,MAP_SHARED |MAP_FILE , fd,0 ); - -memset (p,0xaa , size); -msync (p, size,MS_SYNC ); -munmap (p, size); -close (fd); -unlink (filename); -} -/* * Scale value by kilo, mega, or giga. */
testcases/kernel/io/ltp-aiodio/dio_sparse.c +0 -2
@@ -139,8 +139,6 @@ int main(int argc, char **argv) }setup (); -tst_resm (TINFO ,"Dirtying free blocks" ); -dirty_freeblocks (filesize); fd =SAFE_OPEN (cleanup, filename,O_DIRECT |O_WRONLY |O_CREAT |O_EXCL ,0600 );
Signature · 1 line
2.18.0
PATCH 1/1 aiodio: Remove dirty freeblocks
Hi!
Quoted 7 lines
At the beginning of the test it attempts to write some junk data to disk in order to increase the chance that the blocks allocated are not filled with zeroes.
It does this by memory mapping a new file and writing
0xaato the mapped memory, then syncs and unlinks the file. This uses buffered I/O which should not be mixed with direct I/O.
I do not follow here. Direct and buffered I/O should not be mixed for a given file, that can lead to strange artifacts. But in this case we do open a file, fill it with data, sync it, and then close it and we do that before the test even starts. No direct and buffered I/O is being mixed here or do I miss something?
Quoted 5 lines
Possibly we could use direct I/O to create the dirty blocks or ensure the buffers have been completely flushed and any writes finalised before continuing. However it seems unlikely that this is either effective or necessary. It seems much simpler and thorough to run the test many times, which we do.
I do agree that the value of such function is indeed questionable but I fail to see where is this actually hurting anything.
Signature · 2 lines
Cyril Hrubis [email protected]