Skip to content

Commit cdccf88

Browse files
committed
disabled by default EXPERIMENTAL support for preallocated files
(by mistake it was automatically enabled when converting to ext4!), cleaned it up and clearly marked it everywhere as EXPERIMENTAL
1 parent 3eacbe8 commit cdccf88

22 files changed

+476
-315
lines changed

Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
222222
INSTALL_SCRIPT = @INSTALL_SCRIPT@
223223
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
224224
LDFLAGS = @LDFLAGS@
225+
LD_LIBCOM_ERR = @LD_LIBCOM_ERR@
226+
LD_LIBEXT2FS = @LD_LIBEXT2FS@
225227
LIBOBJS = @LIBOBJS@
226228
LIBS = @LIBS@
227229
LTLIBOBJS = @LTLIBOBJS@

aclocal.m4

+3-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
103103
# configured tree to be moved without reconfiguration.
104104

105105
AC_DEFUN([AM_AUX_DIR_EXPAND],
106-
[dnl Rely on autoconf to set up CDPATH properly.
107-
AC_PREREQ([2.50])dnl
108-
# expand $ac_aux_dir to an absolute path
109-
am_aux_dir=`cd $ac_aux_dir && pwd`
106+
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
107+
# Expand $ac_aux_dir to an absolute path.
108+
am_aux_dir=`cd "$ac_aux_dir" && pwd`
110109
])
111110

112111
# AM_CONDITIONAL -*- Autoconf -*-

configure

+27-17
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ ac_header_list=
626626
ac_subst_vars='am__EXEEXT_FALSE
627627
am__EXEEXT_TRUE
628628
LTLIBOBJS
629+
LD_LIBEXT2FS
630+
LD_LIBCOM_ERR
629631
LIBOBJS
630632
EGREP
631633
GREP
@@ -2514,8 +2516,8 @@ test "$program_suffix" != NONE &&
25142516
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
25152517
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
25162518
2517-
# expand $ac_aux_dir to an absolute path
2518-
am_aux_dir=`cd $ac_aux_dir && pwd`
2519+
# Expand $ac_aux_dir to an absolute path.
2520+
am_aux_dir=`cd "$ac_aux_dir" && pwd`
25192521
25202522
if test x"${MISSING+set}" != xset; then
25212523
case $am_aux_dir in
@@ -5003,6 +5005,8 @@ if test "x$ac_cv_lib_com_err_error_message" = xyes; then :
50035005
50045006
$as_echo "#define HAVE_LIBCOM_ERR 1" >>confdefs.h
50055007
5008+
LD_LIBCOM_ERR=-lcom_err
5009+
50065010
fi
50075011
50085012
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ext2fs_extent_replace in -lext2fs" >&5
@@ -5045,6 +5049,8 @@ if test "x$ac_cv_lib_ext2fs_ext2fs_extent_replace" = xyes; then :
50455049
50465050
$as_echo "#define HAVE_LIBEXT2FS 1" >>confdefs.h
50475051
5052+
LD_LIBEXT2FS=-lext2fs
5053+
50485054
fi
50495055
50505056
@@ -5099,26 +5105,30 @@ fi
50995105
51005106
51015107
5102-
ft_libs_missing=
5103-
for ft_lib in com_err_error_message ext2fs_ext2fs_extent_replace
5104-
do :
5105-
if test "`eval echo '$ac_cv_lib_'$ft_lib`" != "yes"
5106-
then
5107-
ft_libs_missing="${ft_libs_missing}lib$(echo $ft_lib | sed 's/_/:/')() "
5108-
fi
5109-
done
5110-
if test "x$ft_libs_missing" != "x"
5111-
then
5112-
as_fn_error $? "missing required library functions: $ft_libs_missing"
5113-
fi
5108+
if test "$ac_cv_func_fallocate" != "yes"
5109+
then
5110+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing function fallocate(), experimental files preallocation will NOT be compiled" >&5
5111+
$as_echo "$as_me: WARNING: missing function fallocate(), experimental files preallocation will NOT be compiled" >&2;}
51145112
5113+
elif test "$ac_cv_lib_com_err_error_message" != "yes"
5114+
then
5115+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing function error_message() in -lcom_err, experimental files preallocation will NOT be compiled" >&5
5116+
$as_echo "$as_me: WARNING: missing function error_message() in -lcom_err, experimental files preallocation will NOT be compiled" >&2;}
51155117
5116-
if test "$ac_cv_func_fallocate" != "yes"
5118+
elif test "$ac_cv_lib_ext2fs_ext2fs_extent_replace" != "yes"
51175119
then
5118-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing function fallocate(), preallocation speedup will NOT be compiled" >&5
5119-
$as_echo "$as_me: WARNING: missing function fallocate(), preallocation speedup will NOT be compiled" >&2;}
5120+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing function ext2fs_extent_replace() in -lext2fs, experimental files preallocation will NOT be compiled" >&5
5121+
$as_echo "$as_me: WARNING: missing function ext2fs_extent_replace() in -lext2fs, experimental files preallocation will NOT be compiled" >&2;}
5122+
5123+
else
5124+
5125+
$as_echo "#define HAVE_IO_PREALLOC 1" >>confdefs.h
5126+
5127+
{ $as_echo "$as_me:${as_lineno-$LINENO}: support for experimental files preallocation will be compiled" >&5
5128+
$as_echo "$as_me: support for experimental files preallocation will be compiled" >&6;}
51205129
fi
51215130
5131+
51225132
ac_config_files="$ac_config_files Makefile fsattr/build/Makefile fsremap/build/Makefile fsmove/build/Makefile fstransform/build/Makefile"
51235133
51245134
cat >confcache <<\_ACEOF

