[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-868-g5e5d2b2

Tim Prouty tprouty at samba.org
Fri Feb 13 21:00:57 GMT 2009


The branch, master has been updated
       via  5e5d2b2cfadaf3bf352dcc25b302b12c70803d1f (commit)
       via  6085ba3dec4fa616fca78c55b793cfd89ef272a8 (commit)
       via  dbe2588e4659579feec76b3e1d7c4595ecdf8242 (commit)
      from  ad07bb8dbd1c188d1c8840fd8aee893a11115140 (commit)

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


- Log -----------------------------------------------------------------
commit 5e5d2b2cfadaf3bf352dcc25b302b12c70803d1f
Author: Tim Prouty <tprouty at samba.org>
Date:   Fri Feb 13 10:58:54 2009 -0800

    s3 libsmbclient: Fix fstatvfs to be more portable
    
    The statvfs struct isn't guaranteed to be portable across operating
    systems.  Since libsmbclient isn't actually calling statvfs and just
    using the statvfs struct to store similar information, this patch adds
    a new portable smbc_statvfs struct.  This fixes a few of the failures
    in the build farm introduced by:
    ae259575c447e61665c8e7070c476914161b953f
    
    Derrell, please check.

commit 6085ba3dec4fa616fca78c55b793cfd89ef272a8
Author: Aravind Srinivasan <aravind.srinivasan at isilon.com>
Date:   Fri Feb 13 11:07:46 2009 -0800

    s3 OneFS: Add vfs implementation for SMB_VFS_GET_REAL_FILE_NAME

commit dbe2588e4659579feec76b3e1d7c4595ecdf8242
Author: todd stecher <todd.stecher at gmail.com>
Date:   Wed Feb 11 22:28:20 2009 -0800

    s3: Test module for perfcount system
    
    Add 'perfcount module = pc_test' to exercise this module. Results are
    logged into smb.log every 50 operations (configurable via smb.conf).

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

Summary of changes:
 examples/libsmbclient/testfstatvfs.c |    3 +-
 examples/libsmbclient/teststatvfs.c  |    3 +-
 source3/Makefile.in                  |    5 +
 source3/configure.in                 |    3 +-
 source3/include/libsmb_internal.h    |    4 +-
 source3/include/libsmbclient.h       |   25 ++-
 source3/libsmb/libsmb_compat.c       |    4 +-
 source3/libsmb/libsmb_stat.c         |    4 +-
 source3/modules/perfcount_test.c     |  363 ++++++++++++++++++++++++++++++++++
 source3/modules/vfs_onefs.c          |   41 ++++
 10 files changed, 439 insertions(+), 16 deletions(-)
 create mode 100644 source3/modules/perfcount_test.c


Changeset truncated at 500 lines:

diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c
index b4dafef..815afac 100644
--- a/examples/libsmbclient/testfstatvfs.c
+++ b/examples/libsmbclient/testfstatvfs.c
@@ -1,5 +1,4 @@
 #include <sys/types.h>
-#include <sys/statvfs.h>
 #include <stdio.h> 
 #include <unistd.h>
 #include <string.h> 
@@ -18,7 +17,7 @@ int main(int argc, char * argv[])
     char *          p;
     char            path[2048];
     struct stat     statbuf;
-    struct statvfs  statvfsbuf;
+    struct smbc_statvfs  statvfsbuf;
     
     smbc_init(get_auth_data_fn, debug); 
     
diff --git a/examples/libsmbclient/teststatvfs.c b/examples/libsmbclient/teststatvfs.c
index 8812002..b9509d2 100644
--- a/examples/libsmbclient/teststatvfs.c
+++ b/examples/libsmbclient/teststatvfs.c
@@ -1,5 +1,4 @@
 #include <sys/types.h>
-#include <sys/statvfs.h>
 #include <stdio.h> 
 #include <unistd.h>
 #include <string.h> 
@@ -18,7 +17,7 @@ int main(int argc, char * argv[])
     char *          p;
     char            path[2048];
     struct stat     statbuf;
-    struct statvfs  statvfsbuf;
+    struct smbc_statvfs  statvfsbuf;
     
     smbc_init(get_auth_data_fn, debug); 
     
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 144c81a..9bac719 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -668,6 +668,7 @@ VFS_ONEFS_OBJ = modules/vfs_onefs.o modules/onefs_acl.o modules/onefs_system.o \
 		modules/onefs_open.o modules/onefs_streams.o modules/onefs_dir.c \
 		modules/onefs_cbrl.o
 PERFCOUNT_ONEFS_OBJ = modules/perfcount_onefs.o
+PERFCOUNT_TEST_OBJ = modules/perfcount_test.o
 
 PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o
 
@@ -2562,6 +2563,10 @@ bin/pc_onefs. at SHLIBEXT@: $(BINARY_PREREQS) $(PERFCOUNT_ONEFS_OBJ)
 	@echo "Building plugin $@"
 	@$(SHLD_MODULE) $(PERFCOUNT_ONEFS_OBJ)
 
+bin/pc_test. at SHLIBEXT@: $(BINARY_PREREQS) $(PERFCOUNT_TEST_OBJ)
+	@echo "Building plugin $@"
+	@$(SHLD_MODULE) $(PERFCOUNT_TEST_OBJ)
+
 bin/registry. at SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/registry.o
 	@echo "Building plugin $@"
 	@$(SHLD_MODULE) libgpo/gpext/registry.o
diff --git a/source3/configure.in b/source3/configure.in
index 4ff4c7b..97f3511 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -421,7 +421,7 @@ default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho"
-   default_shared_modules="$default_shared_modules charset_weird"
+   default_shared_modules="$default_shared_modules charset_weird perfcount_test"
 fi
 
 #
@@ -6137,6 +6137,7 @@ SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
 SMB_MODULE(perfcount_onefs, \$(PERFCOUNT_ONEFS), "bin/pc_onefs.$SHLIBEXT", PERFCOUNT)
+SMB_MODULE(perfcount_test, \$(PERFCOUNT_TEST), "bin/pc_test.$SHLIBEXT", PERFCOUNT)
 SMB_SUBSYSTEM(PERFCOUNT,smbd/perfcount.o)
 
 SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT)
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 166685c..d3683eb 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -506,13 +506,13 @@ SMBC_fstat_ctx(SMBCCTX *context,
 int
 SMBC_statvfs_ctx(SMBCCTX *context,
                  char *path,
-                 struct statvfs *st);
+                 struct smbc_statvfs *st);
 
 
 int
 SMBC_fstatvfs_ctx(SMBCCTX *context,
                   SMBCFILE *file,
-                  struct statvfs *st);
+                  struct smbc_statvfs *st);
 
 
 /* Functions in libsmb_xattr.c */
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index d35d9de..3bea089 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -75,7 +75,6 @@ extern "C" {
 /* Make sure we have the following includes for now ... */
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
 #include <fcntl.h>
 #include <utime.h>
 
@@ -174,6 +173,22 @@ typedef enum smbc_smb_encrypt_level
     SMBC_ENCRYPTLEVEL_REQUIRE   = 2
 } smbc_smb_encrypt_level;
 
