s3: Factor out "mark_file_modified"
authorVolker Lendecke <vl@samba.org>
Thu, 12 Jul 2012 14:28:11 +0000 (16:28 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 12 Jul 2012 17:13:12 +0000 (10:13 -0700)
This is in preparation of making us survive base-delaywrite with async I/O activated

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/smbd/fileio.c
source3/smbd/proto.h

index a14be7806a04ea9cc2c96ac3968fefa2d4b84265..631a9a1e0d65128d0de43a0099f8306f46b5514f 100644 (file)
@@ -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) {
index 725f89c2296b5ea60a11716495a7f2ff78fb11f9..9aaa00a1ce707b2036339d1f96397a55bd3259c2 100644 (file)
@@ -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,