configure.ac

+19-4
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,36 @@ FT_CXX_STD_TR1_UNORDERED_MAP
7171

7272

7373
# Checks for libraries.
74-
AC_CHECK_LIB(com_err, error_message, [AC_DEFINE(HAVE_LIBCOM_ERR, 1, [Define to 1 if you have the com_err library.])])
75-
AC_CHECK_LIB(ext2fs, ext2fs_extent_replace, [AC_DEFINE(HAVE_LIBEXT2FS, 1, [Define to 1 if you have the ext2fs library.])])
74+
AC_CHECK_LIB(com_err, error_message, [AC_DEFINE(HAVE_LIBCOM_ERR, 1, [Define to 1 if you have the com_err library.])
75+
AC_SUBST(LD_LIBCOM_ERR, [-lcom_err])])
76+
AC_CHECK_LIB(ext2fs, ext2fs_extent_replace, [AC_DEFINE(HAVE_LIBEXT2FS, 1, [Define to 1 if you have the ext2fs library.])
77+
AC_SUBST(LD_LIBEXT2FS, [-lext2fs])])
7678

7779
FT_NEED_ALL_FUNCS([execvp fileno ftruncate memmove memset mkdir mkfifo msync munmap \
7880
remove strerror strftime sync time waitpid])
7981
FT_NEED_ANY_FUNC([localtime_r localtime])
8082
FT_NEED_ANY_FUNC([lchown chown])
8183

82-
FT_NEED_ALL_LIBS([com_err_error_message ext2fs_ext2fs_extent_replace])
84+
dnl FT_NEED_ALL_LIBS([com_err_error_message ext2fs_ext2fs_extent_replace])
8385

