Skip to contentSkip to conversation

fsstress: delete tralling spaces

PATCH In review Andrew Vagin 2 participants 10 messages Sep 26, 2009 – Sep 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 fsstress: delete tralling spaces

---
 testcases/kernel/fs/fsstress/fsstress.c |   36 +++++++++++++++---------------
 1 files changed, 18 insertions(+), 18 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +18 -18
index 1f11f6e..b313b62 100644
@@ -295,7 +295,7 @@ int main(int argc, char **argv)
 	ptrdiff_t	srval;
 #endif
         int             nousage=0;
-#ifndef NO_XFS	
+#ifndef NO_XFS
 	xfs_error_injection_t	err_inj;
 #endif
 
@@ -308,7 +308,7 @@ int main(int argc, char **argv)
 		switch (c) {
 		case 'c':
 			/*Don't cleanup*/
-			cleanup=1; 
+			cleanup=1;
 			break;
 		case 'd':
 			dirname = optarg;
@@ -389,13 +389,13 @@ int main(int argc, char **argv)
 					ops[i].freq = 0;
 			}
 		}
-       
+
        	 	if (!dirname) {
        	     	/* no directory specified */
     	        	if (!nousage) usage();
            	 exit(1);
         	}
-       
+
 		(void)mkdir(dirname, 0777);
 		if (chdir(dirname) < 0) {
 			perror(dirname);
@@ -472,7 +472,7 @@ int main(int argc, char **argv)
 			while (wait(&stat) > 0)
 				continue;
 		}
-#ifndef NO_XFS	
+#ifndef NO_XFS
 		if (errtag != 0) {
 			err_inj.errtag = 0;
 			err_inj.fd = fd;
@@ -724,7 +724,7 @@ doproc(void)
 		p = &ops[freq_table[random() % freq_table_size]];
 		if ((unsigned long)p->func < 4096) abort();
 
-	
+
 		p->func(opno, random());
 		/*
 		 * test for forced shutdown by stat'ing the test
@@ -1225,7 +1225,7 @@ show_ops(int flag, char *lead_str)
         if (flag<0) {
                 /* print in list form */
                 int             x = WIDTH;
-               
+
 	        for (p = ops; p < ops_end; p++) {
 			if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
 				x=printf("%s%s", (p==ops)?"":"\n", lead_str);
@@ -1277,7 +1277,7 @@ symlink_path(const char *name1, pathname_t *name)
 	char		buf[MAXNAMELEN];
 	pathname_t	newname;
 	int		rval;
-       
+
         if (!strcmp(name1, name->path)) {
             printf("yikes! %s %s\n", name1, name->path);
             return 0;
@@ -1553,12 +1553,12 @@ bulkstat_f(int opno, long r)
 	t = malloc(nent * sizeof(*t));
 	fd = open(".", O_RDONLY);
 	total = 0;
-   
+
         bsr.lastip=&last;
         bsr.icount=nent;
         bsr.ubuffer=t;
         bsr.ocount=&count;
-           
+
 	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
 		total += count;
 	free(t);
@@ -1580,7 +1580,7 @@ bulkstat1_f(int opno, long r)
 	xfs_bstat_t	t;
 	int		v;
         xfs_fsop_bulkreq_t bsr;
-       
+
 
 	good = random() & 1;
 	if (good) {
@@ -1610,12 +1610,12 @@ bulkstat1_f(int opno, long r)
 		v = verbose;
 	}
 	fd = open(".", O_RDONLY);
-       
+
         bsr.lastip=&ino;
         bsr.icount=1;
         bsr.ubuffer=&t;
         bsr.ocount=NULL;
-       
+
 	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
 	if (v)
 		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
@@ -1699,9 +1699,9 @@ creat_f(int opno, long r)
 			if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0)
 				e1 = errno;
 			esz = a.fsx_estsize;
-		
+
 		}
-#endif	
+#endif
 		 		 add_to_flist(type, id, parid);
 		close(fd);
 	}
@@ -1723,7 +1723,7 @@ setdirect(int fd)
 		return 0;
 
 	flags = fcntl(fd, F_GETFL, 0);
-	if (flags < 0) 
+	if (flags < 0)
 		return 0;
 
 	if (fcntl(fd, F_SETFL, flags|O_DIRECT)  < 0) {
@@ -1734,7 +1734,7 @@ setdirect(int fd)
 		printf("cannot set O_DIRECT: %s\n",strerror(errno));
 		return 0;
 	}
-			      
+
 	return 1;
 }
 
@@ -1752,7 +1752,7 @@ dread_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
-      
+
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
 		if (v)
Signature · 13 lines
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw

