From 738b2abe784bc38bdaf1abc913a401e0e732e188 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Mon, 31 Jan 2011 20:20:24 +0300 Subject: s4: Don't grant level II oplock to a file with byte-range locks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Shilovsky Signed-off-by: Matthias Dieter Wallnöfer Reviewed-by: Stefan Metzmacher Autobuild-User: Matthias Dieter Wallnöfer Autobuild-Date: Tue Feb 15 11:09:17 CET 2011 on sn-devel-104 --- source4/ntvfs/common/brlock_tdb.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/common/brlock_tdb.c') diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c index df95d4c4c6..07e7c1aa5c 100644 --- a/source4/ntvfs/common/brlock_tdb.c +++ b/source4/ntvfs/common/brlock_tdb.c @@ -738,6 +738,32 @@ static NTSTATUS brl_tdb_close(struct brl_context *brl, return status; } +static NTSTATUS brl_tdb_count(struct brl_context *brl, struct brl_handle *brlh, + int *count) +{ + TDB_DATA kbuf, dbuf; + + kbuf.dptr = brlh->key.data; + kbuf.dsize = brlh->key.length; + *count = 0; + + if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + dbuf = tdb_fetch(brl->w->tdb, kbuf); + if (!dbuf.dptr) { + tdb_chainunlock(brl->w->tdb, kbuf); + return NT_STATUS_OK; + } + + *count = dbuf.dsize / sizeof(struct lock_struct); + + free(dbuf.dptr); + tdb_chainunlock(brl->w->tdb, kbuf); + + return NT_STATUS_OK; +} static const struct brlock_ops brlock_tdb_ops = { .brl_init = brl_tdb_init, @@ -746,7 +772,8 @@ static const struct brlock_ops brlock_tdb_ops = { .brl_unlock = brl_tdb_unlock, .brl_remove_pending = brl_tdb_remove_pending, .brl_locktest = brl_tdb_locktest, - .brl_close = brl_tdb_close + .brl_close = brl_tdb_close, + .brl_count = brl_tdb_count }; -- cgit