Patch
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Nov 28 02:10:04 MST 2012
Hi!
The attached patch converts fetch_share_mode_unlocked to
dbwrap_parse_record. I can't measure how much it gains in
performance. But fetch_share_mode_unlocked is used heavily
in traverse due to the call in get_file_infos, and
malloc/free/talloc_free shows up in profiles. So I think it
is worthwhile to reduce the number of tallocs where it is as
easy as it is with this patch.
If someone feels like it, please push.
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From ceffaf513e85389aba2e0ec478cf4914e064d1c4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 27 Nov 2012 15:40:06 +0100
Subject: [PATCH] s3: Use dbwrap_parse_record in fetch_share_mode_unlocked
---
source3/locking/share_mode_lock.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index a82c44e..4f26099 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -389,6 +389,15 @@ fail:
return NULL;
}
+static void fetch_share_mode_unlocked_parser(
+ TDB_DATA key, TDB_DATA data, void *private_data)
+{
+ struct share_mode_lock *lck = talloc_get_type_abort(
+ private_data, struct share_mode_lock);
+
+ lck->data = parse_share_modes(lck, data);
+}
+
/*******************************************************************
Get a share_mode_lock without locking the database or reference
counting. Used by smbstatus to display existing share modes.
@@ -400,25 +409,17 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
struct share_mode_lock *lck;
struct file_id tmp;
TDB_DATA key = locking_key(&id, &tmp);
- TDB_DATA data;
NTSTATUS status;
- status = dbwrap_fetch(lock_db, talloc_tos(), key, &data);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("Could not fetch share entry\n"));
- return NULL;
- }
- if (data.dptr == NULL) {
- return NULL;
- }
lck = talloc(mem_ctx, struct share_mode_lock);
if (lck == NULL) {
- TALLOC_FREE(data.dptr);
+ DEBUG(0, ("talloc failed\n"));
return NULL;
}
- lck->data = parse_share_modes(lck, data);
- TALLOC_FREE(data.dptr);
- if (lck->data == NULL) {
+ status = dbwrap_parse_record(
+ lock_db, key, fetch_share_mode_unlocked_parser, lck);
+ if (!NT_STATUS_IS_OK(status) ||
+ (lck->data == NULL)) {
TALLOC_FREE(lck);
return NULL;
}
--
1.7.9.5
More information about the samba-technical
mailing list