PATCH 4/5 fsstress: fix memory leak in fread_d

In reply to Andrew Vagin

1. check result from operation open before set flags
2. close descriptor and free path if set flags failed

valgrind --leak-check=full --show-reachable=yes ./fsstress -d /home/shpagin/git-archive/ltp/testcases/kernel/fs/fsstress/tmp -l 10 -n 100

==23212== 1,134 bytes in 108 blocks are definitely lost in loss record 4 of 5

==23212==    at 0x4A0776F: realloc (vg_replace_malloc.c:429)
==23212==    by 0x401E6A: append_pathname (fsstress.c:528)
==23212==    by 0x4024E3: fent_to_name (fsstress.c:760)
==23212==    by 0x40284F: get_fname (fsstress.c:846)
==23212==    by 0x4041E0: dread_f (fsstress.c:1757)
==23212==    by 0x402368: doproc (fsstress.c:728)
==23212==    by 0x401CC1: main (fsstress.c:463)
---
 testcases/kernel/fs/fsstress/fsstress.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +11 -5
index 715c08d..cf7ba76 100644
@@ -1764,10 +1764,6 @@ dread_f(int opno, long r)
 	}
 	fd = open_path(&f, O_RDONLY);
 
-	if (!setdirect(fd)) {
-		return;
-	}
-
 	e = fd < 0 ? errno : 0;
 	check_cwd();
 	if (fd < 0) {
@@ -1777,6 +1773,13 @@ dread_f(int opno, long r)
 		free_pathname(&f);
 		return;
 	}
