LVM (growfiles) workdir fix
cover LVM (growfiles) workdir fix
The LVM tests are currently failing in OpenQA because the /test/growfiles directory doesn't exist and the growfiles test program fails to create its working subdirectories. It's a simple fix - just create the missing parent directories.
I've skipped porting the test program to the new API because it's 3000+ lines long and the fix is almost trivial. Here are OpenQA verification runs with the fix applied:
https://openqa.suse.de/tests/3563470
https://openqa.suse.de/tests/3563513
We should also move the mkpath() function to the LTP library later because it'll be useful for other tests.
Martin Doucha (1):
Create full path to workdir in fs/doio/growfiles.c
testcases/kernel/fs/doio/growfiles.c | 71 +++++++++++++++++++++------- 1 file changed, 53 insertions(+), 18 deletions(-)
Signature · 1 line
2.23.0
PATCH 1/1 Create full path to workdir in fs/doio/growfiles.c
LVM runfile sets the work directory for growfiles to /test/growfiles/[fsname]. If the /test/growfiles directory doesn't exist, the test will fail.
Fix the error by creating the full path.
--- testcases/kernel/fs/doio/growfiles.c | 71 +++++++++++++++++++++------- 1 file changed, 53 insertions(+), 18 deletions(-)
testcases/kernel/fs/doio/growfiles.c +53 -18
@@ -114,6 +114,7 @@ int check_write(int fd, int cf_inter, char *filename, int mode);int check_file (int fd,int cf_inter,char *filename,int no_file_check);int file_size (int fd);int lkfile (int fd,int operation,int lklevel); +int mkpath (const char *path,mode_t mode);#ifndef linuxint pre_alloc (int fd,long size);
@@ -380,7 +381,6 @@ int main(int argc, char **argv)long total_grow_value;/* used in pre-allocations */ #endif int backgrnd =1 ;/* return control to user */ -struct stat statbuf;int time_iterval =-1 ;time_t start_time =0 ;char reason[128 ];/* reason for loop termination */
@@ -481,23 +481,11 @@ int main(int argc, char **argv)#ifdef CRAY unsetenv ("TMPDIR" );/* force the use of auto_dir */ #endif -if (stat (auto_dir, &statbuf) ==-1 ) { -if (mkdir (auto_dir,0777 ) ==-1 ) { -if (errno !=EEXIST ) { -fprintf (stderr, -"%s%s: Unable to make dir %s\n" , - Progname, TagName, - auto_dir); -exit (1 ); - } - } - }else { -if (!(statbuf.st_mode &S_IFDIR )) { -fprintf (stderr, -"%s%s: %s already exists and is not a directory\n" , - Progname, TagName, auto_dir); -exit (1 ); - } +if (!mkpath (auto_dir,0777 )) { +fprintf (stderr, +"%s%s: Unable to make dir %s\n" , + Progname, TagName, auto_dir); +exit (1 ); }break ;
@@ -3019,6 +3007,53 @@ int lkfile(int fd, int operation, int lklevel)return 0 ; } +int mkpath (const char *path,mode_t mode) +{ +struct stat statbuf; +size_t pathlen =strlen (path), pos; +char *pathbuf =malloc (pathlen +1 ); + +strcpy (pathbuf, path); + +// Strip trailing slashes from path +for (pos = pathlen -1 ; pos >0 && pathbuf[pos] =='/' ; pos--, + pathlen--) { + pathbuf[pos] ='\0' ; + } + +// Find the longest existing section of the path +for (pos = pathlen; pos >0 ;) { +if (!stat (pathbuf, &statbuf)) { +if (!(statbuf.st_mode &S_IFDIR )) { +fprintf (stderr, +"%s%s: %s already exists and is not a directory\n" , + Progname, TagName, pathbuf); +free (pathbuf); +return 0 ; + } + +break ; + } + +while (pos >0 && pathbuf[--pos] !='/' ); + pathbuf[pos] ='\0' ; + } + +// Create missing directories +while (pos < pathlen) { + pathbuf[pos] ='/' ; +while (pathbuf[++pos]); + +if (mkdir (pathbuf, mode)) { +free (pathbuf); +return 0 ; + } + } + +free (pathbuf); +return 1 ; +} +#ifndef linux/*********************************************************************** *
Signature · 1 line
2.23.0
PATCH 1/1 Create full path to workdir in fs/doio/growfiles.c
Sorry, ignore my patch for growfiles.c, just creating the missing directories is not the right setup for the LVM tests. The correct fix is to rewrite testscripts/ltpfslvm.sh a bit and create an OpenQA module for it that'll produce a VM snapshot (similar to create_junkfile_ltp that's used for AIODIO tests).
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic