summaryrefslogtreecommitdiff
path: root/source3/smbd/dosmode.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-09-05 19:00:48 -0700
committerJeremy Allison <jra@samba.org>2008-09-05 19:00:48 -0700
commit405b072431db3f3f8f16e4e0d2f2b1b2f1c71286 (patch)
tree8a44daaa1bb7912a33ecb1145f48ef4f13e2fe32 /source3/smbd/dosmode.c
parenta90ba70cbf8af0d6081f6bb02cae71b955126c49 (diff)
downloadsamba-405b072431db3f3f8f16e4e0d2f2b1b2f1c71286.tar.gz
samba-405b072431db3f3f8f16e4e0d2f2b1b2f1c71286.tar.bz2
samba-405b072431db3f3f8f16e4e0d2f2b1b2f1c71286.zip
Write times code update.
Ok, here's the fix for the write times breakage with the new tests in S4 smbtorture. The key is keeping in the share mode struct the "old_file_time" as the real write time, set by all the write and allocation calls, and the "changed_write_time" as the "sticky" write time - set by the SET_FILE_TIME calls. We can set them independently (although I kept the optimization of not setting the "old_file_time" is a "changed_write_time" was already set, as we'll never see it. This allows us to update the write time immediately on the SMBwrite truncate case, SET_END_OF_FILE and SET_ALLOCATION_SIZE calls, whilst still have the 2 second delay on the "normal" SMBwrite, SMBwriteX calls. I think in a subsequent patch I'd like to change the name of these from "old_file_time" to "write_time" and "changed_write_time" to "sticky_write_time" to make this clearer. I think I also fixed a bug in Metze's original code in that once a write timestamp had been set from a "normal" SMBwriteX call the fsp->update_write_time_triggered variable was set and then never reset - thus meaning the write timestamp would never get updated again on subsequent SMBwriteX's. The new code checks the update_write_time_event event instead, and doesn't update is there's an event already scheduled. Metze especially, please check this over for your understanding. Jeremy. (This used to be commit 6f20585419046c4aca1f7d6c863cf79eb6ae53b0)
Diffstat (limited to 'source3/smbd/dosmode.c')
-rw-r--r--source3/smbd/dosmode.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 0ac3873275..88c6a51770 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -616,39 +616,51 @@ int file_ntimes(connection_struct *conn, const char *fname, const struct timespe
return ret;
}
-/*******************************************************************
- Change a filetime - possibly allowing DOS semantics.
-*******************************************************************/
+/******************************************************************
+ Force a "sticky" write time on a pathname. This will always be
+ returned on all future write time queries and set on close.
+******************************************************************/
-bool set_write_time_path(connection_struct *conn, const char *fname,
- struct file_id fileid, const struct timespec mtime,
- bool overwrite)
+bool set_sticky_write_time_path(connection_struct *conn, const char *fname,
+ struct file_id fileid, const struct timespec mtime)
{
if (null_timespec(mtime)) {
return true;
}
- if (!set_write_time(fileid, mtime, overwrite)) {
+ if (!set_sticky_write_time(fileid, mtime)) {
return false;
}
- /* in the overwrite case the caller should trigger the notify */
- if (!overwrite) {
- notify_fname(conn, NOTIFY_ACTION_MODIFIED,
- FILE_NOTIFY_CHANGE_LAST_WRITE, fname);
- }
-
return true;
}
-bool set_write_time_fsp(struct files_struct *fsp, const struct timespec mtime,
- bool overwrite)
+/******************************************************************
+ Force a "sticky" write time on an fsp. This will always be
+ returned on all future write time queries and set on close.
+******************************************************************/
+
+bool set_sticky_write_time_fsp(struct files_struct *fsp, const struct timespec mtime)
{
- if (overwrite) {
- fsp->write_time_forced = true;
- TALLOC_FREE(fsp->update_write_time_event);
+ fsp->write_time_forced = true;
+ TALLOC_FREE(fsp->update_write_time_event);
+
+ return set_sticky_write_time_path(fsp->conn, fsp->fsp_name,
+ fsp->file_id, mtime);
+}
+
+/******************************************************************
+ Update a write time immediately, without the 2 second delay.
+******************************************************************/
+
+bool update_write_time(struct files_struct *fsp)
+{
+ if (!set_write_time(fsp->file_id, timespec_current())) {
+ return false;
}
- return set_write_time_path(fsp->conn, fsp->fsp_name, fsp->file_id,
- mtime, overwrite);
+ notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
+ FILE_NOTIFY_CHANGE_LAST_WRITE, fsp->fsp_name);
+
+ return true;
}