Linux-f2fs-devel Archive on lore.kernel.org
 help / color / Atom feed
* [f2fs-dev] [PATCH 1/3] f2fs_io: add mmap read operation
@ 2020-07-21  0:38 Jaegeuk Kim
  2020-07-21  0:38 ` [f2fs-dev] [PATCH 2/3] mkfs.f2fs: should initialize sparse file in Windows Jaegeuk Kim
  2020-07-21  0:38 ` [f2fs-dev] [PATCH 3/3] mkfs.f2fs: add casefolding and project quota config Jaegeuk Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2020-07-21  0:38 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds an option, mmap, when reading data.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 tools/f2fs_io/f2fs_io.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 30544c1..6266454 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -489,15 +489,18 @@ static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 "IO can be\n"						\
 "  buffered : buffered IO\n"				\
 "  dio      : direct IO\n"				\
+"  mmap     : mmap IO\n"				\
 
 static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 {
 	u64 buf_size = 0, ret = 0, read_cnt = 0;
 	u64 offset;
 	char *buf = NULL;
+	char *data;
 	char *print_buf = NULL;
 	unsigned bs, count, i, print_bytes;
 	int flags = 0;
+	int do_mmap = 0;
 	int fd;
 
 	if (argc != 7) {
@@ -518,6 +521,8 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 	count = atoi(argv[3]);
 	if (!strcmp(argv[4], "dio"))
 		flags |= O_DIRECT;
+	else if (!strcmp(argv[4], "mmap"))
+		do_mmap = 1;
 	else if (strcmp(argv[4], "buffered"))
 		die("Wrong IO type");
 
@@ -529,8 +534,20 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
 
 	fd = xopen(argv[6], O_RDONLY | flags, 0);
 
+	if (do_mmap) {
+		data = mmap(NULL, count * buf_size, PROT_READ,
+						MAP_SHARED, fd, offset);
+		if (data == MAP_FAILED)
+			die("Mmap failed");
+	}
+
 	for (i = 0; i < count; i++) {
-		ret = pread(fd, buf, buf_size, offset + buf_size * i);
+		if (do_mmap) {
+			memcpy(buf, data + offset + buf_size * i, buf_size);
+			ret = buf_size;
+		} else {
+			ret = pread(fd, buf, buf_size, offset + buf_size * i);
+		}
 		if (ret != buf_size)
 			break;
 
-- 
2.28.0.rc0.105.gf9edc3c819-goog



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

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

* [f2fs-dev] [PATCH 2/3] mkfs.f2fs: should initialize sparse file in Windows
  2020-07-21  0:38 [f2fs-dev] [PATCH 1/3] f2fs_io: add mmap read operation Jaegeuk Kim
@ 2020-07-21  0:38 ` Jaegeuk Kim
  2020-07-21  0:38 ` [f2fs-dev] [PATCH 3/3] mkfs.f2fs: add casefolding and project quota config Jaegeuk Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2020-07-21  0:38 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

Otherwise it fails to format in Windows.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 lib/libf2fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 55d3a5c..5937076 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -1158,6 +1158,8 @@ int get_device_info(int i)
 	c.sectors_per_blk = F2FS_BLKSIZE / c.sector_size;
 	c.total_sectors += dev->total_sectors;
 
+	if (c.sparse_mode && f2fs_init_sparse_file())
+		return -1;
 	return 0;
 }
 #endif
-- 
2.28.0.rc0.105.gf9edc3c819-goog



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

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

* [f2fs-dev] [PATCH 3/3] mkfs.f2fs: add casefolding and project quota config
  2020-07-21  0:38 [f2fs-dev] [PATCH 1/3] f2fs_io: add mmap read operation Jaegeuk Kim
  2020-07-21  0:38 ` [f2fs-dev] [PATCH 2/3] mkfs.f2fs: should initialize sparse file in Windows Jaegeuk Kim
@ 2020-07-21  0:38 ` Jaegeuk Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2020-07-21  0:38 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This can be used for Android build support.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 include/f2fs_fs.h       |  1 +
 lib/libf2fs.c           | 11 +++++++++++
 mkfs/f2fs_format_main.c | 14 ++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index c38a60c..71d1c57 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1563,6 +1563,7 @@ extern const struct f2fs_nls_table *f2fs_load_nls_table(int encoding);
 #define F2FS_ENC_UTF8_12_0	1
 
 extern int f2fs_str2encoding(const char *string);
+extern char *f2fs_encoding2str(const int encoding);
 extern int f2fs_get_encoding_flags(int encoding);
 extern int f2fs_str2encoding_flags(char **param, __u16 *flags);
 
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 5937076..55fa391 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -1306,6 +1306,17 @@ int f2fs_str2encoding(const char *string)
 	return -EINVAL;
 }
 
+char *f2fs_encoding2str(const int encoding)
+{
+	int i;
+
+	for (i = 0 ; i < ARRAY_SIZE(f2fs_encoding_map); i++)
+		if (f2fs_encoding_map[i].encoding_magic == encoding)
+			return f2fs_encoding_map[i].name;
+
+	return NULL;
+}
+
 int f2fs_get_encoding_flags(int encoding)
 {
 	int i;
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 7176db1..27c1f1d 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -90,6 +90,12 @@ static void f2fs_show_info()
 
 	if (c.defset == CONF_ANDROID)
 		MSG(0, "Info: Set conf for android\n");
+
+	if (c.feature & le32_to_cpu(F2FS_FEATURE_CASEFOLD))
+		MSG(0, "Info: Enable %s with casefolding\n",
+					f2fs_encoding2str(c.s_encoding));
+	if (c.feature & le32_to_cpu(F2FS_FEATURE_PRJQUOTA))
+		MSG(0, "Info: Enable Project quota\n");
 }
 
 static void add_default_options(void)
@@ -106,6 +112,14 @@ static void add_default_options(void)
 		c.root_uid = c.root_gid = 0;
 		break;
 	}
+#ifdef CONF_CASEFOLD
+	c.s_encoding = F2FS_ENC_UTF8_12_1;
+	c.feature |= cpu_to_le32(F2FS_FEATURE_CASEFOLD);
+#endif
+#ifdef CONF_PROJID
+	c.feature |= cpu_to_le32(F2FS_FEATURE_PRJQUOTA);
+	c.feature |= cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR);
+#endif
 }
 
 static void f2fs_parse_options(int argc, char *argv[])
-- 
2.28.0.rc0.105.gf9edc3c819-goog



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

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21  0:38 [f2fs-dev] [PATCH 1/3] f2fs_io: add mmap read operation Jaegeuk Kim
2020-07-21  0:38 ` [f2fs-dev] [PATCH 2/3] mkfs.f2fs: should initialize sparse file in Windows Jaegeuk Kim
2020-07-21  0:38 ` [f2fs-dev] [PATCH 3/3] mkfs.f2fs: add casefolding and project quota config Jaegeuk Kim

Linux-f2fs-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-f2fs-devel/0 linux-f2fs-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-f2fs-devel linux-f2fs-devel/ https://lore.kernel.org/linux-f2fs-devel \
		linux-f2fs-devel@lists.sourceforge.net
	public-inbox-index linux-f2fs-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/net.sourceforge.lists.linux-f2fs-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git