8486
if test "$ac_cv_func_fallocate" != "yes"
8587
then
86-
AC_MSG_WARN([missing function fallocate(), preallocation speedup will NOT be compiled])
88+
AC_MSG_WARN([missing function fallocate(), experimental files preallocation will NOT be compiled])
89+
90+
elif test "$ac_cv_lib_com_err_error_message" != "yes"
91+
then
92+
AC_MSG_WARN([missing function error_message() in -lcom_err, experimental files preallocation will NOT be compiled])
93+
94+
elif test "$ac_cv_lib_ext2fs_ext2fs_extent_replace" != "yes"
95+
then
96+
AC_MSG_WARN([missing function ext2fs_extent_replace() in -lext2fs, experimental files preallocation will NOT be compiled])
97+
98+
else
99+
AC_DEFINE(HAVE_IO_PREALLOC, 1, [Define to 1 if "prealloc" I/O is supported"])
100+
AC_MSG_NOTICE([support for experimental files preallocation will be compiled])
87101
fi
88102

103+
89104
AC_CONFIG_FILES([Makefile fsattr/build/Makefile fsremap/build/Makefile fsmove/build/Makefile fstransform/build/Makefile])
90105
AC_OUTPUT
91106

fsattr/build/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
22

33
sbin_PROGRAMS = fsattr
44

5-
fsattr_LDADD = -lext2fs -lcom_err
5+
fsattr_LDADD = @LD_LIBEXT2FS@ @LD_LIBCOM_ERR@
66

77
fsattr_SOURCES = \
88
../src/e4attr.cc \

fsattr/build/Makefile.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
183183
INSTALL_SCRIPT = @INSTALL_SCRIPT@
184184
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
185185
LDFLAGS = @LDFLAGS@
186+
LD_LIBCOM_ERR = @LD_LIBCOM_ERR@
187+
LD_LIBEXT2FS = @LD_LIBEXT2FS@
186188
LIBOBJS = @LIBOBJS@
187189
LIBS = @LIBS@
188190
LTLIBOBJS = @LTLIBOBJS@
@@ -244,7 +246,7 @@ top_build_prefix = @top_build_prefix@
244246
top_builddir = @top_builddir@
245247
top_srcdir = @top_srcdir@
246248
AUTOMAKE_OPTIONS = subdir-objects
247-
fsattr_LDADD = -lext2fs -lcom_err
249+
fsattr_LDADD = @LD_LIBEXT2FS@ @LD_LIBCOM_ERR@
248250
fsattr_SOURCES = \
249251
../src/e4attr.cc \
250252
../src/log.cc \

fsattr/src/e4attr.cc

+17-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@
3939
# include <cstring> // for memcmp(), strncmp()
4040
#endif
4141

42-
#include <ext2fs/ext2fs.h>
42+
#if defined (FT_HAVE_EXT2FS_EXT2FS_H)
43+
# include <ext2fs/ext2fs.h>
44+
#endif
4345

44-
#include "log.hh"
46+
# include "log.hh"
4547

4648
FT_NAMESPACE_BEGIN
4749

50+
#if defined(FT_HAVE_LIBEXT2FS) && defined(FT_HAVE_LIBCOM_ERR)
51+
4852
typedef errcode_t e4_err;
4953
typedef ext2_filsys e4_fs;
5054
typedef ext2_ino_t e4_inum;
@@ -242,7 +246,6 @@ static int e4attr_usage(const char * program_name) {
242246
return 1;
243247
}
244248

245-
246249
int e4attr_main(int argc, char ** argv) {
247250
const char * program_name = argv[0], * dev_path = NULL;
248251
e4attr_extent_op apply_op = E4_EXTENT_UNKNOWN_OP;
@@ -281,10 +284,21 @@ int e4attr_main(int argc, char ** argv) {
281284
ff_log(FC_ERROR, 0, "%s: missing operation, please specify one of --files=normal or --files=prealloc", program_name);
282285
return e4attr_usage(program_name);
283286
}
287+
284288
e4_err err = ft::e4attr_run(dev_path, apply_op);
285289
return err != 0 ? 1 : 0;
286290
}
287291

292+
#else /* !(defined(FT_HAVE_LIBEXT2FS) && defined(FT_HAVE_LIBCOM_ERR)) */
293+
294+
int e4attr_main(int argc, char ** argv) {
295+
const char * program_name = argv[0];
288296

297+
ff_log(FC_ERROR, 0, "%s: this program is a NOT functional because it was compiled without -lext2fs -lcom_err", program_name);
298+
return 1;
299+
}
300+
301+
#endif /* defined(FT_HAVE_LIBEXT2FS) && defined(FT_HAVE_LIBCOM_ERR) */
302+
289303
FT_NAMESPACE_END
290304

fsmove/build/Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
190190
INSTALL_SCRIPT = @INSTALL_SCRIPT@
191191
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
192192
LDFLAGS = @LDFLAGS@
193+
LD_LIBCOM_ERR = @LD_LIBCOM_ERR@
194+
LD_LIBEXT2FS = @LD_LIBEXT2FS@
193195
LIBOBJS = @LIBOBJS@
194196
LIBS = @LIBS@
195197
LTLIBOBJS = @LTLIBOBJS@

fsremap/build/Makefile.am

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fsremap_SOURCES = \
1616
../src/io/io_null.cc \
1717
../src/io/io_posix.cc \
1818
../src/io/io_posix_dir.cc \
19+
../src/io/io_prealloc.cc \
1920
../src/io/io_self_test.cc \
2021
../src/io/io_test.cc \
2122
../src/io/persist.cc \
@@ -35,5 +36,3 @@ fsremap_SOURCES = \
3536
../src/ui/ui_tty.cc \
3637
../src/vector.cc \
3738
../src/work.cc
38-
39-
# ../src/io/io_prealloc.cc

fsremap/build/Makefile.in

+7-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ am_fsremap_OBJECTS = ../src/arch/mem.$(OBJEXT) \
104104
../src/io/extent_posix.$(OBJEXT) ../src/io/io.$(OBJEXT) \
105105
../src/io/io_null.$(OBJEXT) ../src/io/io_posix.$(OBJEXT) \
106106
../src/io/io_posix_dir.$(OBJEXT) \
107+
../src/io/io_prealloc.$(OBJEXT) \
107108
../src/io/io_self_test.$(OBJEXT) ../src/io/io_test.$(OBJEXT) \
108109
../src/io/persist.$(OBJEXT) ../src/io/util_dir.$(OBJEXT) \
109110
../src/io/util_posix.$(OBJEXT) ../src/job.$(OBJEXT) \
@@ -199,6 +200,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
199200
INSTALL_SCRIPT = @INSTALL_SCRIPT@
200201
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
201202
LDFLAGS = @LDFLAGS@
203+
LD_LIBCOM_ERR = @LD_LIBCOM_ERR@
204+
LD_LIBEXT2FS = @LD_LIBEXT2FS@
202205
LIBOBJS = @LIBOBJS@
203206
LIBS = @LIBS@
204207
LTLIBOBJS = @LTLIBOBJS@
@@ -274,6 +277,7 @@ fsremap_SOURCES = \
274277
../src/io/io_null.cc \
275278
../src/io/io_posix.cc \
276279
../src/io/io_posix_dir.cc \
280+
../src/io/io_prealloc.cc \
277281
../src/io/io_self_test.cc \
278282
../src/io/io_test.cc \
279283
../src/io/persist.cc \
@@ -414,6 +418,8 @@ clean-sbinPROGRAMS:
414418
../src/io/$(DEPDIR)/$(am__dirstamp)
415419
../src/io/io_posix_dir.$(OBJEXT): ../src/io/$(am__dirstamp) \
416420
../src/io/$(DEPDIR)/$(am__dirstamp)
421+
../src/io/io_prealloc.$(OBJEXT): ../src/io/$(am__dirstamp) \
422+
../src/io/$(DEPDIR)/$(am__dirstamp)
417423
../src/io/io_self_test.$(OBJEXT): ../src/io/$(am__dirstamp) \
418424
../src/io/$(DEPDIR)/$(am__dirstamp)
419425
../src/io/io_test.$(OBJEXT): ../src/io/$(am__dirstamp) \
@@ -498,6 +504,7 @@ distclean-compile:
498504
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_null.Po@am__quote@
499505
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_posix.Po@am__quote@
500506
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_posix_dir.Po@am__quote@
507+
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_prealloc.Po@am__quote@
501508
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_self_test.Po@am__quote@
502509
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/io_test.Po@am__quote@
503510
@AMDEP_TRUE@@am__include@ @am__quote@../src/io/$(DEPDIR)/persist.Po@am__quote@
@@ -734,8 +741,6 @@ uninstall-am: uninstall-sbinPROGRAMS
734741
tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS
735742

736743

737-
# ../src/io/io_prealloc.cc
738-
739744
# Tell versions [3.59,3.63) of GNU make to not export all variables.
740745
# Otherwise a system limit (for SysV at least) may be exceeded.
741746
.NOEXPORT:

fsremap/src/cache/cache.hh

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,22 @@ public:
6666
* if cached inode found, set payload and return 1.
6767
* Otherwise add it to cache and return 0.
6868
* On error, return < 0.
69-
* if returns 0, erase() must be called on the same inode when done with payload!
69+
* if returns 0, find_and_delete() must be called on the same inode when done with payload!
7070
*/
7171
virtual int find_or_add(const K key, V & inout_payload) = 0;
7272

7373
/**
74-
* if cached inode found, set payload, remove inode from cache and return 1.
74+
* if cached inode found, set result_payload, remove inode from cache and return 1.
7575
* Otherwise return 0. On error, return < 0.
7676
*/
7777
virtual int find_and_delete(const K key, V & result_payload) = 0;
7878

79+
/**
80+
* if cached inode found, change its payload and return 1.
81+
* Otherwise return 0. On error, return < 0.
82+
*/
83+
virtual int find_and_update(const K key, const V & new_payload) = 0;
84+
7985
virtual void clear() = 0;
8086
};
8187

fsremap/src/cache/cache_adaptor.hh

+15
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ public:
104104
return err;
105105
}
106106

107+
/**
108+
* if cached inode found, change its payload and return 1.
109+
* Otherwise return 0. On error, return < 0.
110+
*/
111+
virtual int find_and_update(const K key, const V & new_payload)
112+
{
113+
mixin_key_type m_key;
114+
ff_set(m_key, key);
115+
116+
mixin_payload_type m_payload;
117+
ff_set(m_payload, new_payload);
118+
119+
return mixin_type::find_and_update(m_key, m_payload);
120+
}
121+
107122
virtual void clear()
108123
{
109124
mixin_type::clear();

0 commit comments

Comments
 (0)