Hi,
I am attaching a new patch, which:
- Add the files fs/Module.cc,h similar to esi/Module.cc
- Build a new library libfs.a
- The fs/aufs/StoreFSaufs.cc, fs/diskd/StoreFSdiskd.cc and
fs/ufs/StoreFSufs.cc now contain just fake pointers
- The FS::Init() method used to build ufs, aufs and diskd filesystems.
- The FS::Init method called in main.cc before the code which reads
the config files. The FS::clean() currently does not used.
- I left the old way initiating the coss filesystem. I did not want to
touch it, because currently does not used. I think the correct way, is
to (a) remove the StoreFScoss::GetInstance method, (b) declare the
StoreFScoss::stats as static and (c) merge the StoreFScoss::stat()
method with the static StoreFScoss::Stats()
Regards,
Christos
Alex Rousskov wrote:
On 03/29/2009 08:22 PM, Alex Rousskov wrote:
...................
Can you move FsReg.cc to fs/Regs.cc?
I am guessing you cannot move it "as is" because the code will be thrown
away by the linker. If you are adding the Regs file, it would be nice to
convert this to direct initialization and place into fs directory,
similar to how esi/Module.cc does it. Perhaps the result should be
called fs/Modules.cc then.
ACLs should probably do the same, but it is more work because there are
so many of them. Let's try not to take shortcuts where the proper
implementation is simple though.
Thank you,
Alex.
=== modified file 'configure.in'
--- configure.in 2009-03-29 07:13:39 +0000
+++ configure.in 2009-03-30 21:49:46 +0000
@@ -509,6 +509,12 @@
STORE_TESTS="$STORE_TESTS tests/testUfs$EXEEXT"
fi
+AH_TEMPLATE(HAVE_FS_UFS, "Define to 1 if ufs filesystem module is build")
+AH_TEMPLATE(HAVE_FS_AUFS, "Define to 1 if aufs filesystem module is build")
+AH_TEMPLATE(HAVE_FS_DISKD, "Define to 1 if diskd filesystem module is build")
+AH_TEMPLATE(HAVE_FS_COSS, "Define to 1 if coss filesystem module is build")
+
+
dnl got final STORE_MODULES, build library lists
dnl This list will not be needed when each fs library has its own Makefile
STORE_LIBS_TO_BUILD=
@@ -516,8 +522,10 @@
dnl These are the same as STORE_LIBS_TO_BUILD, but with a path
STORE_LIBS_TO_ADD=
for fs in $STORE_MODULES; do
- STORE_LIBS_TO_BUILD="$STORE_LIBS_TO_BUILD lib${fs}.a"
- STORE_LIBS_TO_ADD="$STORE_LIBS_TO_ADD fs/lib${fs}.a"
+ STORE_LIBS_TO_BUILD="$STORE_LIBS_TO_BUILD lib${fs}.la"
+ STORE_LIBS_TO_ADD="$STORE_LIBS_TO_ADD fs/lib${fs}.la"
+ HAVE_FS_TYPE=HAVE_FS_`echo $fs | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ AC_DEFINE_UNQUOTED($HAVE_FS_TYPE, 1)
done
AC_SUBST(STORE_LIBS_TO_BUILD)
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-03-28 17:41:32 +0000
+++ src/Makefile.am 2009-03-30 21:47:47 +0000
@@ -168,7 +168,8 @@
auth/libauth.la \
acl/libapi.la \
base/libbase.la \
- ip/libip.la
+ ip/libip.la \
+ fs/libfs.la
INCLUDES = \
-I$(top_srcdir) \
@@ -532,7 +533,6 @@
@XTRA_OBJS@ \
@DISK_LINKOBJS@ \
@REPL_OBJS@ \
- @STORE_LIBS_TO_ADD@ \
@DISK_LIBS@ \
@CRYPTLIB@ \
@REGEXLIB@ \
@@ -545,7 +545,6 @@
@EPOLL_LIBS@ \
@MINGW_LIBS@
squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
- @STORE_LIBS_TO_ADD@ \
@DISK_LIBS@ \
@DISK_LINKOBJS@ \
@REPL_OBJS@ \
@@ -613,7 +612,6 @@
$(COMMON_LIBS) \
@XTRA_OBJS@ \
@REPL_OBJS@ \
- @STORE_LIBS_TO_ADD@ \
@CRYPTLIB@ \
@REGEXLIB@ \
@SNMPLIB@ \
@@ -623,7 +621,7 @@
@EPOLL_LIBS@ \
@MINGW_LIBS@
ufsdump_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
- @STORE_LIBS_TO_ADD@ \
+ $(COMMON_LIBS) \
@DISK_LIBS@ \
@DISK_LINKOBJS@ \
@REPL_OBJS@
@@ -1595,7 +1593,6 @@
$(COMMON_LIBS) \
icmp/libicmp.la icmp/libicmp-core.la \
@REPL_OBJS@ \
- @STORE_LIBS_TO_ADD@ \
${ADAPTATION_LIBS} \
${ESI_LIBS} \
@REGEXLIB@ \
@@ -1895,7 +1892,7 @@
SWAP_TEST_LDADD = \
@REGEXLIB@ \
- @STORE_LIBS_TO_ADD@ \
+ $(COMMON_LIBS) \
@REPL_OBJS@ \
@DISK_LIBS@ \
-L../lib -lmiscutil \
@@ -1905,7 +1902,7 @@
$(top_builddir)/lib/libmiscutil.a \
repl_modules.o \
@DISK_LIBS@ \
- @STORE_LIBS_TO_ADD@ \
+ $(COMMON_LIBS) \
@REPL_OBJS@ \
@SQUID_CPPUNIT_LA@
=== modified file 'src/fs/Makefile.am'
--- src/fs/Makefile.am 2009-02-25 20:35:16 +0000
+++ src/fs/Makefile.am 2009-03-30 22:00:06 +0000
@@ -1,20 +1,20 @@
include $(top_srcdir)/src/Common.am
-EXTRA_LIBRARIES = libaufs.a libdiskd.a libcoss.a libufs.a
-noinst_LIBRARIES = @STORE_LIBS_TO_BUILD@
+EXTRA_LTLIBRARIES = libaufs.la libdiskd.la libcoss.la libufs.la
+noinst_LTLIBRARIES = @STORE_LIBS_TO_BUILD@ libfs.la
## TODO: add libfs -- file system framework; this library is always built
## TODO: use libtool and add @STORE_LIBS_TO_BUILD@ to libfs.la
# aufs is a "fake" legacy store
-libaufs_a_SOURCES = \
+libaufs_la_SOURCES = \
aufs/StoreFSaufs.cc
# diskd is a "fake" legacy store
-libdiskd_a_SOURCES = \
+libdiskd_la_SOURCES = \
diskd/StoreFSdiskd.cc
-libcoss_a_SOURCES = \
+libcoss_la_SOURCES = \
coss/StoreFScoss.h \
coss/StoreFScoss.cc \
coss/store_coss.h \
@@ -22,7 +22,7 @@
coss/store_dir_coss.cc \
coss/CossSwapDir.h
-libufs_a_SOURCES = \
+libufs_la_SOURCES = \
ufs/StoreFSufs.h \
ufs/StoreFSufs.cc \
ufs/store_dir_ufs.cc \
@@ -31,6 +31,8 @@
ufs/ufscommon.cc \
ufs/ufscommon.h
+libfs_la_SOURCES = Module.c
+libfs_la_LIBADD = @STORE_LIBS_TO_BUILD@
EXTRA_DIST = \
coss/coss-notes.txt
@@ -56,7 +58,7 @@
CLEANFILES += testHeaders.c
## targets below to emulate distributed makefiles
-coss/all: libcoss.a
+coss/all: libcoss.la
coss/clean: clean
-ufs/all: libufs.a
+ufs/all: libufs.la
ufs/clean: clean
=== added file 'src/fs/Module.cc'
--- src/fs/Module.cc 1970-01-01 00:00:00 +0000
+++ src/fs/Module.cc 2009-03-30 21:10:26 +0000
@@ -0,0 +1,65 @@
+#include "squid.h"
+#include "Module.h"
+#if defined(HAVE_FS_UFS) || defined(HAVE_FS_AUFS) || defined(HAVE_FS_DISKD)
+#include "fs/ufs/StoreFSufs.h"
+#include "fs/ufs/ufscommon.h"
+#endif
+
+#ifdef HAVE_FS_COSS
+#include "fs/coss/StoreFScoss.h"
+#endif
+
+#ifdef HAVE_FS_UFS
+static StoreFSufs<UFSSwapDir> *UfsInstance;
+#endif
+
+#ifdef HAVE_FS_AUFS
+static StoreFSufs<UFSSwapDir> *AufsInstance;
+#endif
+
+
+#ifdef HAVE_FS_DISKD
+static StoreFSufs<UFSSwapDir> *DiskdInstance;
+#endif
+
+#ifdef HAVE_FS_COSS
+ StoreFScoss &CossInstance = StoreFScoss::GetInstance();
+#endif
+
+
+void FS::Init() {
+
+#ifdef HAVE_FS_UFS
+ UfsInstance = new StoreFSufs<UFSSwapDir>("Blocking", "ufs");
+#endif
+
+#ifdef HAVE_FS_AUFS
+ AufsInstance = new StoreFSufs<UFSSwapDir>("DiskThreads", "aufs");;
+#endif
+
+
+#ifdef HAVE_FS_DISKD
+ DiskdInstance = new StoreFSufs<UFSSwapDir>("DiskDaemon", "diskd");;
+#endif
+
+}
+
+
+void FS::Clean() {
+#ifdef HAVE_FS_UFS
+ assert(UfsInstance);
+ delete UfsInstance;
+#endif
+
+#ifdef HAVE_FS_AUFS
+ assert(AufsInstance);
+ delete AufsInstance;
+#endif
+
+
+#ifdef HAVE_FS_DISKD
+ assert(DiskdInstance);
+ delete DiskdInstance;
+#endif
+
+}
=== added file 'src/fs/Module.h'
--- src/fs/Module.h 1970-01-01 00:00:00 +0000
+++ src/fs/Module.h 2009-03-30 17:55:35 +0000
@@ -0,0 +1,11 @@
+#ifndef SQUID_FS_MODULE_H
+#define SQUID_FS_MODULE_H
+
+namespace FS {
+
+ extern void Init();
+ extern void Clean();
+
+}; // namespace FS
+
+#endif /* SQUID_FS_MODULE_H */
=== modified file 'src/fs/aufs/StoreFSaufs.cc'
--- src/fs/aufs/StoreFSaufs.cc 2009-01-21 03:47:47 +0000
+++ src/fs/aufs/StoreFSaufs.cc 2009-03-30 20:01:28 +0000
@@ -51,4 +51,5 @@
*/
/// \ingroup AUFS
-static StoreFSufs<UFSSwapDir> AufsInstance("DiskThreads", "aufs");
+//static StoreFSufs<UFSSwapDir> AufsInstance("DiskThreads", "aufs");
+StoreFSufs<UFSSwapDir> *AufsInstance_foo = NULL;
=== modified file 'src/fs/diskd/StoreFSdiskd.cc'
--- src/fs/diskd/StoreFSdiskd.cc 2009-01-21 03:47:47 +0000
+++ src/fs/diskd/StoreFSdiskd.cc 2009-03-30 20:01:16 +0000
@@ -49,4 +49,5 @@
*/
/// \ingroup diskd
-static StoreFSufs<UFSSwapDir> DiskdInstance("DiskDaemon", "diskd");
+//static StoreFSufs<UFSSwapDir> DiskdInstance("DiskDaemon", "diskd");
+StoreFSufs<UFSSwapDir> *DiskdInstance_foo = NULL;
=== modified file 'src/fs/ufs/StoreFSufs.cc'
--- src/fs/ufs/StoreFSufs.cc 2009-01-21 03:47:47 +0000
+++ src/fs/ufs/StoreFSufs.cc 2009-03-30 20:00:55 +0000
@@ -46,5 +46,6 @@
/** \todo FIXME: break UFSSwapDir out so we don't build all the extras */
#include "fs/ufs/ufscommon.h"
-static StoreFSufs<UFSSwapDir> UfsInstance("Blocking", "ufs");
+//static StoreFSufs<UFSSwapDir> UfsInstance("Blocking", "ufs");
+StoreFSufs<UFSSwapDir> *UfsInstance_foo = NULL;
=== modified file 'src/main.cc'
--- src/main.cc 2009-03-17 16:57:05 +0000
+++ src/main.cc 2009-03-30 20:49:02 +0000
@@ -90,6 +90,8 @@
#include "esi/Module.h"
#endif
+#include "fs/Module.h"
+
#if USE_WIN32_SERVICE
#include "squid_windows.h"
@@ -1226,6 +1228,7 @@
Mem::Init();
storeFsInit(); /* required for config parsing */
+ FS::Init();
/* May not be needed for parsing, have not audited for such */
DiskIOModule::SetupAllModules();