@ -1930,7 +1930,8 @@ failure:
return TEST_FAILURE ;
}
static int validate_logs ( char * mount_dir , int log_fd , struct test_file * file )
static int validate_logs ( char * mount_dir , int log_fd , struct test_file * file ,
bool no_rlog )
{
uint8_t data [ INCFS_DATA_FILE_BLOCK_SIZE ] ;
struct incfs_pending_read_info prs [ 100 ] = { } ;
@ -1957,7 +1958,19 @@ static int validate_logs(char *mount_dir, int log_fd, struct test_file *file)
goto failure ;
}
read_count = wait_for_pending_reads ( log_fd , 0 , prs , prs_size ) ;
read_count =
wait_for_pending_reads ( log_fd , no_rlog ? 10 : 0 , prs , prs_size ) ;
if ( no_rlog ) {
if ( read_count = = 0 )
goto success ;
if ( read_count < 0 )
ksft_print_msg ( " Error reading logged reads %s. \n " ,
strerror ( - read_count ) ) ;
else
ksft_print_msg ( " Somehow read empty logs. \n " ) ;
goto failure ;
}
if ( read_count < 0 ) {
ksft_print_msg ( " Error reading logged reads %s. \n " ,
strerror ( - read_count ) ) ;
@ -2001,6 +2014,8 @@ static int validate_logs(char *mount_dir, int log_fd, struct test_file *file)
goto failure ;
}
}
success :
close ( fd ) ;
return TEST_SUCCESS ;
@ -2029,7 +2044,7 @@ static int read_log_test(char *mount_dir)
goto failure ;
log_fd = open_log_file ( mount_dir ) ;
if ( cmd _fd < 0 )
if ( log _fd < 0 )
ksft_print_msg ( " Can't open log file. \n " ) ;
/* Write data. */
@ -2048,7 +2063,7 @@ static int read_log_test(char *mount_dir)
for ( i = 0 ; i < file_num ; i + + ) {
struct test_file * file = & test . files [ i ] ;
if ( validate_logs ( mount_dir , log_fd , file ) )
if ( validate_logs ( mount_dir , log_fd , file , false ) )
goto failure ;
}
@ -2069,20 +2084,46 @@ static int read_log_test(char *mount_dir)
goto failure ;
log_fd = open_log_file ( mount_dir ) ;
if ( cmd _fd < 0 )
if ( log _fd < 0 )
ksft_print_msg ( " Can't open log file. \n " ) ;
/* Validate data again */
for ( i = 0 ; i < file_num ; i + + ) {
struct test_file * file = & test . files [ i ] ;
if ( validate_logs ( mount_dir , log_fd , file ) )
if ( validate_logs ( mount_dir , log_fd , file , false ) )
goto failure ;
}
/* Final unmount */
/*
* Unmount and mount again with no read log to make sure poll
* doesn ' t crash
*/
close ( cmd_fd ) ;
close ( log_fd ) ;
if ( umount ( mount_dir ) ! = 0 ) {
print_error ( " Can't unmout FS " ) ;
goto failure ;
}
if ( mount_fs_opt ( mount_dir , backing_dir , " readahead=0,rlog_pages=0 " ) ! =
0 )
goto failure ;
log_fd = open_log_file ( mount_dir ) ;
if ( log_fd < 0 )
ksft_print_msg ( " Can't open log file. \n " ) ;
/* Validate data again - note should fail this time */
for ( i = 0 ; i < file_num ; i + + ) {
struct test_file * file = & test . files [ i ] ;
if ( validate_logs ( mount_dir , log_fd , file , true ) )
goto failure ;
}
/* Final unmount */
close ( log_fd ) ;
free ( backing_dir ) ;
if ( umount ( mount_dir ) ! = 0 ) {
print_error ( " Can't unmout FS " ) ;