2020-12-08 08:19:30

by Robin Hsu

[permalink] [raw]
Subject: [PATCH v3 0/3] f2fs-tools: sload compression support

From: Robin Hsu <[email protected]>

* 3 patch set:
#1: added some #ifdef for easier support
#2: main code change
#3: automake changes

v2 fix (from v1): fixed a bug and a more elegant error handling flow.
v3 fix (from v2): ./configure (automake) automatically determine to
compile in lzo and/or lz4 compression support depending on the presence
of liblzo2-dev and/or liblz4-dev

Robin Hsu (3):
f2fs-tools: Added #ifdef WITH_func
f2fs-tools:sload.f2fs compression support
f2fs-tools:sload.f2fs compress: Fixed automake

configure.ac | 12 +++
fsck/Makefile.am | 9 +-
fsck/compress_wrapper.c | 102 ++++++++++++++++++++
fsck/compress_wrapper.h | 22 +++++
fsck/fsck.h | 15 +++
fsck/main.c | 157 ++++++++++++++++++++++++++++++-
fsck/segment.c | 202 +++++++++++++++++++++++++++++++++++++---
fsck/sload.c | 67 +++++++++++++
include/f2fs_fs.h | 76 ++++++++++++++-
lib/libf2fs_io.c | 33 +++++++
10 files changed, 678 insertions(+), 17 deletions(-)
create mode 100644 fsck/compress_wrapper.c
create mode 100644 fsck/compress_wrapper.h

--
2.29.2.576.ga3fc446d84-goog


2020-12-08 08:20:29

by Robin Hsu

[permalink] [raw]
Subject: [PATCH 1/3] f2fs-tools: Added #ifdef WITH_func

From: Robin Hsu <[email protected]>

Add proprocessor defines (options) 'WITH_func',
where func = DUMP, DEFRAG, RESIZE, or SLOAD

Signed-off-by: Robin Hsu <[email protected]>
---
fsck/main.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/fsck/main.c b/fsck/main.c
index e70048b..b20498f 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -345,6 +345,7 @@ void f2fs_parse_options(int argc, char *argv[])
break;
}
} else if (!strcmp("dump.f2fs", prog)) {
+#ifdef WITH_DUMP
const char *option_string = "d:i:n:s:Sa:b:V";
static struct dump_option dump_opt = {
.nid = 0, /* default root ino */
@@ -426,7 +427,9 @@ void f2fs_parse_options(int argc, char *argv[])
}

c.private = &dump_opt;
+#endif
} else if (!strcmp("defrag.f2fs", prog)) {
+#ifdef WITH_DEFRAG
const char *option_string = "d:s:Sl:t:iV";

c.func = DEFRAG;
@@ -484,7 +487,9 @@ void f2fs_parse_options(int argc, char *argv[])
if (err != NOERROR)
break;
}
+#endif
} else if (!strcmp("resize.f2fs", prog)) {
+#ifdef WITH_RESIZE
const char *option_string = "d:st:iV";

c.func = RESIZE;
@@ -526,7 +531,9 @@ void f2fs_parse_options(int argc, char *argv[])
if (err != NOERROR)
break;
}
+#endif
} else if (!strcmp("sload.f2fs", prog)) {
+#ifdef WITH_SLOAD
const char *option_string = "C:d:f:p:s:St:T:V";
#ifdef HAVE_LIBSELINUX
int max_nr_opt = (int)sizeof(c.seopt_file) /
@@ -595,6 +602,7 @@ void f2fs_parse_options(int argc, char *argv[])
if (err != NOERROR)
break;
}
+#endif /* WITH_SLOAD */
}

if (err == NOERROR) {
@@ -707,6 +715,7 @@ static int do_fsck(struct f2fs_sb_info *sbi)
return FSCK_ERRORS_LEFT_UNCORRECTED;
}

+#ifdef WITH_DUMP
static void do_dump(struct f2fs_sb_info *sbi)
{
struct dump_option *opt = (struct dump_option *)c.private;
@@ -733,7 +742,9 @@ static void do_dump(struct f2fs_sb_info *sbi)
print_cp_state(flag);

}
+#endif

+#ifdef WITH_DEFRAG
static int do_defrag(struct f2fs_sb_info *sbi)
{
struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
@@ -782,7 +793,9 @@ out_range:
c.defrag_target);
return -1;
}
+#endif

+#ifdef WITH_RESIZE
static int do_resize(struct f2fs_sb_info *sbi)
{
if (!c.target_sectors)
@@ -796,7 +809,9 @@ static int do_resize(struct f2fs_sb_info *sbi)

return f2fs_resize(sbi);
}
+#endif

+#ifdef WITH_SLOAD
static int do_sload(struct f2fs_sb_info *sbi)
{
if (!c.from_dir) {
@@ -808,6 +823,7 @@ static int do_sload(struct f2fs_sb_info *sbi)

return f2fs_sload(sbi);
}
+#endif

#if defined(__APPLE__)
static u64 get_boottime_ns()
--
2.29.2.576.ga3fc446d84-goog

2020-12-09 00:56:54

by Robin Hsu

[permalink] [raw]
Subject: [PATCH 3/3] f2fs-tools:sload.f2fs compress: Fixed automake

From: Robin Hsu <[email protected]>

Fixed automake for sload.f2fs compression support

./configure automatcally compile in liblzo2 (for sload to support -a LZO)
and liblz4 (for sload to support -a LZ4), whhen the libraries present.

Signed-off-by: Robin Hsu <[email protected]>
---
configure.ac | 12 ++++++++++++
fsck/Makefile.am | 9 ++++++---
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1e5619d..01d1a05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,18 @@ AC_PATH_PROG([LDCONFIG], [ldconfig],
[$PATH:/sbin])

# Checks for libraries.
+AC_CHECK_LIB([lzo2], [main],
+ [AC_SUBST([liblzo2_LIBS], ["-llzo2"])
+ AC_DEFINE([HAVE_LIBLZO2], [1],
+ [Define if you have liblzo2])
+ ], [], [])
+
+AC_CHECK_LIB([lz4], [main],
+ [AC_SUBST([liblz4_LIBS], ["-llz4"])
+ AC_DEFINE([HAVE_LIBLZ4], [1],
+ [Define if you have liblz4])
+ ], [], [])
+
PKG_CHECK_MODULES([libuuid], [uuid])

AS_IF([test "x$with_selinux" != "xno"],
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 1fc7310..74bc4b8 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -3,12 +3,15 @@
AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
AM_CFLAGS = -Wall
sbin_PROGRAMS = fsck.f2fs
-noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h quotaio_tree.h quotaio_v2.h xattr.h
+noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h \
+ quotaio_tree.h quotaio_v2.h xattr.h compress_wrapper.h
include_HEADERS = $(top_srcdir)/include/quota.h
fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c \
- node.c segment.c dir.c sload.c xattr.c \
+ node.c segment.c dir.c sload.c xattr.c compress_wrapper.c \
dict.c mkquota.c quotaio.c quotaio_tree.c quotaio_v2.c
-fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la
+fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} \
+ ${liblzo2_LIBS} ${liblz4_LIBS} \
+ $(top_builddir)/lib/libf2fs.la

install-data-hook:
ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/dump.f2fs
--
2.29.2.576.ga3fc446d84-goog