+
+	if (!setdirect(fd)) {
+		close(fd);
+		free_pathname(&f);
+		return;
+	}
+
 	if (fstat64(fd, &stb) < 0) {
 		if (v)
 			printf("%d/%d: dread - fstat64 %s failed %d\n",
@@ -1864,8 +1867,11 @@ dwrite_f(int opno, long r)
 		return;
 	}
 
-	if (!setdirect(fd))
+	if (!setdirect(fd)) {
+		close(fd);
+		free_pathname(&f);
 		return;
+	}
 	if (fstat64(fd, &stb) < 0) {
 		if (v)
 			printf("%d/%d: dwrite - fstat64 %s failed %d\n",
Signature · 13 lines
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

PATCH 2/5 fsstress: use tabs instead of spaces for indentation

In reply to Andrew Vagin
---
 testcases/kernel/fs/fsstress/fsstress.c |  144 +++++++++++++++---------------
 1 files changed, 72 insertions(+), 72 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +72 -72
index b313b62..5ada3d8 100644
@@ -294,7 +294,7 @@ int main(int argc, char **argv)
 #ifndef NO_XFS
 	ptrdiff_t	srval;
 #endif
-        int             nousage=0;
+	int		nousage=0;
 #ifndef NO_XFS
 	xfs_error_injection_t	err_inj;
 #endif
@@ -361,7 +361,7 @@ int main(int argc, char **argv)
 		case 'S':
 			show_ops(0, NULL);
 			printf("\n");
-                        nousage=1;
+			nousage=1;
 			break;
 		case '?':
 			fprintf(stderr, "%s - invalid parameters\n",
@@ -375,8 +375,8 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
-        while ( (loopcntr <= loops) || (loops == 0) )
-        {
+	while ( (loopcntr <= loops) || (loops == 0) )
+	{
 		if (no_xfs && errtag) {
 			fprintf(stderr, "error injection only works on XFS\n");
 			exit(1);
@@ -390,11 +390,11 @@ int main(int argc, char **argv)
 			}
 		}
 
-       	 	if (!dirname) {
-       	     	/* no directory specified */
-    	        	if (!nousage) usage();
-           	 exit(1);
-        	}
+		if (!dirname) {
+			/* no directory specified */
+			if (!nousage) usage();
+			exit(1);
+		}
 
 		(void)mkdir(dirname, 0777);
 		if (chdir(dirname) < 0) {
@@ -485,12 +485,12 @@ int main(int argc, char **argv)
 			close(fd);
 		}
 #endif
-	if (cleanup == 0)
-	{
-	  sprintf(cmd,"rm -rf %s/*",dirname);
-	  system(cmd);
-	}
-        loopcntr++;
+		if (cleanup == 0)
+		{
+			sprintf(cmd,"rm -rf %s/*",dirname);
+			system(cmd);
+		}
+		loopcntr++;
 	}
 	return 0;
 }
@@ -864,7 +864,7 @@ get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
 	fprintf(stderr, "fsstress: get_fname failure\n");
 	abort();
 #endif
-        return -1;
+	return -1;
 	/* NOTREACHED */
 }
 
@@ -1222,33 +1222,33 @@ show_ops(int flag, char *lead_str)
 {
 	opdesc_t	*p;
 
-        if (flag<0) {
-                /* print in list form */
-                int             x = WIDTH;
+	if (flag<0) {
+		/* print in list form */
+		int x = WIDTH;
 
-	        for (p = ops; p < ops_end; p++) {
+		for (p = ops; p < ops_end; p++) {
 			if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
 				x=printf("%s%s", (p==ops)?"":"\n", lead_str);
-                        x+=printf("%s ", p->name);
-                }
-                printf("\n");
-        } else {
-	        int		f;
-	        for (f = 0, p = ops; p < ops_end; p++)
-		        f += p->freq;
-
-	        if (f == 0)
-		        flag = 1;
-
-	        for (p = ops; p < ops_end; p++) {
-		        if (flag != 0 || p->freq > 0) {
-			        if (lead_str != NULL)
-				        printf("%s", lead_str);
-			        printf("%20s %d/%d %s\n",
-			        p->name, p->freq, f,
-			        (p->iswrite == 0) ? " " : "write op");
-		        }
-                }
+			x+=printf("%s ", p->name);
+		}
+		printf("\n");
+	} else {
+		int f;
+		for (f = 0, p = ops; p < ops_end; p++)
+			f += p->freq;
+
+		if (f == 0)
+			flag = 1;
+
+		for (p = ops; p < ops_end; p++) {
+			if (flag != 0 || p->freq > 0) {
+				if (lead_str != NULL)
+					printf("%s", lead_str);
+				printf("%20s %d/%d %s\n",
+				p->name, p->freq, f,
+				(p->iswrite == 0) ? " " : "write op");
+			}
+		}
 	}
 }
 
@@ -1278,10 +1278,10 @@ symlink_path(const char *name1, pathname_t *name)
 	pathname_t	newname;
 	int		rval;
 
-        if (!strcmp(name1, name->path)) {
-            printf("yikes! %s %s\n", name1, name->path);
-            return 0;
-        }
+	if (!strcmp(name1, name->path)) {
+		printf("yikes! %s %s\n", name1, name->path);
+		return 0;
+	}
 
 	rval = symlink(name1, name->path);
 	if (rval >= 0 || errno != ENAMETOOLONG)
@@ -1546,7 +1546,7 @@ bulkstat_f(int opno, long r)
 	int		nent;
 	xfs_bstat_t	*t;
 	__int64_t	total;
-        xfs_fsop_bulkreq_t bsr;
+	xfs_fsop_bulkreq_t bsr;
 
 	last = 0;
 	nent = (r % 999) + 2;
@@ -1554,10 +1554,10 @@ bulkstat_f(int opno, long r)
 	fd = open(".", O_RDONLY);
 	total = 0;
 
-        bsr.lastip=&last;
-        bsr.icount=nent;
-        bsr.ubuffer=t;
-        bsr.ocount=&count;
+	bsr.lastip=&last;
+	bsr.icount=nent;
+	bsr.ubuffer=t;
+	bsr.ocount=&count;
 
 	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
 		total += count;
@@ -1579,12 +1579,12 @@ bulkstat1_f(int opno, long r)
 	struct stat64	s;
 	xfs_bstat_t	t;
 	int		v;
-        xfs_fsop_bulkreq_t bsr;
+	xfs_fsop_bulkreq_t bsr;
 
 
 	good = random() & 1;
 	if (good) {
-               /* use an inode we know exists */
+		/* use an inode we know exists */
 		init_pathname(&f);
 		if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
 			append_pathname(&f, ".");
@@ -1592,34 +1592,34 @@ bulkstat1_f(int opno, long r)
 		check_cwd();
 		free_pathname(&f);
 	} else {
-                /*
-                 * pick a random inode
-                 *
-                 * note this can generate kernel warning messages
-                 * since bulkstat_one will read the disk block that
-                 * would contain a given inode even if that disk
-                 * block doesn't contain inodes.
-                 *
-                 * this is detected later, but not until after the
-                 * warning is displayed.
-                 *
-                 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
-                 *
-                 */
+		/*
+		 * pick a random inode
+		 *
+		 * note this can generate kernel warning messages
+		 * since bulkstat_one will read the disk block that
+		 * would contain a given inode even if that disk
+		 * block doesn't contain inodes.
+		 *
+		 * this is detected later, but not until after the
+		 * warning is displayed.
+		 *
+		 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
+		 *
+		 */
 		ino = (ino64_t)r;
 		v = verbose;
 	}
 	fd = open(".", O_RDONLY);
 
-        bsr.lastip=&ino;
-        bsr.icount=1;
-        bsr.ubuffer=&t;
-        bsr.ocount=NULL;
+	bsr.lastip=&ino;
+	bsr.icount=1;
+	bsr.ubuffer=&t;
+	bsr.ocount=NULL;
 
 	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
 	if (v)
 		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
-                    procid, opno, good?"real":"random", (int64_t)ino, e);
+			procid, opno, good?"real":"random", (int64_t)ino, e);
 	close(fd);
 }
 
