fs: fsstress: make test more POSIX compliant
PATCH v5 1/2 fs: fsstress: make test more POSIX compliant
From: Caspar Zhang <[email protected]>
in commit bacc849720ec4efda5a0a8a9ea6a0e93a1415541, malloc.h was removed and stdlib.h got used instead. However, it's not enough. The function memalign() is also obsolete (via man memalign) and we should use posix_memalign instead. Also if we keep memalign() function here, the program would probably hit segfault once it enters dwrite_t and dread_t.
v2: use correct &buf as argument
v3: remove incorrect disabling warning, will try to fix warning and compiling without -DNO_XFS in another patch
v4: code style
v5: record the retval of posix_memalign and use strerror
Signed-off-by Caspar Zhang <[email protected]>
--- testcases/kernel/fs/fsstress/fsstress.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-)
testcases/kernel/fs/fsstress/fsstress.c +19 -5
@@ -1746,7 +1746,7 @@ void dread_f(int opno, long r) {__int64_t align; -char *buf; +char *buf =NULL ;struct dioattr diob;int e;pathname_t f;
@@ -1826,7 +1826,14 @@ dread_f(int opno, long r) len = align; else if (len > diob.d_maxiosz) len = diob.d_maxiosz; - buf =memalign (diob.d_mem, len); +if ((e =posix_memalign ((void **)&buf, diob.d_mem, len)) !=0 ) { +fprintf (stderr,"posix_memalign: %s\n" ,strerror (e)); +exit (1 ); + } +if (buf ==NULL ) { +fprintf (stderr,"posix_memalign: buf is NULL\n" ); +exit (1 ); + } e =read (fd, buf, len) <0 ? errno :0 ;free (buf);if (v)
@@ -1840,7 +1847,7 @@ void dwrite_f(int opno, long r) {__int64_t align; -char *buf; +char *buf =NULL ;struct dioattr diob;int e;pathname_t f;
@@ -1909,7 +1916,14 @@ dwrite_f(int opno, long r) len = align; else if (len > diob.d_maxiosz) len = diob.d_maxiosz; - buf =memalign (diob.d_mem, len); +if ((e =posix_memalign ((void **)&buf, diob.d_mem, len)) !=0 ) { +fprintf (stderr,"posix_memalign: %s\n" ,strerror (e)); +exit (1 ); + } +if (buf ==NULL ) { +fprintf (stderr,"posix_memalign: buf is NULL\n" ); +exit (1 ); + } off %= maxfsize;lseek64 (fd, off,SEEK_SET );memset (buf, nameseq &0xff , len);
@@ -2650,4 +2664,4 @@ write_f(int opno, long r) procid, opno, f.path, (long long)off, (long int)len, e);free_pathname (&f);close (fd); -} +}
Signature · 12 lines
1.7.4.1 ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Commited -- thanks.
Signature · 12 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list