From 4d7be0854a22257b446edd61095e8986e924362c Mon Sep 17 00:00:00 2001 From: Andrew Klaassen Date: Thu, 26 Apr 2012 15:37:00 -0400 Subject: [PATCH 5/5] - Added "cache locked write times" parameter to allow caching of write times to be turned of (with "no"). Defaults to "yes". --- lib/param/param_functions.c | 1 + source3/include/proto.h | 1 + source3/locking/locking.c | 5 +++-- source3/locking/proto.h | 3 ++- source3/param/loadparm.c | 10 ++++++++++ source3/smbd/dir.c | 2 +- source3/smbd/filename.c | 2 +- source3/smbd/nttrans.c | 4 ++-- source3/smbd/reply.c | 4 ++-- source3/smbd/smb2_create.c | 2 +- source3/smbd/smb2_getinfo.c | 4 ++-- source3/smbd/trans2.c | 8 ++++---- 12 files changed, 30 insertions(+), 16 deletions(-) diff --git a/lib/param/param_functions.c b/lib/param/param_functions.c index ee865fd..d0a170e 100644 --- a/lib/param/param_functions.c +++ b/lib/param/param_functions.c @@ -156,3 +156,4 @@ FN_LOCAL_CHAR(magicchar, magic_char) FN_LOCAL_STRING(cups_options, szCupsOptions) FN_LOCAL_PARM_BOOL(change_notify, bChangeNotify) FN_LOCAL_PARM_BOOL(kernel_change_notify, bKernelChangeNotify) +FN_LOCAL_PARM_BOOL(cache_locked_write_times, bCacheLockedWriteTimes) diff --git a/source3/include/proto.h b/source3/include/proto.h index 779745a..748cd7a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1260,6 +1260,7 @@ bool lp_client_use_spnego_principal(void); bool lp_hostname_lookups(void); bool lp_change_notify(const struct share_params *p ); bool lp_kernel_change_notify(const struct share_params *p ); +bool lp_cache_locked_write_times(const struct share_params *p ); const char * lp_dedicated_keytab_file(void); int lp_kerberos_method(void); bool lp_defer_sharing_violations(void); diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 149a79d..7a36a8f 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -571,7 +571,8 @@ bool rename_share_filename(struct messaging_context *msg_ctx, return True; } -void get_file_infos(struct file_id id, +void get_file_infos(struct connection_struct *conn, + struct file_id id, uint32_t name_hash, bool *delete_on_close, struct timespec *write_time) @@ -594,7 +595,7 @@ void get_file_infos(struct file_id id, *delete_on_close = is_delete_on_close_set(lck, name_hash); } - if (write_time) { + if (write_time && lp_cache_locked_write_times(conn->params)) { struct timespec wt; wt = lck->data->changed_write_time; diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 3a6df37..a1a7650 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -162,7 +162,8 @@ bool rename_share_filename(struct messaging_context *msg_ctx, uint32_t orig_name_hash, uint32_t new_name_hash, const struct smb_filename *smb_fname); -void get_file_infos(struct file_id id, +void get_file_infos(struct connection_struct *conn, + struct file_id id, uint32_t name_hash, bool *delete_on_close, struct timespec *write_time); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index f4e0133..bd91e5d 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -267,6 +267,7 @@ static struct loadparm_service sDefault = .bAclGroupControl = false, .bChangeNotify = true, .bKernelChangeNotify = true, + .bCacheLockedWriteTimes = true, .iallocation_roundup_size = SMB_ROUNDUP_ALLOCATION_SIZE, .iAioReadSize = 0, .iAioWriteSize = 0, @@ -1936,6 +1937,15 @@ static struct parm_struct parm_table[] = { .flags = FLAG_ADVANCED | FLAG_SHARE, }, { + .label = "cache locked write times", + .type = P_BOOL, + .p_class = P_LOCAL, + .offset = LOCAL_VAR(bCacheLockedWriteTimes), + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED | FLAG_SHARE, + }, + { .label = "lpq cache time", .type = P_INTEGER, .p_class = P_GLOBAL, diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 103dbc8..bf36962 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1123,7 +1123,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, fileid = vfs_file_id_from_sbuf(conn, &smb_fname.st); - get_file_infos(fileid, 0, NULL, &write_time_ts); + get_file_infos(conn, fileid, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&smb_fname.st, write_time_ts); diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 95e8c14..2076151 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -871,7 +871,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, goto fail; } - get_file_infos(vfs_file_id_from_sbuf(conn, + get_file_infos(conn, vfs_file_id_from_sbuf(conn, &smb_fname->st), name_hash, &delete_pending, NULL); diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 20379ac..fc39489 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -661,7 +661,7 @@ void reply_ntcreate_and_X(struct smb_request *req) /* Deal with other possible opens having a modified write time. JRA. */ ZERO_STRUCT(write_time_ts); - get_file_infos(fsp->file_id, 0, NULL, &write_time_ts); + get_file_infos(conn, fsp->file_id, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&smb_fname->st, write_time_ts); } @@ -1241,7 +1241,7 @@ static void call_nt_transact_create(connection_struct *conn, /* Deal with other possible opens having a modified write time. JRA. */ ZERO_STRUCT(write_time_ts); - get_file_infos(fsp->file_id, 0, NULL, &write_time_ts); + get_file_infos(conn, fsp->file_id, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&smb_fname->st, write_time_ts); } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 6e4bcab..ccf08a9 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1141,7 +1141,7 @@ void reply_getatr(struct smb_request *req) ZERO_STRUCT(write_time_ts); fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); - get_file_infos(fileid, 0, NULL, &write_time_ts); + get_file_infos(conn, fileid, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&smb_fname->st, write_time_ts); } @@ -1812,7 +1812,7 @@ void reply_open(struct smb_request *req) struct timespec write_time_ts; ZERO_STRUCT(write_time_ts); - get_file_infos(fsp->file_id, 0, NULL, &write_time_ts); + get_file_infos(conn, fsp->file_id, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&smb_fname->st, write_time_ts); } diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index 3e5b81d..b2ec9cd 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -803,7 +803,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, /* Deal with other possible opens having a modified write time. JRA. */ ZERO_STRUCT(write_time_ts); - get_file_infos(result->file_id, 0, NULL, &write_time_ts); + get_file_infos(result->conn, result->file_id, 0, NULL, &write_time_ts); if (!null_timespec(write_time_ts)) { update_stat_ex_mtime(&result->fsp_name->st, write_time_ts); } diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c index e8d918d..8cba0b8 100644 --- a/source3/smbd/smb2_getinfo.c +++ b/source3/smbd/smb2_getinfo.c @@ -355,7 +355,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, fileid = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st); - get_file_infos(fileid, fsp->name_hash, + get_file_infos(conn, fileid, fsp->name_hash, &delete_pending, &write_time_ts); } else { /* @@ -372,7 +372,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, } fileid = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st); - get_file_infos(fileid, fsp->name_hash, + get_file_infos(conn, fileid, fsp->name_hash, &delete_pending, &write_time_ts); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 24642cd..e6b8235 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5151,7 +5151,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, } fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); - get_file_infos(fileid, fsp->name_hash, &delete_pending, &write_time_ts); + get_file_infos(conn, fileid, fsp->name_hash, &delete_pending, &write_time_ts); } else { /* * Original code - this is an open file. @@ -5164,7 +5164,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, return; } fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); - get_file_infos(fileid, fsp->name_hash, &delete_pending, &write_time_ts); + get_file_infos(conn, fileid, fsp->name_hash, &delete_pending, &write_time_ts); } } else { @@ -5275,7 +5275,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, fileid = vfs_file_id_from_sbuf(conn, &smb_fname_base->st); TALLOC_FREE(smb_fname_base); - get_file_infos(fileid, name_hash, &delete_pending, NULL); + get_file_infos(conn, fileid, name_hash, &delete_pending, NULL); if (delete_pending) { reply_nterror(req, NT_STATUS_DELETE_PENDING); return; @@ -5315,7 +5315,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, } fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st); - get_file_infos(fileid, name_hash, &delete_pending, &write_time_ts); + get_file_infos(conn, fileid, name_hash, &delete_pending, &write_time_ts); if (delete_pending) { reply_nterror(req, NT_STATUS_DELETE_PENDING); return; -- 1.7.9.1