tdb_check fails with tdb read-only open.
Rusty Russell
rusty at rustcorp.com.au
Mon Sep 13 17:51:51 MDT 2010
On Tue, 14 Sep 2010 03:15:30 am Jeremy Allison wrote:
> On Mon, Sep 13, 2010 at 05:20:50PM +0930, Rusty Russell wrote:
> > On Thu, 29 Jul 2010 07:35:13 am tridge at samba.org wrote:
> > > looks good to me - nice and simple :-)
> >
> > And unfortunately, doesn't work.
> >
> > I just got around to porting this to CCAN, and added a unit test for it.
> >
> > tdb_lockall_read() fails on r/o TDBs. So that needs to be fixed too. You
>
> How does this fail ? As far as I can see it
> only does F_RDLCK calls on the db - shouldn't
> that always succeed against a r/o fd ? Just trying
> to understand the error.
I missed it too; it's in tdb_allrecord_check:
int tdb_lockall_read(struct tdb_context *tdb)
{
tdb_trace(tdb, "tdb_lockall_read");
return tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false);
}
Here's tdb_allrecord_lock:
int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
enum tdb_lock_flags flags, bool upgradable)
{
switch (tdb_allrecord_check(tdb, ltype, flags, upgradable)) {
case -1:
return -1;
case 0:
return 0;
}
...
And here's tdb_allrecord_check:
static int tdb_allrecord_check(struct tdb_context *tdb, int ltype,
enum tdb_lock_flags flags, bool upgradable)
{
/* There are no locks on read-only dbs */
if (tdb->read_only || tdb->traverse_read) {
tdb->ecode = TDB_ERR_LOCK;
return -1;
}
...
I'd forgotten this feature of read-only TDBs; they use no locks *at all*.
I added a unit test. Unfortunately the unit tests are in the CCAN version
of tdb; fortunately I keep them in sync so we benefit in SAMBA.
> > Patch coming...
>
> Doesn't your patch still leave the F_WRLCK code
> inside tdb_lock_and_recover() ?
Yes, but we can never get there (and if we did, it'd fail as expected).
Cheers,
Rusty.
More information about the samba-technical
mailing list