All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs-toos: use getpagesize() to get default blocksize in Android
@ 2024-09-14  3:11 ` Zhiguo Niu
  0 siblings, 0 replies; 6+ messages in thread
From: Zhiguo Niu @ 2024-09-14  3:11 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: xiuhong.wang, ke.wang, linux-kernel, linux-f2fs-devel, zhiguo.niu,
	Hao_hao.Wang

When 16K page/block size is enabled in Android platform,
a error maybe detected in mount process in kernel if "-b"
parameters is not specified in mkfs.f2fs.
Just as the following check:
if (le32_to_cpu(raw_super->log_blocksize) != F2FS_BLKSIZE_BITS)

So use getpagesize() to get correct default blocksize.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
---
 lib/libf2fs.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index ecd22d4..98ee0ae 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -685,8 +685,17 @@ void f2fs_init_configuration(void)
 
 	memset(&c, 0, sizeof(struct f2fs_configuration));
 	c.ndevs = 1;
+#ifdef WITH_ANDROID
+	c.blksize = getpagesize();
+	c.blksize_bits = log_base_2(c.blksize);
+	if ((1 << c.blksize_bits) != c.blksize) {
+		c.blksize = 1 << DEFAULT_BLKSIZE_BITS;
+		c.blksize_bits = DEFAULT_BLKSIZE_BITS;
+	}
+#else
 	c.blksize = 1 << DEFAULT_BLKSIZE_BITS;
 	c.blksize_bits = DEFAULT_BLKSIZE_BITS;
+#endif
 	c.sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
 	c.blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
 	c.wanted_total_sectors = -1;
-- 
1.9.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2024-10-07 16:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-14  3:11 [f2fs-dev] [PATCH] f2fs-toos: use getpagesize() to get default blocksize in Android Zhiguo Niu
2024-09-14  3:11 ` Zhiguo Niu
2024-09-19  1:23 ` [f2fs-dev] " Zhiguo Niu
2024-09-19  1:23   ` Zhiguo Niu
2024-10-07 16:49   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2024-10-07 16:49     ` Jaegeuk Kim

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.