@@ -1702,7 +1702,7 @@ creat_f(int opno, long r)
 
 		}
 #endif
-		 		 add_to_flist(type, id, parid);
+		add_to_flist(type, id, parid);
 		close(fd);
 	}
 	if (v)
@@ -1798,7 +1798,7 @@ dread_f(int opno, long r)
 		diob.d_mem = stb.st_blksize;
 	}
 #ifndef NO_XFS
-	   else 	if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
+	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
 			printf(
 			"%d/%d: dread - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
Signature · 13 lines
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw

PATCH 5/5 fsstress: renew flist if clean up test directory

In reply to Andrew Vagin

flist contain all files created by fsstress. If test clean up direcory on each interations that it should reinitilize flist.

---
 testcases/kernel/fs/fsstress/fsstress.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +6 -0
index cf7ba76..736bd53 100644
@@ -491,6 +491,12 @@ int main(int argc, char **argv)
 		{
 			sprintf(cmd,"rm -rf %s/*",dirname);
 			system(cmd);
+			for (i = 0; i < FT_nft; i++) {
+				flist[i].nslots = 0;
+				flist[i].nfiles = 0;
+				free(flist[i].fents);
+				flist[i].fents = NULL;
+			}
 		}
 		loopcntr++;
 	}
Signature · 13 lines
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw

PATCH 3/5 fsstress: fix memory leaks

In reply to Andrew Vagin

==11424== 156 bytes in 1 blocks are definitely lost in loss record 2 of 2

==11424==    at 0x4A0763E: malloc (vg_replace_malloc.c:207)
==11424==    by 0x402E4C: make_freq_table (fsstress.c:986)
==11424==    by 0x401C26: main (fsstress.c:410)

make_freq_table is executed on each iterations, but freq_table is not changed during test, so this patch moves it from the loop

---
 testcases/kernel/fs/fsstress/fsstress.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +15 -13
