public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] fs: fsstress: make test more POSIX compliant
@ 2011-03-14 12:03 Caspar Zhang
  2011-03-16 12:07 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Caspar Zhang @ 2011-03-14 12:03 UTC (permalink / raw)
  To: LTP list

[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]

[PATCH] fs: fsstress: make test more POSIX compliant

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.

Besides the POSIX compliant fix, I also did a small fix to remove
compling warnings.

I tried to update this program output to tst_resm/tst_brkm style but
failed, I got confused by some printf output.

Signed-off-by: Caspar Zhang <czhang@redhat.com>
---
 testcases/kernel/fs/fsstress/fsstress.c |   38
++++++++++++++++++------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/testcases/kernel/fs/fsstress/fsstress.c
b/testcases/kernel/fs/fsstress/fsstress.c
index e3b48ea..0e5fba2 100644
--- a/testcases/kernel/fs/fsstress/fsstress.c
+++ b/testcases/kernel/fs/fsstress/fsstress.c
@@ -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;
@@ -1799,11 +1799,9 @@ dread_f(int opno, long r)
 		return;
 	}

-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
+	diob.d_miniosz = stb.st_blksize;
+	diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
+	diob.d_mem = stb.st_blksize;
 #ifndef NO_XFS
 	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
@@ -1826,7 +1824,13 @@ 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);
+	} else if (buf == NULL) {
+		fprintf(stderr, "buf remains NULL unexpectly\n");
+		exit (1);
+	}
 	e = read(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
@@ -1840,7 +1844,7 @@ void
 dwrite_f(int opno, long r)
 {
 	__int64_t	align;
-	char		*buf;
+	char		*buf=NULL;
 	struct dioattr	diob;
 	int		e;
 	pathname_t	f;
@@ -1882,11 +1886,9 @@ dwrite_f(int opno, long r)
 		close(fd);
 		return;
 	}
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
+	diob.d_miniosz = stb.st_blksize;
+	diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
+	diob.d_mem = stb.st_blksize;
 #ifndef NO_XFS
 	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
@@ -1909,7 +1911,13 @@ 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);
+	} else if (buf == NULL)	{
+		fprintf(stderr, "buf remains NULL unexpectly\n");
+		exit (1);
+	}
 	off %= maxfsize;
 	lseek64(fd, off, SEEK_SET);
 	memset(buf, nameseq & 0xff, len);
@@ -2650,4 +2658,4 @@ write_f(int opno, long r)
 			procid, opno, f.path, (long long)off, (long int)len, e);
 	free_pathname(&f);
 	close(fd);
-}
\ No newline at end of file
+}
-- 
1.7.4.1


-- 
Quality Engineer (Kernel) in
Red Hat Software (Beijing) Co., R&D Branch
http://www.cn.redhat.com/
TEL: +86-10-62608150

[-- Attachment #2: 0001-fs-fsstress-make-test-more-POSIX-compliant.patch --]
[-- Type: text/plain, Size: 3241 bytes --]

[PATCH] fs: fsstress: make test more POSIX compliant

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.

Besides the POSIX compliant fix, I also did a small fix to remove
compling warnings.

I tried to update this program output to tst_resm/tst_brkm style but
failed, I got confused by some printf output.

Signed-off-by: Caspar Zhang <czhang@redhat.com>
---
 testcases/kernel/fs/fsstress/fsstress.c |   38 ++++++++++++++++++------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/testcases/kernel/fs/fsstress/fsstress.c b/testcases/kernel/fs/fsstress/fsstress.c
index e3b48ea..0e5fba2 100644
--- a/testcases/kernel/fs/fsstress/fsstress.c
+++ b/testcases/kernel/fs/fsstress/fsstress.c
@@ -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;
@@ -1799,11 +1799,9 @@ dread_f(int opno, long r)
 		return;
 	}
 
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
+	diob.d_miniosz = stb.st_blksize;
+	diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
+	diob.d_mem = stb.st_blksize;
 #ifndef NO_XFS
 	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
@@ -1826,7 +1824,13 @@ 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);
+	} else if (buf == NULL) {
+		fprintf(stderr, "buf remains NULL unexpectly\n");
+		exit (1);
+	}
 	e = read(fd, buf, len) < 0 ? errno : 0;
 	free(buf);
 	if (v)
@@ -1840,7 +1844,7 @@ void
 dwrite_f(int opno, long r)
 {
 	__int64_t	align;
-	char		*buf;
+	char		*buf=NULL;
 	struct dioattr	diob;
 	int		e;
 	pathname_t	f;
@@ -1882,11 +1886,9 @@ dwrite_f(int opno, long r)
 		close(fd);
 		return;
 	}
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
+	diob.d_miniosz = stb.st_blksize;
+	diob.d_maxiosz = stb.st_blksize * 256;  /* good number ? */
+	diob.d_mem = stb.st_blksize;
 #ifndef NO_XFS
 	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
 		if (v)
@@ -1909,7 +1911,13 @@ 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);
+	} else if (buf == NULL)	{
+		fprintf(stderr, "buf remains NULL unexpectly\n");
+		exit (1);
+	}
 	off %= maxfsize;
 	lseek64(fd, off, SEEK_SET);
 	memset(buf, nameseq & 0xff, len);
@@ -2650,4 +2658,4 @@ write_f(int opno, long r)
 			procid, opno, f.path, (long long)off, (long int)len, e);
 	free_pathname(&f);
 	close(fd);
-}
\ No newline at end of file
+}
-- 
1.7.4.1


[-- Attachment #3: Type: text/plain, Size: 249 bytes --]

------------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-16 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-14 12:03 [LTP] [PATCH] fs: fsstress: make test more POSIX compliant Caspar Zhang
2011-03-16 12:07 ` Cyril Hrubis
     [not found]   ` <4D80A5E1.2020002@redhat.com>
2011-03-16 12:51     ` Cyril Hrubis
2011-03-16 13:12     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox