fsstress: fix memory leaks
PATCH 1/3 fsstress: fix memory leaks
==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 | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +16 -14
@@ -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® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 2/3 fsstress: fix memory leak in fread_d
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
@@ -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)) { +free_pathname (&f); +close (fd);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® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH 3/3 fsstress: renew flist if clean up test directory
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 | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +7 -0
@@ -491,6 +491,13 @@ 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® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH 3/3] fsstress: renew flist if clean up test directory
Quoted 15 lines · 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 | 7 +++++++1 files changed, 7 insertions(+), 0 deletions(-)testcases/kernel/fs/fsstress/fsstress.c +0
-0@@ -491,6 +491,13 @@ int main(int argc, char **argv) { sprintf(cmd,"rm -rf %s/*",dirname); system(cmd);
testcases/kernel/fs/fsstress/fsstress.c int main(int argc, char **argv) · line 503
Quoted 10 lines
testcases/kernel/fs/fsstress/fsstress.c +7
-0+ for (i = 0; i < FT_nft; i++) { + flist[i].nslots = 0; + flist[i].nfiles = 0; + free(flist[i].fents); + flist[i].fents = NULL; + } + } loopcntr++; }
Looks good :).
Thanks!
-Garrett
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH 2/3] fsstress: fix memory leak in fread_d
In reply to Andrew VaginQuoted 51 lines · Andrew Vagin
1. check result from operation open before set flags
2. close descriptor and free path if set flags failedvalgrind --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== by0x401E6A:append_pathname(fsstress.c:528) ==23212== by0x4024E3:fent_to_name(fsstress.c:760)
==23212== by0x40284F:get_fname(fsstress.c:846)
==23212== by0x4041E0:dread_f(fsstress.c:1757)
==23212== by0x402368: doproc (fsstress.c:728)
==23212== by0x401CC1: main (fsstress.c:463)---
testcases/kernel/fs/fsstress/fsstress.c | 16 +++++++++++-----1 files changed, 11 insertions(+), 5 deletions(-)testcases/kernel/fs/fsstress/fsstress.c +7
-4@@ -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)) { + free_pathname(&f); + close(fd); return; + } if (fstat64(fd, &stb) < 0) { if (v) printf("%d/%d: dwrite - fstat64 %s failed %d\n",
Andrew,
This change looks good, but the indentation is a bit catywampus.
Please fix and run with checkpatch.pl.
Thanks!
-Garrett
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 55 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== by0x402E4C:make_freq_table(fsstress.c:986) ==11424== by0x401C26: main (fsstress.c:410)
make_freq_tableis executed on each iterations, butfreq_tableis not changed during test, so this patch moves it from the loop
---
testcases/kernel/fs/fsstress/fsstress.c | 30 ++++++++++++++++--------------1 files changed, 16 insertions(+), 14 deletions(-)testcases/kernel/fs/fsstress/fsstress.c +16
-13@@ -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;
Quoted 8 lines
else
maxfsize = (off64_t)MAXFSIZE;
-make_freq_table();dcache_init(); setlinebuf(stdout);
if (!seed) {
--
1.6.2.5
Andrew,
Please use tabs instead of spaces for indentation. Run
checkpatch.pl after everything's said and done to validate style. Thanks,
-Garrett
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
On 09/27/2009 01:29 AM, Garrett Cooper wrote:
Thanks for your comments, I resent all patches.
Quoted 72 lines · Andrew Vagin
Quoted 63 lines
==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_tableis executed on each iterations, butfreq_tableis not changed during test, so this patch moves it from the loop--- testcases/kernel/fs/fsstress/fsstress.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-)testcases/kernel/fs/fsstress/fsstress.c +16
-15@@ -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) { --Quoted 2 lines
1.6.2.5
Andrew,
Please use tabs instead of spaces for indentation. Run
checkpatch.pl after everything's said and done to validate style. Thanks,
-Garrett
Quoted 13 lines
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list