fs: fsstress: make test more POSIX compliant
A message that is not in the archive (sent off-list or not yet received): [PATCH 1/2]
PATCH v4 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
--- 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 (posix_memalign ((void **)&buf, diob.d_mem, len) !=0 ) { +perror ("posix_memalign" ); +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 (posix_memalign ((void **)&buf, diob.d_mem, len) !=0 ) { +perror ("posix_memalign" ); +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!
Quoted 9 lines
dread_f(int opno, long r)
{testcases/kernel/fs/fsstress/fsstress.c +1
-1__int64_t align; -char *buf; +char *buf =NULL ;struct dioattr diob;int e;pathname_t f;
testcases/kernel/fs/fsstress/fsstress.c dread_f(int opno, long r) · line 1830
Quoted 6 lines
testcases/kernel/fs/fsstress/fsstress.c +2
-1@@ -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 (posix_memalign ((void **)&buf, diob.d_mem, len) !=0 ) { +perror ("posix_memalign" );
Sorry for not spotting this earlier, but I've doublechecked the manual page and it says:
...posix_memalign() returns zero on success, or one of the error values listed in the next section on failure. Note that errno is not set.
...
So you can't use perror() to print the error message. It would probably print something like:
posix_memalign: Succeded
The correct solution is to save the return value from posix_memalign() and use strerror().
Quoted 8 lines
testcases/kernel/fs/fsstress/fsstress.c +6
-0+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);
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
PATCH v2 2/2 fs: fsstress: fix compile when -DNO_XFS disabled
In reply to a message not in the archiveFrom: Caspar Zhang <[email protected]>
When -DNO_XFS disabled in Makefile, the compilation couldn't pass and many errors and warnings outputed. This patch fixes this issue.
v2: modify CPPFLAGS to LDLIBS
--- testcases/kernel/fs/fsstress/Makefile | 3 +++ testcases/kernel/fs/fsstress/fsstress.c | 16 ++++++++-------- testcases/kernel/fs/fsstress/global.h | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-)
testcases/kernel/fs/fsstress/Makefile +3 -0
@@ -27,6 +27,9 @@ include $(top_srcdir)/include/mk/env_pre.mk CPPFLAGS += -DNO_XFS -I$(abs_srcdir) \ -D_LARGEFILE64_SOURCE -D_GNU_SOURCE +# if removed -DNO_XFS, you should unmask the following line +#LDLIBS += -lattr + # XXX (garrcoop): not -Wuninitialized clean. CPPFLAGS += -Wno-error
testcases/kernel/fs/fsstress/fsstress.c +8 -8
@@ -1436,7 +1436,7 @@ allocsp_f(int opno, long r) e =ioctl (fd,XFS_IOC_ALLOCSP64 , &fl) <0 ? errno :0 ;if (v)printf ("%d/%d: ioctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n" , - procid, opno, f.path, off, e); + procid, opno, f.path, (long long )off, e);free_pathname (&f);close (fd); }
@@ -1571,7 +1571,7 @@ bulkstat_f(int opno, long r)free (t);if (verbose)printf ("%d/%d: bulkstat nent %d total %lld\n" , - procid, opno, nent, total); + procid, opno, nent, (long long )total);close (fd); }
@@ -1704,7 +1704,7 @@ creat_f(int opno, long r) geom.rtextsize * geom.blocksize * extsize;if (ioctl (fd,XFS_IOC_FSSETXATTR , &a) <0 ) e1 = errno; - esz = a.fsx_estsize; + esz = a.fsx_extsize; }#endif
@@ -2016,7 +2016,7 @@ freesp_f(int opno, long r) e =ioctl (fd,XFS_IOC_FREESP64 , &fl) <0 ? errno :0 ;if (v)printf ("%d/%d: ioctl(XFS_IOC_FREESP64) %s %lld 0 %d\n" , - procid, opno, f.path, off, e); + procid, opno, f.path, (long long )off, e);free_pathname (&f);close (fd); }
@@ -2388,8 +2388,8 @@ resvsp_f(int opno, long r) fl.l_len = (off64_t)(random () % (1024 *1024 )); e =ioctl (fd,XFS_IOC_RESVSP64 , &fl) <0 ? errno :0 ;if (v) -printf ("%d/%d: ioctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n" , - procid, opno, f.path, off, fl.l_len, e); +printf ("%d/%d: ioctl(XFS_IOC_RESVSP64) %s %lld %ld %d\n" , + procid, opno, f.path, (long long )off, fl.l_len, e);free_pathname (&f);close (fd); }
@@ -2605,8 +2605,8 @@ unresvsp_f(int opno, long r) fl.l_len = (off64_t)(random () % (1 <<20 )); e =ioctl (fd,XFS_IOC_UNRESVSP64 , &fl) <0 ? errno :0 ;if (v) -printf ("%d/%d: ioctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n" , - procid, opno, f.path, off, fl.l_len, e); +printf ("%d/%d: ioctl(XFS_IOC_UNRESVSP64) %s %lld %ld %d\n" , + procid, opno, f.path, (long long )off, fl.l_len, e);free_pathname (&f);close (fd); }
testcases/kernel/fs/fsstress/global.h +2 -2
@@ -38,8 +38,8 @@#if defined(NO_XFS )# include "xfscompat.h" #else -# include <libxfs.h> -# include <attributes.h> +# include <xfs/libxfs.h> +# include <attr/attributes.h> #endif /* libc includes */
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
Re: [LTP] [PATCH v2 2/2] fs: fsstress: fix compile when -DNO_XFS disabled
Quoted 6 lines · On Wed, Mar 16, 2011 at 8:45 AM, <[email protected]> wrote:
From: Caspar Zhang <[email protected]>
When -DNO_XFS disabled in
Makefile, the compilation couldn't pass and many errors and warnings outputed. This patch fixes this issue.v2: modify CPPFLAGS to LDLIBS
Once upon a time I assume this worked for someone when compiling
on legacy systems. Please add any and all necessary autoconf tests for these headers.
Thanks,
-Garrett
------------------------------------------------------------------------------
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
Re: [LTP] [PATCH v2 2/2] fs: fsstress: fix compile when -DNO_XFS disabled
Hi!
Quoted 3 lines
Once upon a time I assume this worked for someone when compiling
on legacy systems. Please add any and all necessary autoconf tests for these headers.
I've commited the patch as it is a couple of minutes ago as you may say it's improvement to the previous state. However that it doesn't compile here.
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