[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Sun Jun 3 13:09:04 MDT 2012
The branch, master has been updated
via abcd095 s3:smbd/close: call del_share_mode() directly before TALLOC_FREE(lck)
via f66d88d s3:smbd/close: remove unused goto out from close_directory()
via 8751c3f s3:smbd/close: do an early return in close_directory()
via d792f59 s3: Fix an assert to trigger in close_remove_share_mode
via b9e11bd s3: Do an early return in close_remove_share_mode
via 2e95b77 s3: Make close_remove_share_mode a bit more readable
via dec08b8 s3: Simplify get_delete_on_close_token more
via 103b89f s3: Simplify get_delete_on_close_token slightly
via 8541829 s3: Slightly simplify close_remove_share_mode
via 8486d51 s3:smbd/close: avoid procid_is_me()
via 85e6dcf s3:smbd/open: avoid procid_is_me()
via 9dba59d s3:smbd/oplock: avoid procid_is_me()
from ad26c2a build: Match autoconf build and disable ACLs on MacOS (darwin)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit abcd095847c7438c3be39f6c9200a04c90394ed6
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jun 2 14:06:29 2012 +0200
s3:smbd/close: call del_share_mode() directly before TALLOC_FREE(lck)
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Sun Jun 3 21:08:19 CEST 2012 on sn-devel-104
commit f66d88d10afff65d743663b2e27a94271225b229
Author: Stefan Metzmacher <metze at samba.org>
Date: Sun Jun 3 15:17:29 2012 +0200
s3:smbd/close: remove unused goto out from close_directory()
metze
commit 8751c3f2ef5700c4b317bfecf0e68facf09c6c1e
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jun 2 14:04:52 2012 +0200
s3:smbd/close: do an early return in close_directory()
metze
commit d792f59aeb4e74ea14d3c5979addd31b78b1a2d9
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jun 1 16:29:51 2012 +0200
s3: Fix an assert to trigger in close_remove_share_mode
In case we have a left-over entry in the share mode entry array,
the SMB_ASSERT(got_tokens) is likely to kick in. It happens when
we are about to delete a file with initial delete on close. We don't
have a delete on close token set in the locking.tdb record. We see
the fsp->initial_delete_on_close set, add the delete_on_close token
to lck. Then "delete_file" is being set to true. Then later on we
do the notify_deferred_opens. This walks the list, also checking
for share_mode_stale_pid. We have already deleted our own share
mode entry, share_mode_stale_pid() sees the left-over entry. It not
also deletes that one but also the delete on close token. This leads
to a different view of "delete_file" a.k.a. "got_tokens" further
down in close_remove_share_mode, leading the SMB_ASSERT to fire.
This patch attempts to fix the issue by keeping around our own share
mode entry for almost the whole routine, preventing share_mode_stale_pid()
from removing the delete tokens.
Pair-Programmed-With: Volker Lendecke <vl at samba.org>
commit b9e11bd63ee6e1f1aac8d3b8a61ef0a4734cdd98
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 1 16:42:29 2012 +0200
s3: Do an early return in close_remove_share_mode
Without "lck" we don't have much to clean up
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 2e95b77c993045cb448d36240ea38b44b5418c7e
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 1 16:13:22 2012 +0200
s3: Make close_remove_share_mode a bit more readable
by introducing a variable simplifying a boolean expression
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit dec08b8041c88211efa9efd190c3bb6b6946f599
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 1 15:52:14 2012 +0200
s3: Simplify get_delete_on_close_token more
All remaining callers actually want the token
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 103b89fb071966eb5ca135039249e5def5eb0250
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 1 15:50:39 2012 +0200
s3: Simplify get_delete_on_close_token slightly
Introduce find_delete_on_close_token. Thus is_delete_on_close_set
does not have to call get_delete_on_close_token anymore.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 8541829a9ab20c7fa8c892490284c31593eb2fb8
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jun 1 15:21:12 2012 +0200
s3: Slightly simplify close_remove_share_mode
Remove a level of indentation by more use of "continue;"
Signed-off-by: Stefan Metzmacher <metze at samba.org>
commit 8486d514f5c964b6c20c36f2e7938ad9cd943c70
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jun 2 13:42:09 2012 +0200
s3:smbd/close: avoid procid_is_me()
metze
commit 85e6dcf49c24510ac9c31d56e8d7d1873d9cc638
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jun 2 13:40:26 2012 +0200
s3:smbd/open: avoid procid_is_me()
metze
commit 9dba59d0269f617af02bdc681261436a96ec34d1
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jun 2 13:39:33 2012 +0200
s3:smbd/oplock: avoid procid_is_me()
metze
-----------------------------------------------------------------------
Summary of changes:
source3/locking/locking.c | 47 ++++++++++++++----------
source3/smbd/close.c | 87 +++++++++++++++++++++++++++++----------------
source3/smbd/open.c | 9 +++--
source3/smbd/oplock.c | 6 ++-
4 files changed, 93 insertions(+), 56 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 76c2bc7..5da7595 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1045,6 +1045,26 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
return True;
}
+static struct delete_token *find_delete_on_close_token(
+ struct share_mode_data *d, uint32_t name_hash)
+{
+ uint32_t i;
+
+ DEBUG(10, ("find_delete_on_close_token: name_hash = 0x%x\n",
+ (unsigned int)name_hash));
+
+ for (i=0; i<d->num_delete_tokens; i++) {
+ struct delete_token *dt = &d->delete_tokens[i];
+
+ DEBUG(10, ("find__delete_on_close_token: dt->name_hash = 0x%x\n",
+ (unsigned int)dt->name_hash ));
+ if (dt->name_hash == name_hash) {
+ return dt;
+ }
+ }
+ return NULL;
+}
+
/****************************************************************************
Return the NT token and UNIX token if there's a match. Return true if
found, false if not.
@@ -1055,31 +1075,20 @@ bool get_delete_on_close_token(struct share_mode_lock *lck,
const struct security_token **pp_nt_tok,
const struct security_unix_token **pp_tok)
{
- int i;
+ struct delete_token *dt;
- DEBUG(10,("get_delete_on_close_token: name_hash = 0x%x\n",
- (unsigned int)name_hash ));
-
- for (i=0; i<lck->data->num_delete_tokens; i++) {
- struct delete_token *dt = &lck->data->delete_tokens[i];
- DEBUG(10,("get_delete_on_close_token: dtl->name_hash = 0x%x\n",
- (unsigned int)dt->name_hash ));
- if (dt->name_hash == name_hash) {
- if (pp_nt_tok) {
- *pp_nt_tok = dt->delete_nt_token;
- }
- if (pp_tok) {
- *pp_tok = dt->delete_token;
- }
- return true;
- }
+ dt = find_delete_on_close_token(lck->data, name_hash);
+ if (dt == NULL) {
+ return false;
}
- return false;
+ *pp_nt_tok = dt->delete_nt_token;
+ *pp_tok = dt->delete_token;
+ return true;
}
bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash)
{
- return get_delete_on_close_token(lck, name_hash, NULL, NULL);
+ return find_delete_on_close_token(lck->data, name_hash) != NULL;
}
bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 4b7f694..1fb7bde 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -170,6 +170,7 @@ static int compare_share_mode_times(const void *p1, const void *p2)
static void notify_deferred_opens(struct smbd_server_connection *sconn,
struct share_mode_lock *lck)
{
+ struct server_id self = messaging_server_id(sconn->msg_ctx);
uint32_t i, num_deferred;
struct share_mode_entry *deferred;
@@ -231,7 +232,7 @@ static void notify_deferred_opens(struct smbd_server_connection *sconn,
for (i=0; i<num_deferred; i++) {
struct share_mode_entry *e = &deferred[i];
- if (procid_is_me(&e->pid)) {
+ if (procid_equal(&self, &e->pid)) {
/*
* We need to notify ourself to retry the open. Do
* this by finding the queued SMB record, moving it to
@@ -331,6 +332,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
enum file_close_type close_type)
{
connection_struct *conn = fsp->conn;
+ struct server_id self = messaging_server_id(conn->sconn->msg_ctx);
bool delete_file = false;
bool changed_user = false;
struct share_mode_lock *lck = NULL;
@@ -340,6 +342,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
const struct security_unix_token *del_token = NULL;
const struct security_token *del_nt_token = NULL;
bool got_tokens = false;
+ bool normal_close;
/* Ensure any pending write time updates are done. */
if (fsp->update_write_time_event) {
@@ -359,8 +362,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));
- status = NT_STATUS_INVALID_PARAMETER;
- goto done;
+ return NT_STATUS_INVALID_PARAMETER;
}
if (fsp->write_time_forced) {
@@ -385,12 +387,6 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
}
}
- if (!del_share_mode(lck, fsp)) {
- DEBUG(0, ("close_remove_share_mode: Could not delete share "
- "entry for file %s\n",
- fsp_str_dbg(fsp)));
- }
-
if (fsp->initial_delete_on_close &&
!is_delete_on_close_set(lck, fsp->name_hash)) {
bool became_user = False;
@@ -420,17 +416,26 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
POSIX delete now. */
for (i=0; i<lck->data->num_share_modes; i++) {
struct share_mode_entry *e = &lck->data->share_modes[i];
- if (is_valid_share_mode_entry(e) &&
- e->name_hash == fsp->name_hash) {
- if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
- continue;
- }
- if (share_mode_stale_pid(lck->data, i)) {
- continue;
- }
- delete_file = False;
- break;
+
+ if (!is_valid_share_mode_entry(e)) {
+ continue;
+ }
+ if (e->name_hash != fsp->name_hash) {
+ continue;
+ }
+ if (fsp->posix_open
+ && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
+ continue;
+ }
+ if (procid_equal(&self, &e->pid) &&
+ (e->share_file_id == fsp->fh->gen_id)) {
+ continue;
+ }
+ if (share_mode_stale_pid(lck->data, i)) {
+ continue;
}
+ delete_file = False;
+ break;
}
}
@@ -443,8 +448,16 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
* reference to a file.
*/
- if (!(close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) ||
- !delete_file) {
+ normal_close = (close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE);
+
+ if (!normal_close || !delete_file) {
+
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_remove_share_mode: Could not delete "
+ "share entry for file %s\n",
+ fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
return NT_STATUS_OK;
}
@@ -564,6 +577,11 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
pop_sec_ctx();
}
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_remove_share_mode: Could not delete share "
+ "entry for file %s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
if (delete_file) {
@@ -1029,6 +1047,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
enum file_close_type close_type)
{
+ struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx);
struct share_mode_lock *lck = NULL;
bool delete_dir = False;
NTSTATUS status = NT_STATUS_OK;
@@ -1045,13 +1064,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
if (lck == NULL) {
DEBUG(0, ("close_directory: Could not get share mode lock for "
"%s\n", fsp_str_dbg(fsp)));
- status = NT_STATUS_INVALID_PARAMETER;
- goto out;
- }
-
- if (!del_share_mode(lck, fsp)) {
- DEBUG(0, ("close_directory: Could not delete share entry for "
- "%s\n", fsp_str_dbg(fsp)));
+ return NT_STATUS_INVALID_PARAMETER;
}
if (fsp->initial_delete_on_close) {
@@ -1090,6 +1103,10 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
continue;
}
+ if (procid_equal(&self, &e->pid) &&
+ (e->share_file_id == fsp->fh->gen_id)) {
+ continue;
+ }
if (share_mode_stale_pid(lck->data, i)) {
continue;
}
@@ -1114,6 +1131,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
del_token->groups,
del_nt_token);
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_directory: Could not delete share entry for "
+ "%s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS)
@@ -1123,7 +1145,7 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("delete_all_streams failed: %s\n",
nt_errstr(status)));
- goto out;
+ return status;
}
}
@@ -1145,6 +1167,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_DELETE_PENDING);
}
} else {
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_directory: Could not delete share entry for "
+ "%s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
remove_pending_change_notify_requests_by_fid(
fsp, NT_STATUS_OK);
@@ -1164,8 +1191,6 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
close_filestruct(fsp);
file_free(req, fsp);
- out:
- TALLOC_FREE(lck);
if (NT_STATUS_IS_OK(status) && !NT_STATUS_IS_OK(status1)) {
status = status1;
}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 9042e90..17721c6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -894,9 +894,10 @@ static void validate_my_share_entries(struct smbd_server_connection *sconn,
int num,
struct share_mode_entry *share_entry)
{
+ struct server_id self = messaging_server_id(sconn->msg_ctx);
files_struct *fsp;
- if (!procid_is_me(&share_entry->pid)) {
+ if (!procid_equal(&self, &share_entry->pid)) {
return;
}
@@ -1335,6 +1336,7 @@ static void defer_open(struct share_mode_lock *lck,
struct smb_request *req,
struct deferred_open_record *state)
{
+ struct server_id self = messaging_server_id(req->sconn->msg_ctx);
int i;
/* Paranoia check */
@@ -1343,7 +1345,7 @@ static void defer_open(struct share_mode_lock *lck,
struct share_mode_entry *e = &lck->data->share_modes[i];
if (is_deferred_open_entry(e) &&
- procid_is_me(&e->pid) &&
+ procid_equal(&self, &e->pid) &&
(e->op_mid == req->mid)) {
DEBUG(0, ("Trying to defer an already deferred "
"request: mid=%llu, exiting\n",
@@ -1364,8 +1366,7 @@ static void defer_open(struct share_mode_lock *lck,
state->id, (char *)state, sizeof(*state))) {
exit_server("push_deferred_open_message_smb failed");
}
- add_deferred_open(lck, req->mid, request_time,
- messaging_server_id(req->sconn->msg_ctx), state->id);
+ add_deferred_open(lck, req->mid, request_time, self, state->id);
}
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 190a9d3..19886fc 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -494,6 +494,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
struct smbd_server_connection *sconn =
talloc_get_type_abort(private_data,
struct smbd_server_connection);
+ struct server_id self = messaging_server_id(sconn->msg_ctx);
struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
if (data->data == NULL) {
@@ -562,7 +563,7 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
/* Need to wait before sending a break
message if we sent ourselves this message. */
- if (procid_is_me(&src)) {
+ if (procid_equal(&self, &src)) {
wait_before_sending_break();
}
@@ -802,6 +803,7 @@ static void do_break_to_none(struct tevent_req *req)
{
struct break_to_none_state *state = tevent_req_callback_data(
req, struct break_to_none_state);
+ struct server_id self = messaging_server_id(state->sconn->msg_ctx);
bool ret;
int i;
struct share_mode_lock *lck;
@@ -873,7 +875,7 @@ static void do_break_to_none(struct tevent_req *req)
* Bugid #5980.
*/
- if (procid_is_me(&share_entry->pid)) {
+ if (procid_equal(&self, &share_entry->pid)) {
struct files_struct *cur_fsp =
initial_break_processing(state->sconn,
share_entry->id,
--
Samba Shared Repository
More information about the samba-cvs
mailing list