The branch, v3-6-test has been updated via 7543ee4 s3: Add a vfs_time_audit module via 4a6d708 s3: Fix bug 7759 from d7ea0f9 Fix for bug 7755 - SMBC_getdents_ctx() ignores struct alignment rules
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test - Log ----------------------------------------------------------------- commit 7543ee478021db6f3a6bbdebc897a09aea565876 Author: Abhidnya P Chirmule <achir...@in.ibm.com> Date: Wed Jan 6 19:45:24 2010 +0100 s3: Add a vfs_time_audit module This warns if a file system is slow Autobuild-User: Volker Lendecke <vlen...@samba.org> Autobuild-Date: Thu Oct 28 08:56:44 UTC 2010 on sn-devel-104 commit 4a6d70875ab0923b3888d5f4e0b43de83b74983f Author: Volodymyr Khomenko <volodymyr_khome...@dell.com> Date: Thu Oct 28 09:34:05 2010 +0200 s3: Fix bug 7759 ----------------------------------------------------------------------- Summary of changes: packaging/RHEL-CTDB/samba.spec.tmpl | 1 + source3/Makefile.in | 5 + source3/configure.in | 2 + source3/modules/vfs_default.c | 34 +- source3/modules/vfs_time_audit.c | 2306 +++++++++++++++++++++++++++++++++++ 5 files changed, 2332 insertions(+), 16 deletions(-) create mode 100644 source3/modules/vfs_time_audit.c Changeset truncated at 500 lines: diff --git a/packaging/RHEL-CTDB/samba.spec.tmpl b/packaging/RHEL-CTDB/samba.spec.tmpl index 2f32d3d..7ff37fb 100644 --- a/packaging/RHEL-CTDB/samba.spec.tmpl +++ b/packaging/RHEL-CTDB/samba.spec.tmpl @@ -495,6 +495,7 @@ exit 0 %{_libarchdir}/samba/vfs/streams_depot.so %{_libarchdir}/samba/vfs/streams_xattr.so %{_libarchdir}/samba/vfs/syncops.so +%{_libarchdir}/samba/vfs/time_audit.so %{_libarchdir}/samba/vfs/tsmsm.so %{_libarchdir}/samba/vfs/xattr_tdb.so diff --git a/source3/Makefile.in b/source3/Makefile.in index 45dd891..d44bd6f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -814,6 +814,7 @@ VFS_DIRSORT_OBJ = modules/vfs_dirsort.o VFS_SCANNEDONLY_OBJ = modules/vfs_scannedonly.o VFS_CROSSRENAME_OBJ = modules/vfs_crossrename.o VFS_LINUX_XFS_SGID_OBJ = modules/vfs_linux_xfs_sgid.o +VFS_TIME_AUDIT_OBJ = modules/vfs_time_audit.o PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o @@ -2988,6 +2989,10 @@ bin/linux_xfs_sg...@shlibext@: $(BINARY_PREREQS) $(VFS_LINUX_XFS_SGID_OBJ) @echo "Building plugin $@" @$(SHLD_MODULE) $(VFS_LINUX_XFS_SGID_OBJ) +bin/time_aud...@shlibext@: $(BINARY_PREREQS) $(VFS_TIME_AUDIT_OBJ) + @echo "Building plugin $@" + @$(SHLD_MODULE) $(VFS_TIME_AUDIT_OBJ) + ######################################################### ## IdMap NSS plugins diff --git a/source3/configure.in b/source3/configure.in index 2bc9137..6b6dabb 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -459,6 +459,7 @@ default_shared_modules="$default_shared_modules vfs_catia" default_shared_modules="$default_shared_modules vfs_scannedonly" default_shared_modules="$default_shared_modules vfs_crossrename" default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid" +default_shared_modules="$default_shared_modules vfs_time_audit" if test "x$developer" = xyes; then default_static_modules="$default_static_modules rpc_rpcecho pdb_ads" @@ -6763,6 +6764,7 @@ SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS) SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS) SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS) SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS) +SMB_MODULE(vfs_time_audit, \$(VFS_TIME_AUDIT_OBJ), "bin/time_audit.$SHLIBEXT", VFS) SMB_SUBSYSTEM(VFS,smbd/vfs.o) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 2cbb84c..6f5b09a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -754,25 +754,27 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, goto out; } - if (null_timespec(ft->atime)) { - ft->atime= smb_fname->st.st_ex_atime; - } + if (ft != NULL) { + if (null_timespec(ft->atime)) { + ft->atime= smb_fname->st.st_ex_atime; + } - if (null_timespec(ft->mtime)) { - ft->mtime = smb_fname->st.st_ex_mtime; - } + if (null_timespec(ft->mtime)) { + ft->mtime = smb_fname->st.st_ex_mtime; + } - if (!null_timespec(ft->create_time)) { - set_create_timespec_ea(handle->conn, - smb_fname, - ft->create_time); - } + if (!null_timespec(ft->create_time)) { + set_create_timespec_ea(handle->conn, + smb_fname, + ft->create_time); + } - if ((timespec_compare(&ft->atime, - &smb_fname->st.st_ex_atime) == 0) && - (timespec_compare(&ft->mtime, - &smb_fname->st.st_ex_mtime) == 0)) { - return 0; + if ((timespec_compare(&ft->atime, + &smb_fname->st.st_ex_atime) == 0) && + (timespec_compare(&ft->mtime, + &smb_fname->st.st_ex_mtime) == 0)) { + return 0; + } } #if defined(HAVE_UTIMENSAT) diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c new file mode 100644 index 0000000..b510edb --- /dev/null +++ b/source3/modules/vfs_time_audit.c @@ -0,0 +1,2306 @@ +/* + * Time auditing VFS module for samba. Log time taken for VFS call to syslog + * facility. + * + * Copyright (C) Abhidnya Chirmule <achir...@in.ibm.com> 2009 + * + * 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/>. + */ + +/* + * This module implements logging for time taken for all Samba VFS operations. + * + * vfs objects = time_audit + */ + + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +static double audit_timeout; + +static void smb_time_audit_log(const char *syscallname, double elapsed) +{ + DEBUG(0, ("WARNING: System call \"%s\" took unexpectedly long " + "(%.2f seconds) -- Validate that file and storage " + "subsystems are operating normally\n", syscallname, + elapsed)); +} + +static int smb_time_audit_connect(vfs_handle_struct *handle, + const char *svc, const char *user) +{ + int result; + struct timeval tv; + double timediff; + + if (!handle) { + return -1; + } + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_CONNECT(handle, svc, user); + timediff = timeval_elapsed(&tv); + if (timediff > audit_timeout) { + smb_time_audit_log("connect", timediff); + } + return result; +} + +static void smb_time_audit_disconnect(vfs_handle_struct *handle) +{ + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + SMB_VFS_NEXT_DISCONNECT(handle); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("disconnect", timediff); + } + + return; +} + +static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle, + const char *path, + bool small_query, uint64_t *bsize, + uint64_t *dfree, uint64_t *dsize) +{ + uint64_t result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, + dfree, dsize); + timediff = timeval_elapsed(&tv); + + /* Don't have a reasonable notion of failure here */ + if (timediff > audit_timeout) { + smb_time_audit_log("disk_free", timediff); + } + + return result; +} + +static int smb_time_audit_get_quota(struct vfs_handle_struct *handle, + enum SMB_QUOTA_TYPE qtype, unid_t id, + SMB_DISK_QUOTA *qt) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("get_quota", timediff); + } + return result; +} + +static int smb_time_audit_set_quota(struct vfs_handle_struct *handle, + enum SMB_QUOTA_TYPE qtype, unid_t id, + SMB_DISK_QUOTA *qt) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("set_quota", timediff); + } + + return result; +} + +static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, + struct files_struct *fsp, + SHADOW_COPY_DATA *shadow_copy_data, + bool labels) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, + shadow_copy_data, labels); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("get_shadow_copy_data", timediff); + } + + return result; +} + +static int smb_time_audit_statvfs(struct vfs_handle_struct *handle, + const char *path, + struct vfs_statvfs_struct *statbuf) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("statvfs", timediff); + } + + return result; +} + +static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle, + enum timestamp_set_resolution *p_ts_res) +{ + uint32_t result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("fs_capabilities", timediff); + } + + return result; +} + +static SMB_STRUCT_DIR *smb_time_audit_opendir(vfs_handle_struct *handle, + const char *fname, + const char *mask, uint32 attr) +{ + SMB_STRUCT_DIR *result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("opendir", timediff); + } + + return result; +} + +static SMB_STRUCT_DIRENT *smb_time_audit_readdir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp, + SMB_STRUCT_STAT *sbuf) +{ + SMB_STRUCT_DIRENT *result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("readdir", timediff); + } + + return result; +} + +static void smb_time_audit_seekdir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp, long offset) +{ + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("seekdir", timediff); + } + + return; +} + +static long smb_time_audit_telldir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp) +{ + long result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_TELLDIR(handle, dirp); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("telldir", timediff); + } + + return result; +} + +static void smb_time_audit_rewinddir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp) +{ + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + SMB_VFS_NEXT_REWINDDIR(handle, dirp); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("rewinddir", timediff); + } + + return; +} + +static int smb_time_audit_mkdir(vfs_handle_struct *handle, + const char *path, mode_t mode) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_MKDIR(handle, path, mode); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("mkdir", timediff); + } + + return result; +} + +static int smb_time_audit_rmdir(vfs_handle_struct *handle, + const char *path) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_RMDIR(handle, path); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("rmdir", timediff); + } + + return result; +} + +static int smb_time_audit_closedir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("closedir", timediff); + } + + return result; +} + +static void smb_time_audit_init_search_op(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp) +{ + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("init_search_op", timediff); + } + return; +} + +static int smb_time_audit_open(vfs_handle_struct *handle, + struct smb_filename *fname, + files_struct *fsp, + int flags, mode_t mode) +{ + int result; + struct timeval tv; + double timediff; + + GetTimeOfDay(&tv); + result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + timediff = timeval_elapsed(&tv); + + if (timediff > audit_timeout) { + smb_time_audit_log("open", timediff); + } + + return result; +} + +static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle, + struct smb_request *req, + uint16_t root_dir_fid, + struct smb_filename *fname, + uint32_t access_mask, + uint32_t share_access, + uint32_t create_disposition, + uint32_t create_options, + uint32_t file_attributes, + uint32_t oplock_request, + uint64_t allocation_size, + uint32_t private_flags, + struct security_descriptor *sd, + struct ea_list *ea_list, + files_struct **result_fsp, + int *pinfo) -- Samba Shared Repository