[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

spd_readdir progress report/questions



I've been trying to use Ted's spd_readdir.c to accelerate extremely slow
directory traversal on backup.  For some reason, using it seems to stop
the backup entirely.  I'm still investigating; I suspect it may be an
issue with use LD_PRELOAD with a program running as root (but not
setuid) when the library is not root.

1.  There was a missing #ifdef in the original code.  I have revised it
to be
#ifdef DEBUG
 	if (do_debug) {
	  int i;
	  printf("After sorting.\n");
	  for (i=0; i<dirstruct->num; i++)
	    printf("%lu %s\n", 
		   (unsigned long) dirstruct->dp[i].d_ino, dirstruct->dp[i].d_name);
	}
#endif

I commented out the #define DEBUG statement before building the module
I'm trying to load.  That was how I discovered the need to the guards
shown above.

2. I concocted the following Makefile:
SDIR = /usr/local/src/kernel/ext3-patch
#CFLAGS=-O0 -g
LDFLAGS=-ldl

go2:	tester libsd_readdir.so.1
	LD_LIBRARY_PATH=./ LD_PRELOAD=libsd_readdir.so.1 ./tester Makefile

tester:	tester.o

spd_readdir.o:	spd_readdir.c

tester.o:	tester.c

foo:	foo.o

foo.o:	foo.c

go:	libsd_readdir.so.1
	LD_LIBRARY_PATH=./ LD_PRELOAD=libsd_readdir.so.1 tar cf /dev/null
$(SDIR)

libsd_readdir.so.1: spd_readdir.c
	$(CC) -shared -fpic -o $@ $^ ${LDFLAGS}

clean:
	rm tester spd_readdir.o libsd_readdir.so.1

Peculiarly, when I didn't use the LDFLAGS argument for the
libsd_readdir.so.1 target, I seemed to be able to start the program, but
when I tried to stop it I got
# LD_LIBRARY_PATH=/usr/local/src/kernel/ext3-patch \
LD_PRELOAD=libsd_readdir.so.1 start-stop-daemon --stop -v \
--exec /usr/sbin/bacula-fd -- -c /etc/bacula/bacula-fd.conf \

start-stop-daemon: symbol lookup
error: /usr/local/src/kernel/ext3-patch/libsd_readdir.so.1: undefined
symbol: dlsym

tester is a little test program I wrote to verify I was picking up the
new code.  The test with tar (target go:) didn't show any acceleration,
but apparently tar doesn't use the right calls to benefit for the
library.

3. Originally I was concerned that environment variables set on the
command line for start-stop-daemon would not effect the executable.
However, it seems to work.  Using a non-root test program I was able to
echo the variables from the test program started via start-stop-daemon.
Also, the fact that the deamon (bacula-fd) stops working properly  shows
the outer variable setting is having some effect.

4. start-stop-daemon is part of Debian's infrastructure for launching
deamon processes.  bacula-fd is part of the backup system:
$ ls -l /usr/sbin/bacula-fd
-rwxr-xr-x 1 root root 347212 2008-04-15 14:19 /usr/sbin/bacula-fd
I believe this means it is not setuid; the docs say setuid programs have
a restricted interpretation of LD_PRELOAD.
The library I am loading is
$ ls -l /usr/local/src/kernel/ext3-patch/libsd_readdir*
-rwxr-xr-x 1 ross staff 9083 2008-05-17
23:56 /usr/local/src/kernel/ext3-patch/libsd_readdir.so.1

5. I have the source for bacula-fd.  However, I assume that if I simply
try to add spd_readdir.c to the build I will get multiply defined symbol
conflicts with the calls it shadows.

If anyone has any suggestions for how to make it work, or to diagnose
the problems, I'd love to hear them.

Thanks.
Ross Boylan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]