src/locktest: 3 fixes for locktest
cover src/locktest: 3 fixes for locktest
From: Ira Weiny <[email protected]>
Found these while working on adding a leasetest
Ira Weiny (3):
src/locktest: Remove D_flag
src/locktest: Update test header comment
src/locktest: Remove unused buf allocation
src/locktest.c | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 src/locktest: Remove D_flag
From: Ira Weiny <[email protected]>
This flag is never set. Furthermore, there does not seem to be any need to set O_DIRECT for lock testing.
Remove the D_flag
Signed-off-by Ira Weiny <[email protected]>
--- src/locktest.c | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-)
src/locktest.c +7 -34
@@ -61,8 +61,7 @@ extern int h_errno;#define HANDLE int#define INVALID_HANDLE -1 -#define OPEN (N ,F ) (open(N, F|O_CREAT|O_BINARY| \ - (D_flag ? O_DIRECT : 0), 0644)) +#define OPEN (N ,F ) (open(N, F|O_CREAT|O_BINARY, 0644))#define SEEK (H ,O ) (lseek(H, O, SEEK_SET))#define READ (H ,B ,L ) (read(H, B, L))#define WRITE (H ,B ,L ) (write(H, B, L))
@@ -91,7 +90,6 @@ static SOCKET s_fd = -1; /* listen socket */static SOCKET c_fd =-1 ;/* IPC socket */ static HANDLE f_fd =INVALID_HANDLE ;/* shared file */ static char *buf;/* I/O buffer */ -static int D_flag =0 ;#define WRLOCK 0#define RDLOCK 1
@@ -579,12 +577,7 @@ initialize(HANDLE fd)int offset =0 ;int togo =FILE_SIZE ; -if (D_flag) { - ibuf = (char *)ALLOC_ALIGNED (INIT_BUFSZ ); - } -else { - ibuf = (char *)malloc (INIT_BUFSZ ); - } + ibuf = (char *)malloc (INIT_BUFSZ );memset (ibuf,':' ,INIT_BUFSZ );SEEK (fd,0L );
@@ -614,15 +607,6 @@ int do_open(int flag)/*NOTREACHED*/ } -#ifdef __sun -if (D_flag) { -directio (f_fd,DIRECTIO_ON ); - } -#elif defined(__APPLE__) -if (D_flag) { -fcntl (f_fd,F_NOCACHE ,1 ); - } -#endif return PASS ; }
@@ -826,18 +810,10 @@ main(int argc, char *argv[])* +10 is slop for the iteration number if do_write() ... never * needed unless maxio is very small */ -if (D_flag) { -if ((buf = (char *)ALLOC_ALIGNED (maxio +10 )) ==NULL ) { -perror ("aligned alloc buf" ); -exit (1 ); -/*NOTREACHED*/ - } - }else { -if ((buf = (char *)malloc (maxio +10 )) ==NULL ) { -perror ("malloc buf" ); -exit (1 ); -/*NOTREACHED*/ - } +if ((buf = (char *)malloc (maxio +10 )) ==NULL ) { +perror ("malloc buf" ); +exit (1 ); +/*NOTREACHED*/ }setbuf (stderr,NULL );
@@ -1159,10 +1135,7 @@ main(int argc, char *argv[])printf ("%d tests run, %d failed\n" , test_count, fail_count); }if (buf) { -if (D_flag) -FREE_ALIGNED (buf); -else -free (buf); +free (buf); }
Signature · 1 line
2.20.1
PATCH 2/3 src/locktest: Update test header comment
In reply to [email protected]From: Ira Weiny <[email protected]>
The offset is also used as flags for the OPEN commands.
Signed-off-by Ira Weiny <[email protected]>
--- src/locktest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/locktest.c +1 -1
@@ -175,7 +175,7 @@ char *descriptions[] = { };static int64_t tests[][6 ] = -/* test # Action offset length expected server/client */ +/* test # Action [offset|flags] length expected server/client */ {/* Various simple tests exercising the list */
Signature · 1 line
2.20.1
PATCH 3/3 src/locktest: Remove unused buf allocation
In reply to [email protected]From: Ira Weiny <[email protected]>
Signed-off-by Ira Weiny <[email protected]>
--- src/locktest.c | 16 ---------------- 1 file changed, 16 deletions(-)
src/locktest.c +0 -16
@@ -81,7 +81,6 @@ static char *prog;static char *filename =0 ;static int debug =0 ;static int server =1 ; -static int maxio =8192 ;static int port =0 ;static int testnumber =-1 ;static int saved_errno =0 ;
@@ -89,7 +88,6 @@ static int saved_errno = 0;static SOCKET s_fd =-1 ;/* listen socket */ static SOCKET c_fd =-1 ;/* IPC socket */ static HANDLE f_fd =INVALID_HANDLE ;/* shared file */ -static char *buf;/* I/O buffer */ #define WRLOCK 0#define RDLOCK 1
@@ -806,16 +804,6 @@ main(int argc, char *argv[])if (do_open (O_RDWR ) ==FAIL )exit (1 ); -/* -* +10 is slop for the iteration number if do_write() ... never -* needed unless maxio is very small -*/ -if ((buf = (char *)malloc (maxio +10 )) ==NULL ) { -perror ("malloc buf" ); -exit (1 ); -/*NOTREACHED*/ - } -setbuf (stderr,NULL );if (server) {
@@ -1134,10 +1122,6 @@ main(int argc, char *argv[])if (server)printf ("%d tests run, %d failed\n" , test_count, fail_count); } -if (buf) { -free (buf); - } -exit (fail_count);/*NOTREACHED*/
Signature · 1 line
2.20.1