loadparm in Samba4

tridge at samba.org tridge at samba.org
Sat Sep 16 15:17:22 GMT 2006


Simo,

I hit a snag with the new parameter handling code in Samba4. A lot of
hosts in the build farm are currently failing the test_simple.sh test
(which tests BASE-RW1 against the simple ntvfs backend), because the
CHECK_READ_ONLY() check in each function in that backend is returning
'true', even though we have 'read only = no' in smb.conf.

It turned out that the problem was the change to a real bool type, and
the call to set_boolean() in loadparm.c. On big-endian hosts where
sizeof(int) != sizeof(BOOL) it broke. It should be fixed now.

Anyway, this prompted me to take a closer look at the new share
parameter code, and I'm concerned about the speed.

In the old code, doing something like lp_readonly() involved maybe a
couple of dozen machine instructions. It was just a function call and
a pointer defer to return an integer. Very fast!

In the new code, the CHECK_READ_ONLY() test does the following:

 - deref two pointers in getting ntvfs->ctx->config
 - deref 3 more pointers in getting to scfg->ctx->ops->bool_option()
 - 1 strchr() call to look for a ':'
 - 3 strcmp calls to find the lp_readonly() function
 - finally the dereference is done

this is way too slow! 

If we convert all our code to preload parameters the way the posix
backend does (filling in pvfs_setup_options()) then the speed is OK,
but I think we still have a lot of places where we do simple loadparm
checks at runtime. Innocuous looking macros like CHECK_READ_ONLY() in
the simple backend now expand to some very slow code.

I think we need to either make these common calls much faster, or make
a concerted effort to get rid of any frequent calls to loadparm
functions. 

Cheers, Tridge



More information about the samba-technical mailing list