[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jun 6 21:42:04 MDT 2014


The branch, master has been updated
       via  9c6f1a5 s3: libsmb: Change cli_disk_size() to use the trans2/SMB_FS_FULL_SIZE_INFORMATION call in preference to the old SMB1 call.
       via  d0a7d7e s3: libsmb: Make cli_smb2_dskattr() a 64-bit interface.
       via  66a04ba s3: libsmb : Move users of cli_dskattr to a 64-bit interface cli_disk_free().
       via  536c799 lib: tevent: make TEVENT_SIG_INCREMENT atomic.
      from  4633114 s3/s4: smbd, rpc, ldap, cldap, kdc services.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9c6f1a589ff56928b077904430086062e82b0acb
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 4 14:53:01 2014 -0700

    s3: libsmb: Change cli_disk_size() to use the trans2/SMB_FS_FULL_SIZE_INFORMATION call in preference to the old SMB1 call.
    
    Fallback to the old CORE protocol SMBdskattr if
    trans2/SMB_FS_FULL_SIZE_INFORMATION is not supported.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Jun  7 05:41:44 CEST 2014 on sn-devel-104

commit d0a7d7e87ece03a63840b0f143502075d6fa5527
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 4 14:19:30 2014 -0700

    s3: libsmb: Make cli_smb2_dskattr() a 64-bit interface.
    
    Remove the fallback call from cli_dskattr() (now it's
    not called from external client code).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>

commit 66a04ba7c115d3be111296000e93cc18a1a05ef6
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 4 14:12:38 2014 -0700

    s3: libsmb : Move users of cli_dskattr to a 64-bit interface cli_disk_free().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>

commit 536c799f00d7bdd6a574b6bdbc0e9c742eeef8b5
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jun 3 10:44:19 2014 -0700

    lib: tevent: make TEVENT_SIG_INCREMENT atomic.
    
    On arm platforms incrementing a variable is not
    an atomic operation, so may be interrupted by
    signal processing (if a signal interrupts another
    signal handler).
    
    Use compiler built-ins to make this atomic.
    __sync_fetch_and_add() works on gcc, llvm,
    IBM xlC on AIX, and Intel icc (10.1 and
    above).
    
    atomic_add_32() works on Oracle Solaris.
    
    Based on an inital patch from kamei at osstech.co.jp.
    
    Bug #10640 - smbd is not responding - tevent_common_signal_handler() increments non-atomic variables
    
    https://bugzilla.samba.org/show_bug.cgi?id=10640
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <Volker.Lendecke at SerNet.DE>

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

Summary of changes:
 lib/replace/replace.h          |    5 +++
 lib/replace/wscript            |   25 +++++++++++++
 lib/tevent/tevent_signal.c     |    6 +++
 source3/client/client.c        |   10 +++--
 source3/libsmb/cli_smb2_fnum.c |    8 ++--
 source3/libsmb/cli_smb2_fnum.h |    6 ++--
 source3/libsmb/clifile.c       |   75 +++++++++++++++++++++++++++++++++++++--
 source3/libsmb/proto.h         |    1 +
 source3/torture/nbio.c         |    4 +-
 9 files changed, 123 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index f940898..bc40bf0 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -904,4 +904,9 @@ bool nss_wrapper_hosts_enabled(void);
 bool socket_wrapper_enabled(void);
 bool uid_wrapper_enabled(void);
 
+/* Needed for Solaris atomic_add_XX functions. */
+#if defined(HAVE_SYS_ATOMIC_H)
+#include <sys/atomic.h>
+#endif
+
 #endif /* _LIBREPLACE_REPLACE_H */
diff --git a/lib/replace/wscript b/lib/replace/wscript
index a26de0f..22dd132 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -110,6 +110,7 @@ struct foo bar = { .y = 'X', .x = 1 };
     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
     conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
+    conf.CHECK_HEADERS('sys/atomic.h')
 
     # Check for process set name support
     conf.CHECK_CODE('''
@@ -229,6 +230,30 @@ struct foo bar = { .y = 'X', .x = 1 };
                        msg="Checking whether we have ucontext_t",
                        headers='signal.h sys/ucontext.h')
 
+    # Check for atomic builtins. */
+    conf.CHECK_CODE('''
+                    int main(void) {
+                        int i;
+                        (void)__sync_fetch_and_add(&i, 1);
+                        return 0;
+                    }
+                    ''',
+                    'HAVE___SYNC_FETCH_AND_ADD',
+                    msg='Checking for __sync_fetch_and_add compiler builtin')
+
+    conf.CHECK_CODE('''
+                    #include <stdint.h>
+                    #include <sys/atomic.h>
+                    int main(void) {
+                        int32_t i;
+                        atomic_add_32(&i, 1);
+                        return 0;
+                    }
+                    ''',
+                    'HAVE_ATOMIC_ADD_32',
+                    headers='stdint.h sys/atomic.h',
+                    msg='Checking for atomic_add_32 compiler builtin')
+
     # these may be builtins, so we need the link=False strategy
     conf.CHECK_FUNCS('strdup memmem printf memset memcpy memmove strcpy strncpy bzero', link=False)
 
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index 1ff4872..b54da2e 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -52,7 +52,13 @@ struct tevent_sigcounter {
 	uint32_t seen;
 };
 
+#if defined(HAVE___SYNC_FETCH_AND_ADD)
+#define TEVENT_SIG_INCREMENT(s) __sync_fetch_and_add(&((s).count), 1)
+#elif defined(HAVE_ATOMIC_ADD_32)
+#define TEVENT_SIG_INCREMENT(s) atomic_add_32(&((s).count), 1)
+#else
 #define TEVENT_SIG_INCREMENT(s) (s).count++
+#endif
 #define TEVENT_SIG_SEEN(s, n) (s).seen += (n)
 #define TEVENT_SIG_PENDING(s) ((s).seen != (s).count)
 
diff --git a/source3/client/client.c b/source3/client/client.c
index 592258d..17985b9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -298,7 +298,7 @@ static void send_message(const char *username)
 
 static int do_dskattr(void)
 {
-	int total, bsize, avail;
+	uint64_t total, bsize, avail;
 	struct cli_state *targetcli = NULL;
 	char *targetpath = NULL;
 	TALLOC_CTX *ctx = talloc_tos();
@@ -312,14 +312,16 @@ static int do_dskattr(void)
 		return 1;
 	}
 
-	status = cli_dskattr(targetcli, &bsize, &total, &avail);
+	status = cli_disk_size(targetcli, &bsize, &total, &avail);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("Error in dskattr: %s\n", nt_errstr(status));
 		return 1;
 	}
 
-	d_printf("\n\t\t%d blocks of size %d. %d blocks available\n",
-		 total, bsize, avail);
+	d_printf("\n\t\t%" PRIu64
+		" blocks of size %" PRIu64
+		". %" PRIu64 " blocks available\n",
+		total, bsize, avail);
 
 	return 0;
 }
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 8eb776a..950398a 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1411,7 +1411,7 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
  Synchronous only.
 ***************************************************************/
 
-NTSTATUS cli_smb2_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
+NTSTATUS cli_smb2_dskattr(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail)
 {
 	NTSTATUS status;
 	uint16_t fnum = 0xffff;
@@ -1492,13 +1492,13 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli, int *bsize, int *total, int *av
 	bytes_per_sector = IVAL(outbuf.data, 20);
 
 	if (bsize) {
-		*bsize = (int)(sectors_per_unit * bytes_per_sector);
+		*bsize = (uint64_t)sectors_per_unit * (uint64_t)bytes_per_sector;
 	}
 	if (total) {
-		*total = (int)total_size;
+		*total = total_size;
 	}
 	if (avail) {
-		*avail = (int)size_free;
+		*avail = size_free;
 	}
 
 	status = NT_STATUS_OK;
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 61a0f68..a5ed5a0 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -100,9 +100,9 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
                         time_t access_time,
                         time_t write_time);
 NTSTATUS cli_smb2_dskattr(struct cli_state *cli,
-			int *bsize,
-			int *total,
-			int *avail);
+			uint64_t *bsize,
+			uint64_t *total,
+			uint64_t *avail);
 NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli,
 			uint16_t fnum,
 			uint32_t sec_info,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 70b769d..1c52730 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -4094,10 +4094,6 @@ NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
 	struct tevent_req *req = NULL;
 	NTSTATUS status = NT_STATUS_OK;
 
-	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-		return cli_smb2_dskattr(cli, bsize, total, avail);
-	}
-
 	frame = talloc_stackframe();
 
 	if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -4132,6 +4128,77 @@ NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
 	return status;
 }
 
+NTSTATUS cli_disk_size(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail)
+{
+	uint64_t sectors_per_block;
+	uint64_t bytes_per_sector;
+	int old_bsize, old_total, old_avail;
+	NTSTATUS status;
+
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		return cli_smb2_dskattr(cli, bsize, total, avail);
+	}
+
+	/*
+	 * Try the trans2 disk full size info call first.
+	 * We already use this in SMBC_fstatvfs_ctx().
+	 * Ignore 'actual_available_units' as we only
+	 * care about the quota for the caller.
+	 */
+
+	status = cli_get_fs_full_size_info(cli,
+			total,
+			avail,
+			NULL,
+			&sectors_per_block,
+			&bytes_per_sector);
+
+        /* Try and cope will all varients of "we don't do this call"
+           and fall back to cli_dskattr. */
+
+	if (NT_STATUS_EQUAL(status,NT_STATUS_NOT_IMPLEMENTED) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_NOT_SUPPORTED) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_INFO_CLASS) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_PROCEDURE_NOT_FOUND) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_LEVEL) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_PARAMETER) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_REQUEST) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_STATE) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_CTL_FILE_NOT_SUPPORTED) ||
+			NT_STATUS_EQUAL(status,NT_STATUS_UNSUCCESSFUL)) {
+		goto try_dskattr;
+	}
+
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (bsize) {
+		*bsize = sectors_per_block *
+			 bytes_per_sector;
+	}
+
+	return NT_STATUS_OK;
+
+  try_dskattr:
+
+	/* Old SMB1 core protocol fallback. */
+	status = cli_dskattr(cli, &old_bsize, &old_total, &old_avail);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+	if (bsize) {
+		*bsize = (uint64_t)old_bsize;
+	}
+	if (total) {
+		*total = (uint64_t)old_total;
+	}
+	if (avail) {
+		*avail = (uint64_t)old_avail;
+	}
+	return NT_STATUS_OK;
+}
+
 /****************************************************************************
  Create and open a temporary file.
 ****************************************************************************/
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 525625c..63d2df4 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -516,6 +516,7 @@ struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
 			  int *avail);
 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+NTSTATUS cli_disk_size(struct cli_state *cli, uint64_t *bsize, uint64_t *total, uint64_t *avail);
 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
 				struct tevent_context *ev,
 				struct cli_state *cli,
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index ba4fa95..55dd836 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -285,9 +285,9 @@ void nb_qfileinfo(int fnum)
 
 void nb_qfsinfo(int level)
 {
-	int bsize, total, avail;
+	uint64_t bsize, total, avail;
 	/* this is not the right call - we need cli_qfsinfo() */
-	cli_dskattr(c, &bsize, &total, &avail);
+	cli_disk_size(c, &bsize, &total, &avail);
 }
 
 static NTSTATUS find_fn(const char *mnt, struct file_info *finfo, const char *name,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list