[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Sep 11 00:34:02 UTC 2019
The branch, master has been updated
via bdda10875ed s3:smbd: skip write-time fetching for directories.
via 436be09cfc1 smbd: Do boolean short-circuiting
via 5427f73af58 smbd: Use dbwrap_do_locked() in fd_close_posix()
via 4204ed2b82f smbd: Use dbwrap_do_locked() in add_fd_to_close_entry()
via 92c2a723b27 dbwrap: Initialize state in dbwrap_delete()
via b86df6d0591 lib: Remove an obsolete comment
via a9d09d4bddb smbd: Fix DBG typo in find_delete_on_close_token()
via 2448060072e smbd: Use file_id_str_buf() in close_remove_share_mode()
via c88cb0a13bf smbd: Use file_id_str_buf() in setup_poll_open()
via fd691fbc94c smbd: Use file_id_str_buf() in defer_open()
via bf2bf5b1448 smbstatus: Use file_id_str_buf() in print_brl()
via feccf9bb4f5 smbd: Use file_id_str_buf() in set_sticky_write_time()
via d9263473b07 smbd: Use file_id_str_buf() in share_mode_str()
via de8b93b4799 smbd: Use file_id_str_buf() in brl_cleanup_disconnected()
via 49d18bbf29d smbd: Use file_id_str_buf() in brl_get_locks()
via 7e70701ab0f vfs: Use file_id_str_buf() in xattr_tdb_setattr()
via 5ca021bd85d vfs: Use file_id_str_buf() in xattr_tdb_getattr()
via b09c216f5ae lib: Use file_id_str_buf() in file_id_string()
via 049b8833ae8 lib: Add file_id_str_buf()
via ba72d8231f8 lib: Properly #ifdef __LIB_FILE_ID_H__
from 95655fe683d vfs: restore stat fields in vfs_stat_fsp()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bdda10875ed1a21a66829206c77a1ffd998c9569
Author: Ralph Boehme <slow at samba.org>
Date: Mon Sep 2 12:21:56 2019 +0200
s3:smbd: skip write-time fetching for directories.
The whole logic only applies to files.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Sep 11 00:33:26 UTC 2019 on sn-devel-184
commit 436be09cfc17bcd26ae438608749a1d47acc1954
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 9 10:42:59 2019 +0200
smbd: Do boolean short-circuiting
&= does bitwise AND, and does not do boolean short-circuiting if the
variable is already 0. As has_other_nonposix_opens() might have its
cost, this speeds up closing a handle.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5427f73af58252f6aabb044dac267c799ec26eb6
Author: Volker Lendecke <vl at samba.org>
Date: Mon Aug 26 16:22:23 2019 +0200
smbd: Use dbwrap_do_locked() in fd_close_posix()
We don't need to make a copy of the fd array
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 4204ed2b82fd8e9f6faf6e05a009d0ad7742c649
Author: Volker Lendecke <vl at samba.org>
Date: Fri Aug 23 18:11:57 2019 +0200
smbd: Use dbwrap_do_locked() in add_fd_to_close_entry()
Less explicit talloc. Right now dbwrap_rbt behind the scenes does a
dbwrap_fetch_locked(), but that will eventually change.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 92c2a723b278fb0338248bfb1fd1c1f4b90dce2b
Author: Volker Lendecke <vl at samba.org>
Date: Fri Aug 23 17:47:47 2019 +0200
dbwrap: Initialize state in dbwrap_delete()
Probably not required, but looks safer and gives static checkers less
reason to complain about potentially uninitialized variable reads
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b86df6d0591d7d8f3c08d0fe0975839ba00c342c
Author: Volker Lendecke <vl at samba.org>
Date: Thu Sep 5 17:25:07 2019 +0200
lib: Remove an obsolete comment
At least as of 2ac9d0afa66 ctdb does not care about db prios anymore
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a9d09d4bddb2a66e146f8e157fda4d7dd160a8a4
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:40:00 2019 +0200
smbd: Fix DBG typo in find_delete_on_close_token()
The routine isn't called find__delete_on_close_token. Also avoid
casts.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 2448060072e9f82fc6b0d48109d70e4e491650ca
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 9 16:34:10 2019 +0200
smbd: Use file_id_str_buf() in close_remove_share_mode()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit c88cb0a13bf2bd6ec8d144c60991643b225746d3
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 9 16:32:21 2019 +0200
smbd: Use file_id_str_buf() in setup_poll_open()
While there, remove a pointless empty line
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit fd691fbc94cf8da744e70bca0165e6a8356cffc5
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 9 16:30:57 2019 +0200
smbd: Use file_id_str_buf() in defer_open()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit bf2bf5b1448be3c4c8c6492a036b46a5ccd55890
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 9 16:28:57 2019 +0200
smbstatus: Use file_id_str_buf() in print_brl()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit feccf9bb4f50bd777b0ff64700272a3496c68576
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 6 07:31:22 2019 +0200
smbd: Use file_id_str_buf() in set_sticky_write_time()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit d9263473b07abe106f79edda8f880183881b4cff
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 6 07:29:10 2019 +0200
smbd: Use file_id_str_buf() in share_mode_str()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit de8b93b47992dc37821aa2bd83b34ba374ff0139
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:26:09 2019 +0200
smbd: Use file_id_str_buf() in brl_cleanup_disconnected()
Also avoid some casts and use DBG_ instead of DEBUG()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 49d18bbf29dd00414fcd52ddeed72809ba4e9002
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:18:00 2019 +0200
smbd: Use file_id_str_buf() in brl_get_locks()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7e70701ab0fd7fa03e79fad62a1903d4037e9852
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:15:40 2019 +0200
vfs: Use file_id_str_buf() in xattr_tdb_setattr()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5ca021bd85db7f645b963bbeb89cf6d09ed398f4
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:14:28 2019 +0200
vfs: Use file_id_str_buf() in xattr_tdb_getattr()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b09c216f5aeea3c41722b938213572012290a543
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 3 16:12:35 2019 +0200
lib: Use file_id_str_buf() in file_id_string()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 049b8833ae885412db3ce2d41c9e26134b4e7e7e
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 2 19:04:25 2019 +0200
lib: Add file_id_str_buf()
file_id_string() without talloc
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ba72d8231f836e364304996467f088e1ea8ca448
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 2 19:04:42 2019 +0200
lib: Properly #ifdef __LIB_FILE_ID_H__
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/dbwrap/dbwrap.c | 2 +-
lib/dbwrap/dbwrap.h | 4 -
source3/lib/file_id.c | 17 ++++-
source3/lib/file_id.h | 12 +++
source3/lib/xattr_tdb.c | 10 ++-
source3/locking/brlock.c | 54 +++++++-------
source3/locking/locking.c | 15 ++--
source3/locking/posix.c | 141 ++++++++++++------------------------
source3/smbd/close.c | 17 ++---
source3/smbd/dir.c | 2 +-
source3/smbd/open.c | 7 +-
source3/smbd/smb2_query_directory.c | 4 +-
source3/utils/status.c | 4 +-
13 files changed, 134 insertions(+), 155 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c
index f8eefcca02d..3d8d2ae78d7 100644
--- a/lib/dbwrap/dbwrap.c
+++ b/lib/dbwrap/dbwrap.c
@@ -339,7 +339,7 @@ static void dbwrap_delete_fn(struct db_record *rec, void *private_data)
NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key)
{
- struct dbwrap_delete_state state;
+ struct dbwrap_delete_state state = { .status = NT_STATUS_NOT_FOUND };
NTSTATUS status;
status = dbwrap_do_locked(db, key, dbwrap_delete_fn, &state);
diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h
index 6a0f7b1ee2e..42998b78139 100644
--- a/lib/dbwrap/dbwrap.h
+++ b/lib/dbwrap/dbwrap.h
@@ -31,10 +31,6 @@ struct db_context;
enum dbwrap_lock_order {
DBWRAP_LOCK_ORDER_NONE = 0, /* Don't check lock orders for this db. */
- /*
- * We only allow orders 1, 2, 3:
- * These are the orders that CTDB currently supports.
- */
DBWRAP_LOCK_ORDER_1 = 1,
DBWRAP_LOCK_ORDER_2 = 2,
DBWRAP_LOCK_ORDER_3 = 3
diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c
index 21f22ffbf3b..49e5c50385f 100644
--- a/source3/lib/file_id.c
+++ b/source3/lib/file_id.c
@@ -39,15 +39,24 @@ const char *file_id_string_tos(const struct file_id *id)
return file_id_string(talloc_tos(), id);
}
+char *file_id_str_buf(struct file_id fid, struct file_id_buf *dst)
+{
+ snprintf(dst->buf,
+ sizeof(dst->buf),
+ "%"PRIu64":%"PRIu64":%"PRIu64,
+ fid.devid,
+ fid.inode,
+ fid.extid);
+ return dst->buf;
+}
+
/*
an allocated string for a file_id structure
*/
const char *file_id_string(TALLOC_CTX *mem_ctx, const struct file_id *id)
{
- char *result = talloc_asprintf(mem_ctx, "%llx:%llx:%llx",
- (unsigned long long)id->devid,
- (unsigned long long)id->inode,
- (unsigned long long)id->extid);
+ struct file_id_buf buf;
+ char *result = talloc_strdup(mem_ctx, file_id_str_buf(*id, &buf));
SMB_ASSERT(result != NULL);
return result;
}
diff --git a/source3/lib/file_id.h b/source3/lib/file_id.h
index 509e924c1fe..c001199a35b 100644
--- a/source3/lib/file_id.h
+++ b/source3/lib/file_id.h
@@ -19,11 +19,21 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef __LIB_FILE_ID_H__
+#define __LIB_FILE_ID_H__
+
#include "librpc/gen_ndr/file_id.h"
/* The following definitions come from lib/file_id.c */
bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
+
+/*
+ * strlen("18446744073709551615")=20 times 3 plus 2 colons plus trailing 0
+ */
+struct file_id_buf { char buf[63]; };
+char *file_id_str_buf(struct file_id fid, struct file_id_buf *dst);
+
/*
a static-like (on talloc_tos()) string for a file_id structure
*/
@@ -40,3 +50,5 @@ void pull_file_id_24(const char *buf, struct file_id *id);
* Make a SMB File-ID from itime
*/
uint64_t make_file_id_from_itime(SMB_STRUCT_STAT *st);
+
+#endif
diff --git a/source3/lib/xattr_tdb.c b/source3/lib/xattr_tdb.c
index f3a2e19bf5d..564cdd80965 100644
--- a/source3/lib/xattr_tdb.c
+++ b/source3/lib/xattr_tdb.c
@@ -181,9 +181,10 @@ ssize_t xattr_tdb_getattr(struct db_context *db_ctx,
ssize_t result = -1;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
+ struct file_id_buf buf;
- DEBUG(10, ("xattr_tdb_getattr called for file %s, name %s\n",
- file_id_string(frame, id), name));
+ DBG_DEBUG("xattr_tdb_getattr called for file %s, name %s\n",
+ file_id_str_buf(*id, &buf), name);
status = xattr_tdb_load_attrs(frame, db_ctx, id, &attribs);
@@ -229,9 +230,10 @@ int xattr_tdb_setattr(struct db_context *db_ctx,
uint32_t i;
TDB_DATA data;
TALLOC_CTX *frame = talloc_stackframe();
+ struct file_id_buf buf;
- DEBUG(10, ("xattr_tdb_setattr called for file %s, name %s\n",
- file_id_string(frame, id), name));
+ DBG_DEBUG("xattr_tdb_setattr called for file %s, name %s\n",
+ file_id_str_buf(*id, &buf), name);
rec = xattr_tdb_lock_attrs(frame, db_ctx, id);
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index f22580164f9..f3fb75ef136 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -1832,10 +1832,11 @@ struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx, files_struct *fsp)
if (DEBUGLEVEL >= 10) {
unsigned int i;
+ struct file_id_buf buf;
struct lock_struct *locks = br_lck->lock_data;
- DEBUG(10,("brl_get_locks_internal: %u current locks on file_id %s\n",
- br_lck->num_locks,
- file_id_string_tos(&fsp->file_id)));
+ DBG_DEBUG("%u current locks on file_id %s\n",
+ br_lck->num_locks,
+ file_id_str_buf(fsp->file_id, &buf));
for( i = 0; i < br_lck->num_locks; i++) {
print_lock_struct(i, &locks[i]);
}
@@ -1961,14 +1962,15 @@ bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id)
struct db_record *rec;
struct lock_struct *lock;
unsigned n, num;
+ struct file_id_buf buf;
NTSTATUS status;
key = make_tdb_data((void*)&fid, sizeof(fid));
rec = dbwrap_fetch_locked(brlock_db, frame, key);
if (rec == NULL) {
- DEBUG(5, ("brl_cleanup_disconnected: failed to fetch record "
- "for file %s\n", file_id_string(frame, &fid)));
+ DBG_INFO("failed to fetch record for file %s\n",
+ file_id_str_buf(fid, &buf));
goto done;
}
@@ -1976,8 +1978,8 @@ bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id)
lock = (struct lock_struct*)val.dptr;
num = val.dsize / sizeof(struct lock_struct);
if (lock == NULL) {
- DEBUG(10, ("brl_cleanup_disconnected: no byte range locks for "
- "file %s\n", file_id_string(frame, &fid)));
+ DBG_DEBUG("no byte range locks for file %s\n",
+ file_id_str_buf(fid, &buf));
ret = true;
goto done;
}
@@ -1987,38 +1989,38 @@ bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id)
if (!server_id_is_disconnected(&ctx->pid)) {
struct server_id_buf tmp;
- DEBUG(5, ("brl_cleanup_disconnected: byte range lock "
- "%s used by server %s, do not cleanup\n",
- file_id_string(frame, &fid),
- server_id_str_buf(ctx->pid, &tmp)));
+ DBG_INFO("byte range lock "
+ "%s used by server %s, do not cleanup\n",
+ file_id_str_buf(fid, &buf),
+ server_id_str_buf(ctx->pid, &tmp));
goto done;
}
if (ctx->smblctx != open_persistent_id) {
- DEBUG(5, ("brl_cleanup_disconnected: byte range lock "
- "%s expected smblctx %llu but found %llu"
- ", do not cleanup\n",
- file_id_string(frame, &fid),
- (unsigned long long)open_persistent_id,
- (unsigned long long)ctx->smblctx));
+ DBG_INFO("byte range lock %s expected smblctx %"PRIu64" "
+ "but found %"PRIu64", do not cleanup\n",
+ file_id_str_buf(fid, &buf),
+ open_persistent_id,
+ ctx->smblctx);
goto done;
}
}
status = dbwrap_record_delete(rec);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(5, ("brl_cleanup_disconnected: failed to delete record "
- "for file %s from %s, open %llu: %s\n",
- file_id_string(frame, &fid), dbwrap_name(brlock_db),
- (unsigned long long)open_persistent_id,
- nt_errstr(status)));
+ DBG_INFO("failed to delete record "
+ "for file %s from %s, open %"PRIu64": %s\n",
+ file_id_str_buf(fid, &buf),
+ dbwrap_name(brlock_db),
+ open_persistent_id,
+ nt_errstr(status));
goto done;
}
- DEBUG(10, ("brl_cleanup_disconnected: "
- "file %s cleaned up %u entries from open %llu\n",
- file_id_string(frame, &fid), num,
- (unsigned long long)open_persistent_id));
+ DBG_DEBUG("file %s cleaned up %u entries from open %"PRIu64"\n",
+ file_id_str_buf(fid, &buf),
+ num,
+ open_persistent_id);
ret = true;
done:
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 3ed63cdec41..72235113fbb 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -442,6 +442,7 @@ char *share_mode_str(TALLOC_CTX *ctx, int num,
const struct share_mode_entry *e)
{
struct server_id_buf tmp;
+ struct file_id_buf ftmp;
return talloc_asprintf(ctx, "share_mode_entry[%d]: "
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
@@ -453,7 +454,7 @@ char *share_mode_str(TALLOC_CTX *ctx, int num,
e->access_mask, (unsigned long long)e->op_mid,
e->op_type, (unsigned long long)e->share_file_id,
(unsigned int)e->uid, (unsigned int)e->flags,
- file_id_string_tos(id),
+ file_id_str_buf(*id, &ftmp),
(unsigned int)e->name_hash);
}
@@ -1123,14 +1124,13 @@ static struct delete_token *find_delete_on_close_token(
{
uint32_t i;
- DEBUG(10, ("find_delete_on_close_token: name_hash = 0x%x\n",
- (unsigned int)name_hash));
+ DBG_DEBUG("name_hash = 0x%"PRIx32"\n", 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 ));
+ DBG_DEBUG("dt->name_hash = 0x%"PRIx32"\n",
+ dt->name_hash);
if (dt->name_hash == name_hash) {
return dt;
}
@@ -1167,11 +1167,12 @@ bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash)
bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
{
struct share_mode_lock *lck;
+ struct file_id_buf ftmp;
- DEBUG(5,("set_sticky_write_time: %s id=%s\n",
+ DBG_INFO("%s id=%s\n",
timestring(talloc_tos(),
convert_timespec_to_time_t(write_time)),
- file_id_string_tos(&fileid)));
+ file_id_str_buf(fileid, &ftmp));
lck = get_existing_share_mode_lock(talloc_tos(), fileid);
if (lck == NULL) {
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index a7bb5519bb4..3b75cfe481a 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -508,93 +508,64 @@ static void delete_lock_ref_count(const files_struct *fsp)
ref count is non zero.
****************************************************************************/
-/****************************************************************************
- Add an fd to the pending close db.
-****************************************************************************/
+struct add_fd_to_close_entry_state {
+ const struct files_struct *fsp;
+};
-static void add_fd_to_close_entry(const files_struct *fsp)
+static void add_fd_to_close_entry_fn(
+ struct db_record *rec, void *private_data)
{
- struct db_record *rec;
- int *fds;
- size_t num_fds;
+ struct add_fd_to_close_entry_state *state = private_data;
+ TDB_DATA values[] = {
+ dbwrap_record_get_value(rec),
+ { .dptr = (uint8_t *)&(state->fsp->fh->fd),
+ .dsize = sizeof(state->fsp->fh->fd) },
+ };
NTSTATUS status;
- TDB_DATA value;
-
- rec = dbwrap_fetch_locked(
- posix_pending_close_db, talloc_tos(),
- fd_array_key_fsp(fsp));
-
- SMB_ASSERT(rec != NULL);
-
- value = dbwrap_record_get_value(rec);
- SMB_ASSERT((value.dsize % sizeof(int)) == 0);
-
- num_fds = value.dsize / sizeof(int);
- fds = talloc_array(rec, int, num_fds+1);
-
- SMB_ASSERT(fds != NULL);
-
- memcpy(fds, value.dptr, value.dsize);
- fds[num_fds] = fsp->fh->fd;
- status = dbwrap_record_store(
- rec, make_tdb_data((uint8_t *)fds, talloc_get_size(fds)), 0);
+ SMB_ASSERT((values[0].dsize % sizeof(int)) == 0);
+ status = dbwrap_record_storev(rec, values, ARRAY_SIZE(values), 0);
SMB_ASSERT(NT_STATUS_IS_OK(status));
-
- TALLOC_FREE(rec);
-
- DEBUG(10,("add_fd_to_close_entry: added fd %d file %s\n",
- fsp->fh->fd, fsp_str_dbg(fsp)));
}
/****************************************************************************
- Remove all fd entries for a specific dev/inode pair from the tdb.
+ Add an fd to the pending close db.
****************************************************************************/
-static void delete_close_entries(const files_struct *fsp)
+static void add_fd_to_close_entry(const files_struct *fsp)
{
- struct db_record *rec;
+ struct add_fd_to_close_entry_state state = { .fsp = fsp };
+ NTSTATUS status;
- rec = dbwrap_fetch_locked(
- posix_pending_close_db, talloc_tos(),
- fd_array_key_fsp(fsp));
+ status = dbwrap_do_locked(
+ posix_pending_close_db,
+ fd_array_key_fsp(fsp),
+ add_fd_to_close_entry_fn,
+ &state);
+ SMB_ASSERT(NT_STATUS_IS_OK(status));
- SMB_ASSERT(rec != NULL);
- dbwrap_record_delete(rec);
- TALLOC_FREE(rec);
+ DBG_DEBUG("added fd %d file %s\n",
+ fsp->fh->fd,
+ fsp_str_dbg(fsp));
}
-/****************************************************************************
- Get the array of POSIX pending close records for an open fsp. Returns number
- of entries.
-****************************************************************************/
-
-static size_t get_posix_pending_close_entries(TALLOC_CTX *mem_ctx,
- const files_struct *fsp,
- int **entries)
+static void fd_close_posix_fn(
+ struct db_record *rec, void *private_data)
{
- TDB_DATA dbuf;
- NTSTATUS status;
+ TDB_DATA data = dbwrap_record_get_value(rec);
+ size_t num_fds, i;
- status = dbwrap_fetch(
- posix_pending_close_db, mem_ctx, fd_array_key_fsp(fsp),
- &dbuf);
+ SMB_ASSERT((data.dsize % sizeof(int)) == 0);
+ num_fds = data.dsize / sizeof(int);
- if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
- *entries = NULL;
- return 0;
- }
-
- SMB_ASSERT(NT_STATUS_IS_OK(status));
-
- if (dbuf.dsize == 0) {
- *entries = NULL;
- return 0;
+ for (i=0; i<num_fds; i++) {
+ int fd;
+ memcpy(&fd, data.dptr, sizeof(int));
+ close(fd);
+ data.dptr += sizeof(int);
}
-
- *entries = (int *)dbuf.dptr;
- return (size_t)(dbuf.dsize / sizeof(int));
+ dbwrap_record_delete(rec);
}
/****************************************************************************
@@ -607,8 +578,7 @@ int fd_close_posix(const struct files_struct *fsp)
{
int saved_errno = 0;
int ret;
- int *fd_array = NULL;
- size_t count, i;
+ NTSTATUS status;
if (!lp_locking(fsp->conn->params) ||
!lp_posix_locking(fsp->conn->params) ||
@@ -635,33 +605,16 @@ int fd_close_posix(const struct files_struct *fsp)
return 0;
}
- /*
- * No outstanding locks. Get the pending close fd's
- * from the db and close them all.
- */
-
- count = get_posix_pending_close_entries(talloc_tos(), fsp, &fd_array);
-
- if (count) {
- DEBUG(10,("fd_close_posix: doing close on %u fd's.\n",
- (unsigned int)count));
-
- for(i = 0; i < count; i++) {
- if (close(fd_array[i]) == -1) {
- saved_errno = errno;
- }
- }
-
- /*
- * Delete all fd's stored in the db
- * for this dev/inode pair.
- */
-
- delete_close_entries(fsp);
+ status = dbwrap_do_locked(
+ posix_pending_close_db,
+ fd_array_key_fsp(fsp),
+ fd_close_posix_fn,
+ NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("dbwrap_do_locked failed: %s\n",
+ nt_errstr(status));
}
- TALLOC_FREE(fd_array);
-
/* Don't need a lock ref count on this dev/ino anymore. */
delete_lock_ref_count(fsp);
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 12d7f8c9a95..9786c826439 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -350,9 +350,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
}
}
- delete_file = is_delete_on_close_set(lck, fsp->name_hash);
-
- delete_file &= !has_other_nonposix_opens(lck, fsp);
+ delete_file = is_delete_on_close_set(lck, fsp->name_hash) &&
+ !has_other_nonposix_opens(lck, fsp);
/*
* NT can set delete_on_close of the last open
@@ -421,14 +420,15 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
if (!file_id_equal(&fsp->file_id, &id)) {
+ struct file_id_buf ftmp1, ftmp2;
DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
"was set and dev and/or inode does not match\n",
fsp_str_dbg(fsp)));
DEBUG(5,("close_remove_share_mode: file %s. stored file_id %s, "
"stat file_id %s\n",
fsp_str_dbg(fsp),
- file_id_string_tos(&fsp->file_id),
- file_id_string_tos(&id)));
--
Samba Shared Repository
More information about the samba-cvs
mailing list