1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

smbd: move files_struct.modified to a bitfield

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-04-02 17:37:02 +02:00 committed by Jeremy Allison
parent b95c62bc90
commit 65a4302474
12 changed files with 22 additions and 22 deletions

View File

@ -365,6 +365,7 @@ typedef struct files_struct {
bool can_lock : 1; bool can_lock : 1;
bool can_read : 1; bool can_read : 1;
bool can_write : 1; bool can_write : 1;
bool modified : 1;
} fsp_flags; } fsp_flags;
struct tevent_timer *update_write_time_event; struct tevent_timer *update_write_time_event;
@ -385,7 +386,6 @@ typedef struct files_struct {
struct lock_struct last_lock_failure; struct lock_struct last_lock_failure;
int current_lock_count; /* Count the number of outstanding locks and pending locks. */ int current_lock_count; /* Count the number of outstanding locks and pending locks. */
bool modified;
bool is_directory; bool is_directory;
bool aio_write_behind; bool aio_write_behind;
bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */ bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */

View File

@ -1335,7 +1335,7 @@ static int virusfilter_vfs_close(
* If close failed, file likely doesn't exist, do not try to scan. * If close failed, file likely doesn't exist, do not try to scan.
*/ */
if (close_result == -1 && close_errno == EBADF) { if (close_result == -1 && close_errno == EBADF) {
if (fsp->modified) { if (fsp->fsp_flags.modified) {
DBG_DEBUG("Removing cache entry (if existent): " DBG_DEBUG("Removing cache entry (if existent): "
"fname: %s\n", fname); "fname: %s\n", fname);
virusfilter_cache_remove(config->cache, virusfilter_cache_remove(config->cache,
@ -1350,7 +1350,7 @@ static int virusfilter_vfs_close(
} }
if (is_named_stream(fsp->fsp_name)) { 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) { if (config->cache) {
DBG_DEBUG("Removing cache entry (if existent)" DBG_DEBUG("Removing cache entry (if existent)"
": fname: %s\n", fname); ": fname: %s\n", fname);
@ -1365,7 +1365,7 @@ static int virusfilter_vfs_close(
} }
if (!config->scan_on_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) { if (config->cache) {
DBG_DEBUG("Removing cache entry (if existent)" DBG_DEBUG("Removing cache entry (if existent)"
": fname: %s\n", fname); ": fname: %s\n", fname);
@ -1379,7 +1379,7 @@ static int virusfilter_vfs_close(
return close_result; return close_result;
} }
if (!fsp->modified) { if (!fsp->fsp_flags.modified) {
DBG_NOTICE("Not scanned: File not modified: %s/%s\n", DBG_NOTICE("Not scanned: File not modified: %s/%s\n",
cwd_fname, fname); cwd_fname, fname);

View File

@ -232,7 +232,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
fsp->fsp_flags.can_read = false; fsp->fsp_flags.can_read = false;
fsp->access_mask = FILE_GENERIC_WRITE; fsp->access_mask = FILE_GENERIC_WRITE;
fsp->fsp_flags.can_write = true; fsp->fsp_flags.can_write = true;
fsp->modified = false; fsp->fsp_flags.modified = false;
fsp->oplock_type = NO_OPLOCK; fsp->oplock_type = NO_OPLOCK;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = false; fsp->is_directory = false;

View File

@ -691,7 +691,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
* TODO: * TODO:
* Do we need to store the modified flag in the DB? * Do we need to store the modified flag in the DB?
*/ */
fsp->modified = false; fsp->fsp_flags.modified = false;
/* /*
* no durables for directories * no durables for directories
*/ */

View File

@ -210,11 +210,11 @@ void mark_file_modified(files_struct *fsp)
trigger_write_time_update(fsp); trigger_write_time_update(fsp);
if (fsp->modified) { if (fsp->fsp_flags.modified) {
return; return;
} }
fsp->modified = true; fsp->fsp_flags.modified = true;
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
return; return;

View File

@ -793,7 +793,7 @@ NTSTATUS dup_file_fsp(
to->fsp_flags.can_write = to->fsp_flags.can_write =
CAN_WRITE(from->conn) && CAN_WRITE(from->conn) &&
((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0); ((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->is_directory = from->is_directory;
to->aio_write_behind = from->aio_write_behind; to->aio_write_behind = from->aio_write_behind;

View File

@ -1435,7 +1435,7 @@ static NTSTATUS open_file(files_struct *fsp,
CAN_WRITE(conn) && CAN_WRITE(conn) &&
((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0); ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0);
fsp->print_file = NULL; fsp->print_file = NULL;
fsp->modified = False; fsp->fsp_flags.modified = false;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = False; fsp->is_directory = False;
if (conn->aio_write_behind_list && 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->access_mask = access_mask | FILE_READ_ATTRIBUTES;
fsp->print_file = NULL; fsp->print_file = NULL;
fsp->modified = False; fsp->fsp_flags.modified = false;
fsp->oplock_type = NO_OPLOCK; fsp->oplock_type = NO_OPLOCK;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = True; fsp->is_directory = True;

View File

@ -197,7 +197,7 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx,
fsp->fsp_flags.can_read = true; fsp->fsp_flags.can_read = true;
fsp->fsp_flags.can_write = true; fsp->fsp_flags.can_write = true;
fsp->print_file = NULL; fsp->print_file = NULL;
fsp->modified = False; fsp->fsp_flags.modified = false;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode); fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode);

View File

@ -5717,7 +5717,7 @@ static struct files_struct *file_sync_one_fn(struct files_struct *fsp,
} }
sync_file(conn, fsp, True /* write through */); sync_file(conn, fsp, True /* write through */);
if (fsp->modified) { if (fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
} }
@ -5759,7 +5759,7 @@ void reply_flush(struct smb_request *req)
END_PROFILE(SMBflush); END_PROFILE(SMBflush);
return; return;
} }
if (fsp->modified) { if (fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
} }
} }
@ -9524,7 +9524,7 @@ void reply_setattrE(struct smb_request *req)
goto out; goto out;
} }
if (fsp->modified) { if (fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
} }

View File

@ -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)); tevent_req_nterror(req, map_nt_error_from_unix(vfs_aio_state.error));
return; return;
} }
if (state->fsp->modified) { if (state->fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(state->fsp); trigger_write_time_update_immediate(state->fsp);
} }
tevent_req_done(req); tevent_req_done(req);

View File

@ -6697,7 +6697,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
if (fsp == NULL) { if (fsp == NULL) {
return NT_STATUS_OK; return NT_STATUS_OK;
} }
if (!fsp->modified) { if (!fsp->fsp_flags.modified) {
return NT_STATUS_OK; return NT_STATUS_OK;
} }
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
@ -7865,7 +7865,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
return status; return status;
} }
if (fsp != NULL && fsp->modified) { if (fsp != NULL && fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
} }
return NT_STATUS_OK; return NT_STATUS_OK;
@ -7910,7 +7910,7 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn,
return status; return status;
} }
if (fsp != NULL && fsp->modified) { if (fsp != NULL && fsp->fsp_flags.modified) {
trigger_write_time_update_immediate(fsp); trigger_write_time_update_immediate(fsp);
} }
return NT_STATUS_OK; return NT_STATUS_OK;

View File

@ -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_read = true;
fsp->fsp_flags.can_write = CAN_WRITE(vfs->conn); fsp->fsp_flags.can_write = CAN_WRITE(vfs->conn);
fsp->print_file = NULL; fsp->print_file = NULL;
fsp->modified = False; fsp->fsp_flags.modified = false;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = False; 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_read = true;
fsp->fsp_flags.can_write = true; fsp->fsp_flags.can_write = true;
fsp->print_file = NULL; fsp->print_file = NULL;
fsp->modified = False; fsp->fsp_flags.modified = false;
fsp->sent_oplock_break = NO_BREAK_SENT; fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode); fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode);