All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] src/t_stripealign.c: Use block size reported by fstatfs()
@ 2018-11-21 16:26 Chandan Rajendra
  2018-11-23  6:20 ` Eryu Guan
  0 siblings, 1 reply; 2+ messages in thread
From: Chandan Rajendra @ 2018-11-21 16:26 UTC (permalink / raw)
  To: fstests; +Cc: Chandan Rajendra, guaneryu

On ppc64le, block size reported by fstat(2) is 64k (the page size)
i.e. the "preferred I/O size". However src/t_stripealign.c requires the
actual block size of the filesystem. Hence this commit now makes use of
the block size reported by fstatfs(2) syscall.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 src/t_stripealign.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/t_stripealign.c b/src/t_stripealign.c
index c61e7632..5cdadaae 100644
--- a/src/t_stripealign.c
+++ b/src/t_stripealign.c
@@ -7,7 +7,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#include <sys/vfs.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
@@ -31,7 +31,7 @@
 
 int main(int argc, char ** argv)
 {
-	struct stat		sb;
+	struct statfs		sb;
 	struct fiemap		*fie;
 	struct fiemap_extent	*fe;
 	int			fd;
@@ -54,7 +54,7 @@ int main(int argc, char ** argv)
                 return 1;
         }
 
-	ret = fstat(fd, &sb);
+	ret = fstatfs(fd, &sb);
 	if (ret) {
 		perror(filename);
 		close(fd);
@@ -101,7 +101,7 @@ int main(int argc, char ** argv)
 		return 1;
 	}
 
-	block = fie->fm_extents[0].fe_physical / sb.st_blksize;
+	block = fie->fm_extents[0].fe_physical / sb.f_bsize;
 check:
 	if (block % sunit) {
 		printf("%s: Start block %llu not multiple of sunit %u\n",
-- 
2.19.1

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

* Re: [PATCH] src/t_stripealign.c: Use block size reported by fstatfs()
  2018-11-21 16:26 [PATCH] src/t_stripealign.c: Use block size reported by fstatfs() Chandan Rajendra
@ 2018-11-23  6:20 ` Eryu Guan
  0 siblings, 0 replies; 2+ messages in thread
From: Eryu Guan @ 2018-11-23  6:20 UTC (permalink / raw)
  To: Chandan Rajendra; +Cc: fstests

On Wed, Nov 21, 2018 at 09:56:46PM +0530, Chandan Rajendra wrote:
> On ppc64le, block size reported by fstat(2) is 64k (the page size)
> i.e. the "preferred I/O size". However src/t_stripealign.c requires the
> actual block size of the filesystem. Hence this commit now makes use of
> the block size reported by fstatfs(2) syscall.
> 
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>

Looks like that only XFS returns the preferred iosize
(xfs_preferred_iosize()) on stat(2), other filesystems will return block
size (I checked the code of ext4, f2fs, ocfs2).

On the other hand, statfs(2) returns the actual block size on all
filesystems I've checked, including XFS. So this patch looks fine to me.

Thanks,
Eryu

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

end of thread, other threads:[~2018-11-23 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-21 16:26 [PATCH] src/t_stripealign.c: Use block size reported by fstatfs() Chandan Rajendra
2018-11-23  6:20 ` Eryu Guan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.