Bug 10781 - smbstatus: locking.tdb - TDB_MUTEX_LOCKING requires TDB_CLEAR_IF_FIRST
Summary: smbstatus: locking.tdb - TDB_MUTEX_LOCKING requires TDB_CLEAR_IF_FIRST
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Stefan Metzmacher
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on: 10974
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-25 13:00 UTC by Stefan Metzmacher
Modified: 2014-12-04 08:09 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Metzmacher 2014-08-25 13:00:41 UTC
smbstatus gives the following, when using dbwrap_tdb_mutexes:* = yes

tdb(/usr/local/samba/var/lock/locking.tdb): tdb_open_ex: invalid flags for /usr/local/samba/var/lock/locking.tdb - TDB_MUTEX_LOCKING requires TDB_CLEAR_IF_FIRST
/usr/local/samba/var/lock/locking.tdb not initialised
This is normal if an SMB client has never connected to your server.

TDB_MUTEX_LOCKING doesn't work together with O_RDONLY as that
clears the TDB_CLEAR_IF_FIRST flag.

The problem is located in source3/utils/status.c

                db = db_open(NULL, lock_path("locking.tdb"), 0,
                             TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0,
                             DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);

And in locking_init_readonly() => locking_init_internal()
and brl_init().

A possible fix would be to skip TDB_MUTEX_LOCKING, when using
O_RDONLY, as O_RDONLY also implies TDB_NOLOCK, which allows
a tdb created with mutexes to be read.
Comment 1 Karolin Seeger 2014-11-27 10:58:35 UTC
Is this a showstopper for 4.2.0?
Comment 2 Stefan Metzmacher 2014-11-27 10:59:40 UTC
This is fixed in master, I'll propose the backport shortly.
Comment 3 Jelmer Vernooij 2014-12-01 22:42:54 UTC
The test for this is breaking for me on Debian unstable:

tdb1-run-mutex-openflags2 failed:
.......TDB_MUTEX_LOCKING with O_RDONLY should fail with EINVAL - 22/0

apparently this is because the return value is non-NULL
Comment 4 Stefan Metzmacher 2014-12-04 08:09:23 UTC
fixed in tdb-1.3.3