[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-3-58-g25f85bd

Karolin Seeger kseeger at samba.org
Tue Sep 9 11:25:52 GMT 2008


The branch, v3-2-stable has been updated
       via  25f85bdc7a23697757905fa5f44baeaab23bcbfb (commit)
       via  4782c3ad8d661697646fcb093cc0d2708500c16e (commit)
       via  ef6697435efba2afe15498caeb5daae7aea10604 (commit)
       via  db306bfee30437d2858788ea783ccb5acabd1ffa (commit)
       via  d8e7a10a984587fabe6df26983b8defa1fd8c144 (commit)
       via  359b252b72da0f60ff5c549c65b75aa32e0e9cbf (commit)
      from  2436662f0f60ec4d29ebe3074e63a5995d89bd59 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit 25f85bdc7a23697757905fa5f44baeaab23bcbfb
Author: Karolin Seeger <kseeger at samba.org>
Date:   Tue Sep 9 13:23:28 2008 +0200

    WHATSNEW: Update changes since 3.2.3.
    
    Karolin
    (cherry picked from commit 903868a474d4875807a131dffe74b5090c0dbcea)

commit 4782c3ad8d661697646fcb093cc0d2708500c16e
Author: Volker Lendecke <vl at sernet.de>
Date:   Mon Sep 8 22:53:50 2008 +0200

    Fix calculation of useable_space for trans2 and nttrans replies
    
    When alignment was in place, we pretended to send more data/params according to
    the param_offset/param_length and data_offset/data_length parameters than would
    actually fit into the SMB according to the NBSS length field.
    (cherry picked from commit 2ae870aead5e0ea7e7f9f6f9730f989ae34755b9)

commit ef6697435efba2afe15498caeb5daae7aea10604
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Sep 8 15:12:24 2008 +0200

    smbd: some write time fixes
    
    - only the first non truncating write causes
      the write time update with 2 seconds delay.
      It's not enough to check for an existing update event
      as it will be NULL after the event was triggered.
    
    - SMBwrite truncates always update the write time
      unless the sticky write time is set.
    
    - SMBwrite truncates don't trigger a write time update on close.
    
    metze
    (cherry picked from commit 142a9703ae19a467a23ee72429f899dae156df64)

commit db306bfee30437d2858788ea783ccb5acabd1ffa
Author: Volker Lendecke <vl at sernet.de>
Date:   Mon Sep 8 16:42:06 2008 +0200

    When setting an NFSv4 ACL, map generic bits
    (cherry picked from commit dbe7a61be2beac50d1665e38ac374cefbbabec00)
    (cherry picked from commit c2faa48abce1d656527b89f601e084e3ba70e36d)

commit d8e7a10a984587fabe6df26983b8defa1fd8c144
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 5 20:40:02 2008 -0700

    Fix debug message to show correct function name.
    Jeremy.
    (cherry picked from commit b2fcb8b6b17302e5ec29914f4e3dde853ffe5283)

commit 359b252b72da0f60ff5c549c65b75aa32e0e9cbf
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 5 19:01:09 2008 -0700

    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.
    (cherry picked from commit f2fb6321b6666a30ca7fa11bc8d395f1a1865bb2)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt               |    7 ++++++
 source/locking/locking.c   |   33 +++++++++++++++++++++++----
 source/modules/nfs4_acls.c |    4 +++
 source/smbd/dosmode.c      |   52 +++++++++++++++++++++++++++-----------------
 source/smbd/fileio.c       |   42 ++++++++++++++++++++++++++++++-----
 source/smbd/nttrans.c      |   22 ++++++++----------
 source/smbd/reply.c        |    6 +++-
 source/smbd/trans2.c       |   27 +++++++++++++---------
 8 files changed, 137 insertions(+), 56 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 9b31f35..7af5981 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -34,6 +34,7 @@ o   Jeremy Allison <jra at samba.org>
     * Fix the wcache_invalidate_samlogon calls.
     * Add st_birthtime and friends for accurate create times on *BSD and MacOSX.
     * Clarify usage of "force create mode".
+    * Write times code update.
 
 
 o   Gerald (Jerry) Carter <jerry at samba.org>
@@ -65,7 +66,13 @@ o   Jeff Layton <jlayton at redhat.com>
 
 o   Volker Lendecke <vl at sernet.de>
     * BUG 5707: Do proper error handling if the socket is closed.
+    * Fix calculation of useable_space for trans2 and nttrans replies.
     * Fix Coverity ID 587.
+    * Add mapping of generic bits when setting an NFSv4 ACL.
+
+
+o   Stefan Metzmacher <metze at samba.org>
+    * Some write time fixes.
 
 
 o   David Leonard <David.Leonard at quest.com>
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 4ee0a19..85bacd1 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -1409,22 +1409,21 @@ bool set_allow_initial_delete_on_close(struct share_mode_lock *lck, files_struct
 	return True;
 }
 
-bool set_write_time(struct file_id fileid, struct timespec write_time,
-		    bool overwrite)
+bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
 {
 	struct share_mode_lock *lck;
 
-	DEBUG(5,("set_write_time: %s overwrite=%d id=%s\n",
+	DEBUG(5,("set_sticky_write_time: %s id=%s\n",
 		 timestring(debug_ctx(),
 			    convert_timespec_to_time_t(write_time)),
-		 overwrite, file_id_string_tos(&fileid)));
+		 file_id_string_tos(&fileid)));
 
 	lck = get_share_mode_lock(NULL, fileid, NULL, NULL, NULL);
 	if (lck == NULL) {
 		return False;
 	}
 
-	if (overwrite || null_timespec(lck->changed_write_time)) {
+	if (timespec_compare(&lck->changed_write_time, &write_time) != 0) {
 		lck->modified = True;
 		lck->changed_write_time = write_time;
 	}
@@ -1433,6 +1432,30 @@ bool set_write_time(struct file_id fileid, struct timespec write_time,
 	return True;
 }
 
+bool set_write_time(struct file_id fileid, struct timespec write_time)
+{
+	struct share_mode_lock *lck;
+
+	DEBUG(5,("set_write_time: %s id=%s\n",
+		 timestring(debug_ctx(),
+			    convert_timespec_to_time_t(write_time)),
+		 file_id_string_tos(&fileid)));
+
+	lck = get_share_mode_lock(NULL, fileid, NULL, NULL, NULL);
+	if (lck == NULL) {
+		return False;
+	}
+
+	if (timespec_compare(&lck->old_write_time, &write_time) != 0) {
+		lck->modified = True;
+		lck->old_write_time = write_time;
+	}
+
+	TALLOC_FREE(lck);
+	return True;
+}
+
+
 struct forall_state {
 	void (*fn)(const struct share_mode_entry *entry,
 		   const char *sharepath,
diff --git a/source/modules/nfs4_acls.c b/source/modules/nfs4_acls.c
index 0c3d010..5e90afa 100644
--- a/source/modules/nfs4_acls.c
+++ b/source/modules/nfs4_acls.c
@@ -25,6 +25,8 @@
 
 #define SMBACL4_PARAM_TYPE_NAME "nfs4"
 
+extern const struct generic_mapping file_generic_mapping;
+
 #define SMB_ACE4_INT_MAGIC 0x76F8A967
 typedef struct _SMB_ACE4_INT_T
 {
@@ -529,6 +531,8 @@ static bool smbacl4_fill_ace4(
 	ace_v4->aceMask = ace_nt->access_mask &
 		(STD_RIGHT_ALL_ACCESS | SA_RIGHT_FILE_ALL_ACCESS);
 
+	se_map_generic(&ace_v4->aceMask, &file_generic_mapping);
+
 	if (ace_v4->aceFlags!=ace_nt->flags)
 		DEBUG(9, ("ace_v4->aceFlags(0x%x)!=ace_nt->flags(0x%x)\n",
 			ace_v4->aceFlags, ace_nt->flags));
diff --git a/source/smbd/dosmode.c b/source/smbd/dosmode.c
index 0ac3873..88c6a51 100644
--- a/source/smbd/dosmode.c
+++ b/source/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;
 }
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c
index 64cea7f..0958418 100644
--- a/source/smbd/fileio.c
+++ b/source/smbd/fileio.c
@@ -176,25 +176,36 @@ static void update_write_time_handler(struct event_context *ctx,
 				      const struct timeval *now,
 				      void *private_data)
 {
-       files_struct *fsp = (files_struct *)private_data;
+	files_struct *fsp = (files_struct *)private_data;
 
-       /* Remove the timed event handler. */
-       TALLOC_FREE(fsp->update_write_time_event);
-       DEBUG(5, ("Update write time on %s\n", fsp->fsp_name));
+	/* Remove the timed event handler. */
+	TALLOC_FREE(fsp->update_write_time_event);
+	DEBUG(5, ("Update write time on %s\n", fsp->fsp_name));
 
-       /* change the write time if not already changed by someoneelse */
-       set_write_time_fsp(fsp, timespec_current(), false);
+	/* change the write time if not already changed by someone else */
+	update_write_time(fsp);
 }
 
+/*********************************************************
+ Schedule a write time update for WRITE_TIME_UPDATE_USEC_DELAY
+ in the future.
+*********************************************************/
+
 void trigger_write_time_update(struct files_struct *fsp)
 {
 	int delay;
 
 	if (fsp->write_time_forced) {
+		/* No point - "sticky" write times
+		 * in effect.
+		 */
 		return;
 	}
 
 	if (fsp->update_write_time_triggered) {
+		/*
+		 * No point - an event is already scheduled.
+		 */
 		return;
 	}
 	fsp->update_write_time_triggered = true;
@@ -212,6 +223,25 @@ void trigger_write_time_update(struct files_struct *fsp)
 				update_write_time_handler, fsp);
 }
 
+void trigger_write_time_update_immediate(struct files_struct *fsp)
+{
+        if (fsp->write_time_forced) {
+		/*
+		 * No point - "sticky" write times
+		 * in effect.
+		 */
+                return;
+        }
+
+	TALLOC_FREE(fsp->update_write_time_event);
+	DEBUG(5, ("Update write time immediate on %s\n", fsp->fsp_name));
+
+	fsp->update_write_time_triggered = true;
+
+        fsp->update_write_time_on_close = false;
+	update_write_time(fsp);
+}
+
 /****************************************************************************
  Write to a file.
 ****************************************************************************/
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index 0b48fa2..13caf77 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -113,14 +113,11 @@ void send_nt_replies(connection_struct *conn,
 				    + alignment_offset
 				    + data_alignment_offset);
 
-	/*
-	 * useable_space can never be more than max_send minus the
-	 * alignment offset.
-	 */
-
-	useable_space = MIN(useable_space,
-				max_send - (alignment_offset+data_alignment_offset));
-
+	if (useable_space < 0) {
+		DEBUG(0, ("send_nt_replies failed sanity useable_space "
+			  "= %d!!!", useable_space));
+		exit_server_cleanly("send_nt_replies: srv_send_smb failed.");
+	}
 
 	while (params_to_send || data_to_send) {
 
@@ -128,8 +125,7 @@ void send_nt_replies(connection_struct *conn,
 		 * Calculate whether we will totally or partially fill this packet.
 		 */
 
-		total_sent_thistime = params_to_send + data_to_send +
-					alignment_offset + data_alignment_offset;
+		total_sent_thistime = params_to_send + data_to_send;
 
 		/*
 		 * We can never send more than useable_space.
@@ -137,7 +133,9 @@ void send_nt_replies(connection_struct *conn,
 
 		total_sent_thistime = MIN(total_sent_thistime, useable_space);
 
-		reply_outbuf(req, 18, total_sent_thistime);
+		reply_outbuf(req, 18,
+			     total_sent_thistime + alignment_offset
+			     + data_alignment_offset);
 
 		/*
 		 * Set total params and data to be sent.
@@ -264,7 +262,7 @@ void send_nt_replies(connection_struct *conn,
 		if(params_to_send < 0 || data_to_send < 0) {
 			DEBUG(0,("send_nt_replies failed sanity check pts = %d, dts = %d\n!!!",
 				params_to_send, data_to_send));
-			return;
+			exit_server_cleanly("send_nt_replies: internal error");
 		}
 	}
 }
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 67b382d..466fef9 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -3783,9 +3783,11 @@ void reply_write(struct smb_request *req)
 			END_PROFILE(SMBwrite);
 			return;
 		}
-	} else
+		trigger_write_time_update_immediate(fsp);
+	} else {
 		nwritten = write_file(req,fsp,data,startpos,numtowrite);
-  
+	}
+
 	status = sync_file(conn, fsp, False);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(5,("reply_write: sync_file for %s returned %s\n",
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 41f2a15..7753fad 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -737,14 +737,16 @@ void send_trans2_replies(connection_struct *conn,
 				    + alignment_offset
 				    + data_alignment_offset);
 
-	/* useable_space can never be more than max_send minus the alignment offset. */
-
-	useable_space = MIN(useable_space, max_send - (alignment_offset+data_alignment_offset));
+	if (useable_space < 0) {
+		DEBUG(0, ("send_trans2_replies failed sanity useable_space "
+			  "= %d!!!", useable_space));
+		exit_server_cleanly("send_trans2_replies: Not enough space");
+	}
 
 	while (params_to_send || data_to_send) {
 		/* Calculate whether we will totally or partially fill this packet */
 
-		total_sent_thistime = params_to_send + data_to_send + alignment_offset + data_alignment_offset;
+		total_sent_thistime = params_to_send + data_to_send;
 
 		/* We can never send more than useable_space */
 		/*
@@ -754,9 +756,10 @@ void send_trans2_replies(connection_struct *conn,
 		 * are sent here. Fix from Marc_Jacobsen at hp.com.
 		 */
 
-		total_sent_thistime = MIN(total_sent_thistime, useable_space+ alignment_offset + data_alignment_offset);
+		total_sent_thistime = MIN(total_sent_thistime, useable_space);
 
-		reply_outbuf(req, 10, total_sent_thistime);
+		reply_outbuf(req, 10, total_sent_thistime + alignment_offset
+			     + data_alignment_offset);
 
 		/* Set total params and data to be sent */
 		SSVAL(req->outbuf,smb_tprcnt,paramsize);
@@ -4884,11 +4887,11 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
 			  time_to_asc(convert_timespec_to_time_t(ts[1])) ));
 
 		if (fsp != NULL) {
-			set_write_time_fsp(fsp, ts[1], true);
+			set_sticky_write_time_fsp(fsp, ts[1]);
 		} else {
-			set_write_time_path(conn, fname,
+			set_sticky_write_time_path(conn, fname,
 					    vfs_file_id_from_sbuf(conn, psbuf),
-					    ts[1], true);
+					    ts[1]);
 		}
 	}
 
@@ -4972,6 +4975,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
 		if (vfs_set_filelen(fsp, size) == -1) {
 			return map_nt_error_from_unix(errno);
 		}
+		trigger_write_time_update_immediate(fsp);
 		return NT_STATUS_OK;
 	}
 
@@ -4995,6 +4999,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
 		return status;
 	}
 
+	trigger_write_time_update_immediate(new_fsp);
 	close_file(new_fsp,NORMAL_CLOSE);
 	return NT_STATUS_OK;
 }
@@ -5720,7 +5725,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
 		 * This is equivalent to a write. Ensure it's seen immediately
 		 * if there are no pending writes.
 		 */
-		trigger_write_time_update(fsp);
+		trigger_write_time_update_immediate(fsp);
 		return NT_STATUS_OK;
 	}
 
@@ -5754,7 +5759,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
 	 * This is equivalent to a write. Ensure it's seen immediately
 	 * if there are no pending writes.
 	 */
-	trigger_write_time_update(new_fsp);
+	trigger_write_time_update_immediate(new_fsp);
 
 	close_file(new_fsp,NORMAL_CLOSE);
 	return NT_STATUS_OK;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list