index 5ada3d8..715c08d 100644
@@ -375,21 +375,24 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
-	while ( (loopcntr <= loops) || (loops == 0) )
-	{
-		if (no_xfs && errtag) {
-			fprintf(stderr, "error injection only works on XFS\n");
-			exit(1);
-		}
 
-		if (no_xfs) {
-			int i;
-			for (i = 0; ops+i < ops_end; ++i) {
-				if (ops[i].isxfs)
-					ops[i].freq = 0;
-			}
+	if (no_xfs && errtag) {
+		fprintf(stderr, "error injection only works on XFS\n");
+		exit(1);
+	}
+
+	if (no_xfs) {
+		int i;
+		for (i = 0; ops+i < ops_end; ++i) {
+			if (ops[i].isxfs)
+				ops[i].freq = 0;
 		}
+	}
 
+	make_freq_table();
+
+	while ( (loopcntr <= loops) || (loops == 0) )
+	{
 		if (!dirname) {
 			/* no directory specified */
 			if (!nousage) usage();
@@ -407,7 +410,6 @@ int main(int argc, char **argv)
 			maxfsize = (off64_t)MAXFSIZE32;
 		else
 			maxfsize = (off64_t)MAXFSIZE;
-		make_freq_table();
 		dcache_init();
 		setlinebuf(stdout);
 		if (!seed) {
Signature · 13 lines
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#8 lore raw

Re: [LTP] [PATCH 2/5] fsstress: use tabs instead of spaces for indentation

In reply to Andrew Vagin
Quoted 1 line · Andrew Vagin

Thanks.

Regards--
Subrata

Quoted 258 lines
---
 testcases/kernel/fs/fsstress/fsstress.c |  144 +++++++++++++++---------------
 1 files changed, 72 insertions(+), 72 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +71 -71
index b313b62..5ada3d8 100644
@@ -294,7 +294,7 @@ int main(int argc, char **argv)
 #ifndef NO_XFS
 	ptrdiff_t	srval;
 #endif
-        int             nousage=0;
+	int		nousage=0;
 #ifndef NO_XFS
 	xfs_error_injection_t	err_inj;
 #endif
@@ -361,7 +361,7 @@ int main(int argc, char **argv)
 		case 'S':
 			show_ops(0, NULL);
 			printf("\n");
-                        nousage=1;
+			nousage=1;
 			break;
 		case '?':
 			fprintf(stderr, "%s - invalid parameters\n",
@@ -375,8 +375,8 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
-        while ( (loopcntr <= loops) || (loops == 0) )
-        {
+	while ( (loopcntr <= loops) || (loops == 0) )
+	{
 		if (no_xfs && errtag) {
 			fprintf(stderr, "error injection only works on XFS\n");
 			exit(1);
@@ -390,11 +390,11 @@ int main(int argc, char **argv)
 			}
 		}
 
-       	 	if (!dirname) {
-       	     	/* no directory specified */
-    	        	if (!nousage) usage();
-           	 exit(1);
-        	}
+		if (!dirname) {
+			/* no directory specified */
+			if (!nousage) usage();
+			exit(1);
+		}
 
 		(void)mkdir(dirname, 0777);
 		if (chdir(dirname) < 0) {
@@ -485,12 +485,12 @@ int main(int argc, char **argv)
 			close(fd);
 		}
 #endif
-	if (cleanup == 0)
-	{
-	  sprintf(cmd,"rm -rf %s/*",dirname);
-	  system(cmd);
-	}
-        loopcntr++;
+		if (cleanup == 0)
+		{
+			sprintf(cmd,"rm -rf %s/*",dirname);
+			system(cmd);
+		}
+		loopcntr++;
 	}
 	return 0;
 }
@@ -864,7 +864,7 @@ get_fname(int which, long r, pathname_t *name, flist_t **flpp, fent_t **fepp,
 	fprintf(stderr, "fsstress: get_fname failure\n");
 	abort();
 #endif
-        return -1;
+	return -1;
 	/* NOTREACHED */
 }
 
@@ -1222,33 +1222,33 @@ show_ops(int flag, char *lead_str)
 {
 	opdesc_t	*p;
 
-        if (flag<0) {
-                /* print in list form */
-                int             x = WIDTH;
+	if (flag<0) {
+		/* print in list form */
+		int x = WIDTH;
 
-	        for (p = ops; p < ops_end; p++) {
+		for (p = ops; p < ops_end; p++) {
 			if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
 				x=printf("%s%s", (p==ops)?"":"\n", lead_str);
-                        x+=printf("%s ", p->name);
-                }
-                printf("\n");
-        } else {
-	        int		f;
-	        for (f = 0, p = ops; p < ops_end; p++)
-		        f += p->freq;
-
-	        if (f == 0)
-		        flag = 1;
-
-	        for (p = ops; p < ops_end; p++) {
-		        if (flag != 0 || p->freq > 0) {
-			        if (lead_str != NULL)
-				        printf("%s", lead_str);
-			        printf("%20s %d/%d %s\n",
-			        p->name, p->freq, f,
-			        (p->iswrite == 0) ? " " : "write op");
-		        }
-                }
+			x+=printf("%s ", p->name);
+		}
+		printf("\n");
+	} else {
+		int f;
+		for (f = 0, p = ops; p < ops_end; p++)
+			f += p->freq;
+
+		if (f == 0)
+			flag = 1;
+
+		for (p = ops; p < ops_end; p++) {
+			if (flag != 0 || p->freq > 0) {
+				if (lead_str != NULL)
+					printf("%s", lead_str);
+				printf("%20s %d/%d %s\n",
+				p->name, p->freq, f,
+				(p->iswrite == 0) ? " " : "write op");
+			}
+		}
 	}
 }
 
@@ -1278,10 +1278,10 @@ symlink_path(const char *name1, pathname_t *name)
 	pathname_t	newname;
 	int		rval;
 
-        if (!strcmp(name1, name->path)) {
-            printf("yikes! %s %s\n", name1, name->path);
-            return 0;
-        }
+	if (!strcmp(name1, name->path)) {
+		printf("yikes! %s %s\n", name1, name->path);
+		return 0;
+	}
 
 	rval = symlink(name1, name->path);
 	if (rval >= 0 || errno != ENAMETOOLONG)
@@ -1546,7 +1546,7 @@ bulkstat_f(int opno, long r)
 	int		nent;
 	xfs_bstat_t	*t;
 	__int64_t	total;
-        xfs_fsop_bulkreq_t bsr;
+	xfs_fsop_bulkreq_t bsr;
 
 	last = 0;
 	nent = (r % 999) + 2;
@@ -1554,10 +1554,10 @@ bulkstat_f(int opno, long r)
 	fd = open(".", O_RDONLY);
 	total = 0;
 
-        bsr.lastip=&last;
-        bsr.icount=nent;
-        bsr.ubuffer=t;
-        bsr.ocount=&count;
+	bsr.lastip=&last;
+	bsr.icount=nent;
+	bsr.ubuffer=t;
+	bsr.ocount=&count;
 
 	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
 		total += count;
@@ -1579,12 +1579,12 @@ bulkstat1_f(int opno, long r)
 	struct stat64	s;
 	xfs_bstat_t	t;
 	int		v;
-        xfs_fsop_bulkreq_t bsr;
+	xfs_fsop_bulkreq_t bsr;
 
 
 	good = random() & 1;
 	if (good) {
-               /* use an inode we know exists */
+		/* use an inode we know exists */
 		init_pathname(&f);
 		if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
 			append_pathname(&f, ".");
@@ -1592,34 +1592,34 @@ bulkstat1_f(int opno, long r)
 		check_cwd();
 		free_pathname(&f);
 	} else {
-                /*
-                 * pick a random inode
-                 *
-                 * note this can generate kernel warning messages
-                 * since bulkstat_one will read the disk block that
-                 * would contain a given inode even if that disk
-                 * block doesn't contain inodes.
-                 *
-                 * this is detected later, but not until after the
-                 * warning is displayed.
-                 *
-                 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
-                 *
-                 */
+		/*
+		 * pick a random inode
+		 *
+		 * note this can generate kernel warning messages
+		 * since bulkstat_one will read the disk block that
+		 * would contain a given inode even if that disk
+		 * block doesn't contain inodes.
+		 *
+		 * this is detected later, but not until after the
+		 * warning is displayed.
+		 *
+		 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
+		 *
+		 */
 		ino = (ino64_t)r;
 		v = verbose;
 	}
 	fd = open(".", O_RDONLY);
 
-        bsr.lastip=&ino;
-        bsr.icount=1;
-        bsr.ubuffer=&t;
-        bsr.ocount=NULL;
+	bsr.lastip=&ino;
+	bsr.icount=1;
+	bsr.ubuffer=&t;
+	bsr.ocount=NULL;
 
 	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
 	if (v)
 		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
-                    procid, opno, good?"real":"random", (int64_t)ino, e);
+			procid, opno, good?"real":"random", (int64_t)ino, e);
 	close(fd);
 }
 
@@ -1702,7 +1702,7 @@ creat_f(int opno, long r)
 
 		}
 #endif
-		 		 add_to_flist(type, id, parid);
+		add_to_flist(type, id, parid);
 		close(fd);
 	}
 	if (v)

testcases/kernel/fs/fsstress/fsstress.c dread_f(int opno, long r) · line 1804

Quoted 8 lines
testcases/kernel/fs/fsstress/fsstress.c +1 -1
@@ -1798,7 +1798,7 @@ dread_f(int opno, long r)
 		diob.d_mem = stb.st_blksize;
 	}
 #ifndef NO_XFS