+/**
+ * Use a system independent statvfs struct for smbclient.
+ */
+struct smbc_statvfs {
+	fsblkcnt_t	f_bavail;
+	fsblkcnt_t	f_bfree;
+	fsblkcnt_t	f_blocks;
+	fsfilcnt_t	f_favail;
+	fsfilcnt_t	f_ffree;
+	fsfilcnt_t	f_files;
+	unsigned long	f_bsize;
+	unsigned long	f_flag;
+	unsigned long	f_frsize;
+	unsigned long	f_fsid;
+	unsigned long	f_namemax;
+};
 
 /**
  * Capabilities set in the f_flag field of struct statvfs, from
@@ -872,13 +887,13 @@ void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
 
 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
                                char *path,
-                               struct statvfs *st);
+                               struct smbc_statvfs *st);
 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
 
 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
                                 SMBCFILE *file,
-                                struct statvfs *st);
+                                struct smbc_statvfs *st);
 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
 
@@ -1640,7 +1655,7 @@ int smbc_fstat(int fd, struct stat *st);
  */
 int
 smbc_statvfs(char *url,
-             struct statvfs *st);
+             struct smbc_statvfs *st);
 
 /**@ingroup attribute
  * Get file system information via an file descriptor.
@@ -1663,7 +1678,7 @@ smbc_statvfs(char *url,
  */
 int
 smbc_fstatvfs(int fd,
-              struct statvfs *st);
+              struct smbc_statvfs *st);
 
 
 /**@ingroup attribute
diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c
index 56d113f..95485dc 100644
--- a/source3/libsmb/libsmb_compat.c
+++ b/source3/libsmb/libsmb_compat.c
@@ -331,14 +331,14 @@ smbc_fstat(int fd,
 
 int
 smbc_statvfs(char *path,
-             struct statvfs *st)
+             struct smbc_statvfs *st)
 {
         return smbc_getFunctionStatVFS(statcont)(statcont, path, st);
 }
 
 int
 smbc_fstatvfs(int fd,
-              struct statvfs *st)
+              struct smbc_statvfs *st)
 {
 	SMBCFILE * file = find_fd(fd);
         return smbc_getFunctionFstatVFS(statcont)(statcont, file, st);
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index d589f7e..0ad40e8 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -308,7 +308,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
 int
 SMBC_statvfs_ctx(SMBCCTX *context,
                  char *path,
-                 struct statvfs *st)
+                 struct smbc_statvfs *st)
 {
         int             ret;
         bool            bIsDir;
@@ -360,7 +360,7 @@ SMBC_statvfs_ctx(SMBCCTX *context,
 int
 SMBC_fstatvfs_ctx(SMBCCTX *context,
                   SMBCFILE *file,
-                  struct statvfs *st)
+                  struct smbc_statvfs *st)
 {
 	uint32 fs_attrs = 0;
 	struct cli_state *cli = file->srv->cli;
diff --git a/source3/modules/perfcount_test.c b/source3/modules/perfcount_test.c
new file mode 100644
index 0000000..e0954bf
--- /dev/null
+++ b/source3/modules/perfcount_test.c
@@ -0,0 +1,363 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Test module for perfcounters
+ *
+ * Copyright (C) Todd Stecher 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+
+#define PARM_PC_TEST_TYPE		"pc_test"
+#define PARM_DUMPON_COUNT		"count"
+#define PARM_DUMPON_COUNT_DEFAULT	50
+
+struct perfcount_test_identity {
+	uid_t uid;
+	char *user;
+	char *domain;
+};
+
+struct perfcount_test_counter {
+	int op;
+	int sub_op;
+	int ioctl;
+	uint64_t bytes_in;
+	uint64_t bytes_out;
+	int count;
+
+	struct perfcount_test_counter *next;
+	struct perfcount_test_counter *prev;
+};
+
+struct perfcount_test_context {
+
+	/* wip:  identity */
+	struct perfcount_test_identity *id;
+	struct perfcount_test_counter *ops;
+};
+
+#define MAX_OP 256
+struct perfcount_test_counter *g_list[MAX_OP];
+
+int count;
+
+/* determine frequency of dumping results */
+int count_mod = 1;
+
+static void perfcount_test_add_counters(struct perfcount_test_context *ctxt)
+{
+	struct perfcount_test_counter *head;
+	struct perfcount_test_counter *ptc;
+	struct perfcount_test_counter *tmp;
+	bool found;
+
+	for (ptc = ctxt->ops; ptc != NULL; ) {
+
+		found = false;
+
+		if (ptc->op > MAX_OP)
+			continue;
+
+		for (head = g_list[ptc->op]; head != NULL; head = head->next) {
+			if ((ptc->sub_op == head->sub_op) &&
+			    (ptc->ioctl == head->ioctl)) {
+				head->bytes_in += ptc->bytes_in;
+				head->bytes_out += ptc->bytes_out;
+				head->count++;
+				tmp = ptc->next;
+				DLIST_REMOVE(ctxt->ops, ptc);
+				SAFE_FREE(ptc);
+				ptc = tmp;
+				found = true;
+				break;
+			}
+		}
+
+		/* not in global tracking list - add it */
+		if (!found) {
+			tmp = ptc->next;
+			DLIST_REMOVE(ctxt->ops, ptc);
+			ptc->count = 1;
+			DLIST_ADD(g_list[ptc->op], ptc);
+			ptc = tmp;
+		}
+	}
+
+}
+
+#if 0
+
+static void perfcount_test_dump_id(struct perfcount_test_identity *id, int lvl)
+{
+	if (!id)
+		return;
+
+	DEBUG(lvl,("uid - %d\n", id->uid));
+	DEBUG(lvl,("user - %s\n", id->user));
+	DEBUG(lvl,("domain - %s\n", id->domain));
+}
+
+#endif
+
+static const char *trans_subop_table[] = {
+	"unknown", "trans:create", "trans:ioctl", "trans:set sd",
+	"trans:change notify", "trans: rename", "trans:get sd",
+	"trans:get quota", "trans:set quota"
+};
+
+static const char *trans2_subop_table[] = {
+	"trans2:open", "trans2:find first", "trans2:find next",
+	"trans2:q fsinfo", "trans2:set fsinfo", "trans2:q path info",
+	"trans2:set pathinfo", "trans2:fs ctl", "trans2: io ctl",
+	"trans2:find notify first", "trans2:find notify next",
+	"trans2:mkdir", "trans2:sess setup", "trans2:get dfs referral",
+	"trans2:report dfs inconsistent"
+};
+
+static const char *smb_subop_name(int op, int subop)
+{
+	/* trans */
+	if (op == 0x25) {
+		if (subop > sizeof(trans_subop_table) /
+		    sizeof(trans_subop_table[0])) {
+			return "unknown";
+		}
+		return trans_subop_table[subop];
+	} else if (op == 0x32) {
+		if (subop > sizeof(trans2_subop_table) /
+		    sizeof(trans2_subop_table[0])) {
+			return "unknown";
+		}
+		return trans2_subop_table[subop];
+	}
+
+	return "unknown";
+}
+
+static void perfcount_test_dump_counter(struct perfcount_test_counter *ptc,
+					int lvl)
+{
+	DEBUG(lvl, ("OP: %s\n", smb_fn_name(ptc->op)));
+	if (ptc->sub_op > 0) {
+		DEBUG(lvl, ("SUBOP: %s\n",
+			smb_subop_name(ptc->op, ptc->sub_op)));
+	}
+
+	if (ptc->ioctl > 0) {
+		DEBUG(lvl, ("IOCTL: %d\n", ptc->ioctl));
+	}
+
+	DEBUG(lvl, ("Count: %d\n\n", ptc->count));
+}
+
+static void perfcount_test_dump_counters(void)
+{
+	int i;
+	struct perfcount_test_counter *head;
+
+	count_mod = lp_parm_int(0, PARM_PC_TEST_TYPE, PARM_DUMPON_COUNT,
+	    PARM_DUMPON_COUNT_DEFAULT);
+
+	if ((count++ % count_mod) != 0)
+		return;
+
+	DEBUG(0,("#####  Dumping Performance Counters #####\n"));
+
+	for (i=0; i < 256; i++) {
+	       for (head = g_list[i]; head != NULL; head = head->next) {
+		       perfcount_test_dump_counter(head, 0);
+		       head->prev = NULL;
+		       SAFE_FREE(head->prev);
+	       }
+	       SAFE_FREE(head);
+	}
+}
+
+/*  operations */
+static void perfcount_test_start(struct smb_perfcount_data *pcd)
+{
+	struct perfcount_test_context *ctxt;
+	struct perfcount_test_counter *ctr;
+	/*
+	 * there shouldn't already be a context here - if so,
+	 * there's an unbalanced call to start / end.
+	 */
+	if (pcd->context) {
+		DEBUG(0,("perfcount_test_start - starting "
+			 "initialized context - %p\n", pcd));
+		return;
+	}
+
+	ctxt = SMB_MALLOC_P(struct perfcount_test_context);
+	if (!ctxt)
+		return;
+
+	ZERO_STRUCTP(ctxt);
+
+	/* create 'default' context */
+	ctr = SMB_MALLOC_P(struct perfcount_test_counter);
+	if (!ctr) {
+		SAFE_FREE(ctxt);
+		return;
+	}
+
+	ZERO_STRUCTP(ctr);
+	ctr->op = ctr->sub_op = ctr->ioctl = -1;
+	DLIST_ADD(ctxt->ops, ctr);
+
+	pcd->context = (void*)ctxt;
+}
+
+static void perfcount_test_add(struct smb_perfcount_data *pcd)
+{
+	struct perfcount_test_context *ctxt = pcd->context;
+	struct perfcount_test_counter *ctr;
+
+        if (pcd->context == NULL) {
+		DEBUG(0,("perfcount_test_add - uninitialized "
+			"perfcount context - %p\n", pcd));
+                return;
+	}
+
+	ctr = SMB_MALLOC_P(struct perfcount_test_counter);
+	if (!ctr) {
+		return;
+	}
+
+	DLIST_ADD(ctxt->ops, ctr);
+
+}
+
+static void perfcount_test_set_op(struct smb_perfcount_data *pcd, int op)
+{
+	struct perfcount_test_context *ctxt = pcd->context;
+
+        if (pcd->context == NULL) {
+		DEBUG(0,("perfcount_test_set_op - uninitialized "
+			"perfcount context - %p\n", pcd));
+                return;
+	}
+
+	ctxt->ops->op = op;
+}
+
+static void perfcount_test_set_subop(struct smb_perfcount_data *pcd, int sub_op)
+{
+	struct perfcount_test_context *ctxt = pcd->context;
+
+        if (pcd->context == NULL) {
+		DEBUG(0,("perfcount_test_set_sub_op - uninitialized "
+			"perfcount context - %p\n", pcd));
+                return;
+	}
+
+	ctxt->ops->sub_op = sub_op;
+}
+
+static void perfcount_test_set_ioctl(struct smb_perfcount_data *pcd, int io_ctl)
+{
+	struct perfcount_test_context *ctxt = pcd->context;
+        if (pcd->context == NULL) {
+		DEBUG(0,("perfcount_test_set_ioctl - uninitialized "
+			"perfcount context - %p\n", pcd));
+                return;
+	}
+	ctxt->ops->ioctl = io_ctl;
+}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list