From 67e7e14e6231b420d34b9782cfac7901c2e28663 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 12 Jul 2012 16:28:11 +0200 Subject: [PATCH] s3: Factor out "mark_file_modified" This is in preparation of making us survive base-delaywrite with async I/O activated Signed-off-by: Jeremy Allison --- source3/smbd/fileio.c | 67 ++++++++++++++++++++++++++++++++------------------- source3/smbd/proto.h | 1 + 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index a14be7806a0..631a9a1e0d6 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -269,6 +269,37 @@ void trigger_write_time_update_immediate(struct files_struct *fsp) (void)smb_set_file_time(fsp->conn, fsp, fsp->fsp_name, &ft, false); } +void mark_file_modified(files_struct *fsp) +{ + int dosmode; + + if (fsp->modified) { + return; + } + + fsp->modified = true; + + if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) { + return; + } + trigger_write_time_update(fsp); + + if (fsp->posix_open) { + return; + } + if (!(lp_store_dos_attributes(SNUM(fsp->conn)) || + MAP_ARCHIVE(fsp->conn))) { + return; + } + + dosmode = dos_mode(fsp->conn, fsp->fsp_name); + if (IS_DOS_ARCHIVE(dosmode)) { + return; + } + file_set_dosmode(fsp->conn, fsp->fsp_name, + dosmode | FILE_ATTRIBUTE_ARCHIVE, NULL, false); +} + /**************************************************************************** Write to a file. ****************************************************************************/ @@ -300,34 +331,20 @@ ssize_t write_file(struct smb_request *req, return -1; } - if (!fsp->modified) { - fsp->modified = True; - - if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) == 0) { - trigger_write_time_update(fsp); - if (!fsp->posix_open && - (lp_store_dos_attributes(SNUM(fsp->conn)) || - MAP_ARCHIVE(fsp->conn))) { - int dosmode = dos_mode(fsp->conn, fsp->fsp_name); - if (!IS_DOS_ARCHIVE(dosmode)) { - file_set_dosmode(fsp->conn, fsp->fsp_name, - dosmode | FILE_ATTRIBUTE_ARCHIVE, NULL, false); - } - } - - /* - * If this is the first write and we have an exclusive oplock then setup - * the write cache. - */ + /* + * If this is the first write and we have an exclusive oplock + * then setup the write cache. + */ - if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !wcp) { - setup_write_cache(fsp, - fsp->fsp_name->st.st_ex_size); - wcp = fsp->wcp; - } - } + if (!fsp->modified && + EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && + (wcp == NULL)) { + setup_write_cache(fsp, fsp->fsp_name->st.st_ex_size); + wcp = fsp->wcp; } + mark_file_modified(fsp); + #ifdef WITH_PROFILE DO_PROFILE_INC(writecache_total_writes); if (!fsp->oplock_type) { diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 725f89c2296..9aaa00a1ce7 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -320,6 +320,7 @@ void update_write_time_handler(struct event_context *ctx, void *private_data); void trigger_write_time_update(struct files_struct *fsp); void trigger_write_time_update_immediate(struct files_struct *fsp); +void mark_file_modified(files_struct *fsp); ssize_t write_file(struct smb_request *req, files_struct *fsp, const char *data, -- 2.11.4.GIT