-	   else 	if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
+	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
 			printf(
 			"%d/%d: dread - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#7 lore raw

Re: [LTP] [PATCH 3/5] fsstress: fix memory leaks

In reply to Andrew Vagin
Quoted 9 lines · Andrew Vagin

==11424== 156 bytes in 1 blocks are definitely lost in loss record 2 of 2

==11424==    at 0x4A0763E: malloc (vg_replace_malloc.c:207)
==11424==    by 0x402E4C: make_freq_table (fsstress.c:986)
==11424==    by 0x401C26: main (fsstress.c:410)

make_freq_table is executed on each iterations, but freq_table is not changed during test, so this patch moves it from the loop

Thanks.

Regards--
Subrata

Quoted 46 lines
---
 testcases/kernel/fs/fsstress/fsstress.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +15 -12
index 5ada3d8..715c08d 100644
@@ -375,21 +375,24 @@ int main(int argc, char **argv)
 			break;
 		}
 	}
-	while ( (loopcntr <= loops) || (loops == 0) )
-	{
-		if (no_xfs && errtag) {
-			fprintf(stderr, "error injection only works on XFS\n");
-			exit(1);
-		}
 
-		if (no_xfs) {
-			int i;
-			for (i = 0; ops+i < ops_end; ++i) {
-				if (ops[i].isxfs)
-					ops[i].freq = 0;
-			}
+	if (no_xfs && errtag) {
+		fprintf(stderr, "error injection only works on XFS\n");
+		exit(1);
+	}
+
+	if (no_xfs) {
+		int i;
+		for (i = 0; ops+i < ops_end; ++i) {
+			if (ops[i].isxfs)
+				ops[i].freq = 0;
 		}
+	}
 
+	make_freq_table();
+
+	while ( (loopcntr <= loops) || (loops == 0) )
+	{
 		if (!dirname) {
 			/* no directory specified */
 			if (!nousage) usage();

testcases/kernel/fs/fsstress/fsstress.c int main(int argc, char **argv) · line 415

Quoted 7 lines
testcases/kernel/fs/fsstress/fsstress.c +0 -1
@@ -407,7 +410,6 @@ int main(int argc, char **argv)
 			maxfsize = (off64_t)MAXFSIZE32;
 		else
 			maxfsize = (off64_t)MAXFSIZE;
-		make_freq_table();
 		dcache_init();
 		setlinebuf(stdout);
 		if (!seed) {

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw

Re: [LTP] [PATCH 4/5] fsstress: fix memory leak in fread_d

In reply to Andrew Vagin
Quoted 14 lines · Andrew Vagin

1. check result from operation open before set flags
2. close descriptor and free path if set flags failed

valgrind --leak-check=full --show-reachable=yes ./fsstress -d /home/shpagin/git-archive/ltp/testcases/kernel/fs/fsstress/tmp -l 10 -n 100

==23212== 1,134 bytes in 108 blocks are definitely lost in loss record 4 of 5

==23212==    at 0x4A0776F: realloc (vg_replace_malloc.c:429)
==23212==    by 0x401E6A: append_pathname (fsstress.c:528)
==23212==    by 0x4024E3: fent_to_name (fsstress.c:760)
==23212==    by 0x40284F: get_fname (fsstress.c:846)
==23212==    by 0x4041E0: dread_f (fsstress.c:1757)
==23212==    by 0x402368: doproc (fsstress.c:728)
==23212==    by 0x401CC1: main (fsstress.c:463)
Quoted 1 line

Thanks.

Regards--
Subrata

Quoted 36 lines
---
 testcases/kernel/fs/fsstress/fsstress.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +7 -4
index 715c08d..cf7ba76 100644
@@ -1764,10 +1764,6 @@ dread_f(int opno, long r)
 	}
 	fd = open_path(&f, O_RDONLY);
 
-	if (!setdirect(fd)) {
-		return;
-	}
-
 	e = fd < 0 ? errno : 0;
 	check_cwd();
 	if (fd < 0) {
@@ -1777,6 +1773,13 @@ dread_f(int opno, long r)
 		free_pathname(&f);
 		return;
 	}
+
+	if (!setdirect(fd)) {
+		close(fd);
+		free_pathname(&f);
+		return;
+	}
+
 	if (fstat64(fd, &stb) < 0) {
 		if (v)
 			printf("%d/%d: dread - fstat64 %s failed %d\n",
@@ -1864,8 +1867,11 @@ dwrite_f(int opno, long r)
 		return;
 	}

testcases/kernel/fs/fsstress/fsstress.c dwrite_f(int opno, long r) · line 1877

Quoted 10 lines
testcases/kernel/fs/fsstress/fsstress.c +4 -1
 
-	if (!setdirect(fd))
+	if (!setdirect(fd)) {
+		close(fd);
+		free_pathname(&f);
 		return;
+	}
 	if (fstat64(fd, &stb) < 0) {
 		if (v)
 			printf("%d/%d: dwrite - fstat64 %s failed %d\n",

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw

Re: [LTP] [PATCH 5/5] fsstress: renew flist if clean up test directory

In reply to Andrew Vagin
Quoted 4 lines · Andrew Vagin

flist contain all files created by fsstress. If test clean up direcory on each interations that it should reinitilize flist.

Thanks.

Regards--
Subrata

Quoted 11 lines
---
 testcases/kernel/fs/fsstress/fsstress.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +0 -0
index cf7ba76..736bd53 100644
@@ -491,6 +491,12 @@ int main(int argc, char **argv)
 		{
 			sprintf(cmd,"rm -rf %s/*",dirname);

testcases/kernel/fs/fsstress/fsstress.c int main(int argc, char **argv) · line 502

Quoted 10 lines
testcases/kernel/fs/fsstress/fsstress.c +6 -0
 			system(cmd);
+			for (i = 0; i < FT_nft; i++) {
+				flist[i].nslots = 0;
+				flist[i].nfiles = 0;
+				free(flist[i].fents);
+				flist[i].fents = NULL;
+			}
 		}
 		loopcntr++;
 	}

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#9 lore raw
In reply to Andrew Vagin
Quoted 1 line · Andrew Vagin

Thanks.

Regards--
Subrata

Quoted 148 lines
---
 testcases/kernel/fs/fsstress/fsstress.c |   36 +++++++++++++++---------------
 1 files changed, 18 insertions(+), 18 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +17 -17
index 1f11f6e..b313b62 100644
@@ -295,7 +295,7 @@ int main(int argc, char **argv)
 	ptrdiff_t	srval;
 #endif
         int             nousage=0;
-#ifndef NO_XFS	
+#ifndef NO_XFS
 	xfs_error_injection_t	err_inj;
 #endif
 
@@ -308,7 +308,7 @@ int main(int argc, char **argv)
 		switch (c) {
 		case 'c':
 			/*Don't cleanup*/
-			cleanup=1; 
+			cleanup=1;
 			break;
 		case 'd':
 			dirname = optarg;
@@ -389,13 +389,13 @@ int main(int argc, char **argv)
 					ops[i].freq = 0;
 			}
 		}
-       
+
        	 	if (!dirname) {
        	     	/* no directory specified */
     	        	if (!nousage) usage();
            	 exit(1);
         	}
-       
+
 		(void)mkdir(dirname, 0777);
 		if (chdir(dirname) < 0) {
 			perror(dirname);
@@ -472,7 +472,7 @@ int main(int argc, char **argv)
 			while (wait(&stat) > 0)
 				continue;
 		}
-#ifndef NO_XFS	
+#ifndef NO_XFS
 		if (errtag != 0) {
 			err_inj.errtag = 0;
 			err_inj.fd = fd;
@@ -724,7 +724,7 @@ doproc(void)
 		p = &ops[freq_table[random() % freq_table_size]];
 		if ((unsigned long)p->func < 4096) abort();
 
-	
+
 		p->func(opno, random());
 		/*
 		 * test for forced shutdown by stat'ing the test
@@ -1225,7 +1225,7 @@ show_ops(int flag, char *lead_str)
         if (flag<0) {
                 /* print in list form */
                 int             x = WIDTH;
-               
+
 	        for (p = ops; p < ops_end; p++) {
 			if (lead_str != NULL && x+strlen(p->name)>=WIDTH-5)
 				x=printf("%s%s", (p==ops)?"":"\n", lead_str);
@@ -1277,7 +1277,7 @@ symlink_path(const char *name1, pathname_t *name)
 	char		buf[MAXNAMELEN];
 	pathname_t	newname;
 	int		rval;
-       
+
         if (!strcmp(name1, name->path)) {
             printf("yikes! %s %s\n", name1, name->path);
             return 0;
@@ -1553,12 +1553,12 @@ bulkstat_f(int opno, long r)
 	t = malloc(nent * sizeof(*t));
 	fd = open(".", O_RDONLY);
 	total = 0;
-   
+
         bsr.lastip=&last;
         bsr.icount=nent;
         bsr.ubuffer=t;
         bsr.ocount=&count;
-           
+
 	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
 		total += count;
 	free(t);
@@ -1580,7 +1580,7 @@ bulkstat1_f(int opno, long r)
 	xfs_bstat_t	t;
 	int		v;
         xfs_fsop_bulkreq_t bsr;
-       
+
 
 	good = random() & 1;
 	if (good) {
@@ -1610,12 +1610,12 @@ bulkstat1_f(int opno, long r)
 		v = verbose;
 	}
 	fd = open(".", O_RDONLY);
-       
+
         bsr.lastip=&ino;
         bsr.icount=1;
         bsr.ubuffer=&t;
         bsr.ocount=NULL;
-       
+
 	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
 	if (v)
 		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
@@ -1699,9 +1699,9 @@ creat_f(int opno, long r)
 			if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0)
 				e1 = errno;
 			esz = a.fsx_estsize;
-		
+
 		}
-#endif	
+#endif
 		 		 add_to_flist(type, id, parid);
 		close(fd);
 	}
@@ -1723,7 +1723,7 @@ setdirect(int fd)
 		return 0;
 
 	flags = fcntl(fd, F_GETFL, 0);
-	if (flags < 0) 
+	if (flags < 0)
 		return 0;
 
 	if (fcntl(fd, F_SETFL, flags|O_DIRECT)  < 0) {
@@ -1734,7 +1734,7 @@ setdirect(int fd)
 		printf("cannot set O_DIRECT: %s\n",strerror(errno));
 		return 0;
 	}
-			      
+
 	return 1;
 }
 

testcases/kernel/fs/fsstress/fsstress.c dread_f(int opno, long r) · line 1758

Quoted 8 lines
testcases/kernel/fs/fsstress/fsstress.c +1 -1
@@ -1752,7 +1752,7 @@ dread_f(int opno, long r)
 	off64_t		off;
 	struct stat64	stb;
 	int		v;
-      
+
 	init_pathname(&f);
 	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
 		if (v)

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list