From: Ralph Boehme Date: Thu, 2 Apr 2020 15:37:02 +0000 (+0200) Subject: smbd: move files_struct.modified to a bitfield X-Git-Tag: ldb-2.2.0~991 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=65a4302474d1e6678ea6d258f981c4fc139aeeb4;p=thirdparty%2Fsamba.git smbd: move files_struct.modified to a bitfield Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/include/vfs.h b/source3/include/vfs.h index d270dcbd92a..74d9aa17e43 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -365,6 +365,7 @@ typedef struct files_struct { bool can_lock : 1; bool can_read : 1; bool can_write : 1; + bool modified : 1; } fsp_flags; struct tevent_timer *update_write_time_event; @@ -385,7 +386,6 @@ typedef struct files_struct { struct lock_struct last_lock_failure; int current_lock_count; /* Count the number of outstanding locks and pending locks. */ - bool modified; bool is_directory; bool aio_write_behind; bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */ diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c index 12f0364d2a7..9dbe9b6348b 100644 --- a/source3/modules/vfs_virusfilter.c +++ b/source3/modules/vfs_virusfilter.c @@ -1335,7 +1335,7 @@ static int virusfilter_vfs_close( * If close failed, file likely doesn't exist, do not try to scan. */ if (close_result == -1 && close_errno == EBADF) { - if (fsp->modified) { + if (fsp->fsp_flags.modified) { DBG_DEBUG("Removing cache entry (if existent): " "fname: %s\n", fname); virusfilter_cache_remove(config->cache, @@ -1350,7 +1350,7 @@ static int virusfilter_vfs_close( } if (is_named_stream(fsp->fsp_name)) { - if (config->scan_on_open && fsp->modified) { + if (config->scan_on_open && fsp->fsp_flags.modified) { if (config->cache) { DBG_DEBUG("Removing cache entry (if existent)" ": fname: %s\n", fname); @@ -1365,7 +1365,7 @@ static int virusfilter_vfs_close( } if (!config->scan_on_close) { - if (config->scan_on_open && fsp->modified) { + if (config->scan_on_open && fsp->fsp_flags.modified) { if (config->cache) { DBG_DEBUG("Removing cache entry (if existent)" ": fname: %s\n", fname); @@ -1379,7 +1379,7 @@ static int virusfilter_vfs_close( return close_result; } - if (!fsp->modified) { + if (!fsp->fsp_flags.modified) { DBG_NOTICE("Not scanned: File not modified: %s/%s\n", cwd_fname, fname); diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c index fbf4054b192..c397902592c 100644 --- a/source3/printing/printspoolss.c +++ b/source3/printing/printspoolss.c @@ -232,7 +232,7 @@ NTSTATUS print_spool_open(files_struct *fsp, fsp->fsp_flags.can_read = false; fsp->access_mask = FILE_GENERIC_WRITE; fsp->fsp_flags.can_write = true; - fsp->modified = false; + fsp->fsp_flags.modified = false; fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = false; diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 54283a7bef1..d6e05c6245a 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -691,7 +691,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, * TODO: * Do we need to store the modified flag in the DB? */ - fsp->modified = false; + fsp->fsp_flags.modified = false; /* * no durables for directories */ diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 2300f5a209f..14610eb225d 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -210,11 +210,11 @@ void mark_file_modified(files_struct *fsp) trigger_write_time_update(fsp); - if (fsp->modified) { + if (fsp->fsp_flags.modified) { return; } - fsp->modified = true; + fsp->fsp_flags.modified = true; if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { return; diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 78df1fad6f4..5a0b5622096 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -793,7 +793,7 @@ NTSTATUS dup_file_fsp( to->fsp_flags.can_write = CAN_WRITE(from->conn) && ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0); - to->modified = from->modified; + to->fsp_flags.modified = from->fsp_flags.modified; to->is_directory = from->is_directory; to->aio_write_behind = from->aio_write_behind; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 4e0b3752371..ffb3ea5f9d1 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1435,7 +1435,7 @@ static NTSTATUS open_file(files_struct *fsp, CAN_WRITE(conn) && ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0); fsp->print_file = NULL; - fsp->modified = False; + fsp->fsp_flags.modified = false; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = False; if (conn->aio_write_behind_list && @@ -4402,7 +4402,7 @@ static NTSTATUS open_directory(connection_struct *conn, */ fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES; fsp->print_file = NULL; - fsp->modified = False; + fsp->fsp_flags.modified = false; fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = True; diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 224619b6014..d9d4a6143cc 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -197,7 +197,7 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx, fsp->fsp_flags.can_read = true; fsp->fsp_flags.can_write = true; fsp->print_file = NULL; - fsp->modified = False; + fsp->fsp_flags.modified = false; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 6a2093a1498..7c9900d763c 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5717,7 +5717,7 @@ static struct files_struct *file_sync_one_fn(struct files_struct *fsp, } sync_file(conn, fsp, True /* write through */); - if (fsp->modified) { + if (fsp->fsp_flags.modified) { trigger_write_time_update_immediate(fsp); } @@ -5759,7 +5759,7 @@ void reply_flush(struct smb_request *req) END_PROFILE(SMBflush); return; } - if (fsp->modified) { + if (fsp->fsp_flags.modified) { trigger_write_time_update_immediate(fsp); } } @@ -9524,7 +9524,7 @@ void reply_setattrE(struct smb_request *req) goto out; } - if (fsp->modified) { + if (fsp->fsp_flags.modified) { trigger_write_time_update_immediate(fsp); } diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index 08539e95807..677877ca62f 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -220,7 +220,7 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq) tevent_req_nterror(req, map_nt_error_from_unix(vfs_aio_state.error)); return; } - if (state->fsp->modified) { + if (state->fsp->fsp_flags.modified) { trigger_write_time_update_immediate(state->fsp); } tevent_req_done(req); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index a4cf666d76f..380b276e759 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -6697,7 +6697,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, if (fsp == NULL) { return NT_STATUS_OK; } - if (!fsp->modified) { + if (!fsp->fsp_flags.modified) { return NT_STATUS_OK; } trigger_write_time_update_immediate(fsp); @@ -7865,7 +7865,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn, return status; } - if (fsp != NULL && fsp->modified) { + if (fsp != NULL && fsp->fsp_flags.modified) { trigger_write_time_update_immediate(fsp); } return NT_STATUS_OK; @@ -7910,7 +7910,7 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn, return status; } - if (fsp != NULL && fsp->modified) { + if (fsp != NULL && fsp->fsp_flags.modified) { trigger_write_time_update_immediate(fsp); } return NT_STATUS_OK; diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 4ad65dc31ba..e66f5d44d96 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -426,7 +426,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c fsp->fsp_flags.can_read = true; fsp->fsp_flags.can_write = CAN_WRITE(vfs->conn); fsp->print_file = NULL; - fsp->modified = False; + fsp->fsp_flags.modified = false; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = False; @@ -1654,7 +1654,7 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a fsp->fsp_flags.can_read = true; fsp->fsp_flags.can_write = true; fsp->print_file = NULL; - fsp->modified = False; + fsp->fsp_flags.modified = false; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode);