diff options
author | Volker Lendecke <vl@samba.org> | 2012-07-12 16:28:11 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-07-12 10:13:12 -0700 |
commit | 67e7e14e6231b420d34b9782cfac7901c2e28663 (patch) | |
tree | d41598ab64e9071624cc514569a9a30c2bfe4264 | |
parent | 1ee95e4cb14b0f9c7bbaba0c994f0a511822cff8 (diff) | |
download | samba-67e7e14e6231b420d34b9782cfac7901c2e28663.tar.gz samba-67e7e14e6231b420d34b9782cfac7901c2e28663.tar.bz2 samba-67e7e14e6231b420d34b9782cfac7901c2e28663.zip |
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 <jra@samba.org>
-rw-r--r-- | source3/smbd/fileio.c | 67 | ||||
-rw-r--r-- | 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 a14be7806a..631a9a1e0d 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 725f89c229..9aaa00a1ce 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, |