summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-05 18:50:18 +0000
committerJeremy Allison <jra@samba.org>2000-10-05 18:50:18 +0000
commitbbd7f7bf0fd4f6cda41989c3371d7bf18f49a592 (patch)
tree63e4f012a5cab611ca74f0ec2b4b8b97d6a1b7be
parentfde7328900a6bef12aa93d11f5dc3e0838f2f7fc (diff)
downloadsamba-bbd7f7bf0fd4f6cda41989c3371d7bf18f49a592.tar.gz
samba-bbd7f7bf0fd4f6cda41989c3371d7bf18f49a592.tar.bz2
samba-bbd7f7bf0fd4f6cda41989c3371d7bf18f49a592.zip
Herb's fixes for profiling & compiler warnings.
Jeremy. (This used to be commit 7914e9351abb5271ebb4990c3b1fe495d15a4eda)
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/include/smb.h3
-rw-r--r--source3/smbd/fileio.c116
-rw-r--r--source3/tdb/tdb.c2
4 files changed, 72 insertions, 52 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 0959218ae6..8d061f2522 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3862,14 +3862,13 @@ char *vfswrap_getwd(char *path);
int vfswrap_utime(char *path, struct utimbuf *times);
int vfswrap_ftruncate(int fd, SMB_OFF_T offset);
BOOL vfswrap_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
-size_t vfswrap_get_nt_acl(files_struct *fsp, SEC_DESC **ppdesc);
-BOOL vfswrap_set_nt_acl(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd);
/*The following definitions come from smbd/vfs.c */
int vfs_init_default(connection_struct *conn);
BOOL vfs_init_custom(connection_struct *conn);
int vfs_stat(connection_struct *conn, char *fname, SMB_STRUCT_STAT *st);
+int vfs_fstat(connection_struct *conn, int fd, SMB_STRUCT_STAT *st);
BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
int vfs_unlink(connection_struct *conn, char *fname);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index c869650373..02ef940085 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -622,8 +622,7 @@ struct current_user
#define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
- OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
-
+ OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
/* Defines for the sent_oplock_break field above. */
#define NO_BREAK_SENT 0
#define EXCLUSIVE_BREAK_SENT 1
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 3ebc46e86b..0c43a255dc 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -70,7 +70,6 @@ SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
Read from write cache if we can.
****************************************************************************/
-static unsigned int cache_read_hits;
BOOL read_from_write_cache(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
{
@@ -84,7 +83,9 @@ BOOL read_from_write_cache(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
memcpy(data, wcp->data + (pos - wcp->offset), n);
- cache_read_hits++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_read_hits);
+#endif
return True;
}
@@ -125,20 +126,8 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
return(ret);
}
-/* Write cache static counters. */
-
-static unsigned int abutted_writes;
-static unsigned int total_writes;
-static unsigned int non_oplock_writes;
-static unsigned int direct_writes;
-static unsigned int init_writes;
-static unsigned int flushed_writes;
-static unsigned int num_perfect_writes;
-static unsigned int flush_reasons[NUM_FLUSH_REASONS];
-
/* how many write cache buffers have been allocated */
static unsigned int allocated_write_caches;
-static unsigned int num_write_caches;
/****************************************************************************
*Really* write to a file.
@@ -193,10 +182,12 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
}
}
- total_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_total_writes);
if (!fsp->oplock_type) {
- non_oplock_writes++;
+ INC_PROFILE_COUNT(writecache_non_oplock_writes);
}
+#endif
/*
* If this file is level II oplocked then we need
@@ -279,25 +270,35 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
abort();
}
- if (total_writes % 500 == 0) {
- DEBUG(3,("WRITECACHE: initwrites=%u abutted=%u flushes=%u total=%u \
+#ifdef WITH_PROFILE
+ if (profile_p && profile_p->writecache_total_writes % 500 == 0) {
+ DEBUG(3,("WRITECACHE: initwrites=%u abutted=%u total=%u \
nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
- init_writes, abutted_writes, flushed_writes, total_writes, non_oplock_writes,
- allocated_write_caches,
- num_write_caches, direct_writes, num_perfect_writes, cache_read_hits ));
-
- DEBUG(3,("WRITECACHE: SEEK=%d, READ=%d, WRITE=%d, READRAW=%d, OPLOCK=%d, CLOSE=%d, SYNC=%d\n",
- flush_reasons[SEEK_FLUSH],
- flush_reasons[READ_FLUSH],
- flush_reasons[WRITE_FLUSH],
- flush_reasons[READRAW_FLUSH],
- flush_reasons[OPLOCK_RELEASE_FLUSH],
- flush_reasons[CLOSE_FLUSH],
- flush_reasons[SYNC_FLUSH] ));
+ profile_p->writecache_init_writes,
+ profile_p->writecache_abutted_writes,
+ profile_p->writecache_total_writes,
+ profile_p->writecache_non_oplock_writes,
+ profile_p->writecache_allocated_write_caches,
+ profile_p->writecache_num_write_caches,
+ profile_p->writecache_direct_writes,
+ profile_p->writecache_num_perfect_writes,
+ profile_p->writecache_read_hits ));
+
+ DEBUG(3,("WRITECACHE: Flushes SEEK=%d, READ=%d, WRITE=%d, READRAW=%d, OPLOCK=%d, CLOSE=%d, SYNC=%d\n",
+ profile_p->writecache_flushed_writes[SEEK_FLUSH],
+ profile_p->writecache_flushed_writes[READ_FLUSH],
+ profile_p->writecache_flushed_writes[WRITE_FLUSH],
+ profile_p->writecache_flushed_writes[READRAW_FLUSH],
+ profile_p->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH],
+ profile_p->writecache_flushed_writes[CLOSE_FLUSH],
+ profile_p->writecache_flushed_writes[SYNC_FLUSH] ));
}
+#endif
if(!wcp) {
- direct_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_direct_writes);
+#endif
return real_write_file(fsp, data, pos, n);
}
@@ -349,7 +350,9 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
pos += data_used;
n -= data_used;
- abutted_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_abutted_writes);
+#endif
total_written = data_used;
write_path = 1;
@@ -385,7 +388,9 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
cache_flush_needed = True;
- abutted_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_abutted_writes);
+#endif
total_written = data_used;
write_path = 2;
@@ -455,7 +460,9 @@ nonop=%u allocated=%u active=%u direct=%u perfect=%u readhits=%u\n",
pos += data_used;
n -= data_used;
- abutted_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_abutted_writes);
+#endif
total_written = data_used;
write_path = 3;
@@ -487,7 +494,9 @@ len = %u\n",fsp->fd, (double)pos, (unsigned int)n, (double)wcp->offset, (unsigne
if ( n <= wcp->alloc_size && n > wcp->data_size) {
cache_flush_needed = True;
} else {
- direct_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_direct_writes);
+#endif
return real_write_file(fsp, data, pos, n);
}
@@ -499,8 +508,6 @@ len = %u\n",fsp->fd, (double)pos, (unsigned int)n, (double)wcp->offset, (unsigne
wcp->file_size = wcp->data_size;
if (cache_flush_needed) {
- flushed_writes++;
-
DEBUG(3,("WRITE_FLUSH:%d: due to noncontinuous write: fd = %d, size = %.0f, pos = %.0f, \
n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
write_path, fsp->fd, (double)wcp->file_size, (double)pos, (unsigned int)n,
@@ -518,7 +525,9 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
if (n > wcp->alloc_size ) {
if(real_write_file(fsp, data, pos, n) == -1)
return -1;
- direct_writes++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_direct_writes);
+#endif
return total_written + n;
}
@@ -527,16 +536,19 @@ n = %u, wcp->offset=%.0f, wcp->data_size=%u\n",
*/
if (n) {
+#ifdef WITH_PROFILE
if (wcp->data_size) {
- abutted_writes++;
- DEBUG(9,("abutted write (%u)\n", abutted_writes));
+ INC_PROFILE_COUNT(writecache_abutted_writes);
} else {
- init_writes++;
+ INC_PROFILE_COUNT(writecache_init_writes);
}
+#endif
memcpy(wcp->data+wcp->data_size, data, n);
if (wcp->data_size == 0) {
wcp->offset = pos;
- num_write_caches++;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_num_write_caches);
+#endif
}
wcp->data_size += n;
DEBUG(9,("cache return %u\n", (unsigned int)n));
@@ -561,6 +573,9 @@ void delete_write_cache(files_struct *fsp)
if(!(wcp = fsp->wcp))
return;
+#ifdef WITH_PROFILE
+ DEC_PROFILE_COUNT(writecache_allocated_write_caches);
+#endif
allocated_write_caches--;
SMB_ASSERT(wcp->data_size == 0);
@@ -583,7 +598,8 @@ static BOOL setup_write_cache(files_struct *fsp, SMB_OFF_T file_size)
ssize_t alloc_size = lp_write_cache_size(SNUM(fsp->conn));
write_cache *wcp;
- if (allocated_write_caches >= MAX_WRITE_CACHES) return False;
+ if (allocated_write_caches >= MAX_WRITE_CACHES)
+ return False;
if(alloc_size == 0 || fsp->wcp)
return False;
@@ -605,6 +621,9 @@ static BOOL setup_write_cache(files_struct *fsp, SMB_OFF_T file_size)
}
fsp->wcp = wcp;
+#ifdef WITH_PROFILE
+ INC_PROFILE_COUNT(writecache_allocated_write_caches);
+#endif
allocated_write_caches++;
DEBUG(10,("setup_write_cache: File %s allocated write cache size %u\n",
@@ -640,15 +659,18 @@ ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason)
data_size = wcp->data_size;
wcp->data_size = 0;
- num_write_caches--;
-
- flush_reasons[(int)reason]++;
+#ifdef WITH_PROFILE
+ DEC_PROFILE_COUNT(writecache_num_write_caches);
+ INC_PROFILE_COUNT(writecache_flushed_writes[reason]);
+#endif
DEBUG(9,("flushing write cache: fd = %d, off=%.0f, size=%u\n",
fsp->fd, (double)wcp->offset, (unsigned int)data_size));
+#ifdef WITH_PROFILE
if(data_size == wcp->alloc_size)
- num_perfect_writes++;
+ INC_PROFILE_COUNT(writecache_num_perfect_writes);
+#endif
return real_write_file(fsp, wcp->data, wcp->offset, data_size);
}
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index d9401d95d4..9c5e99e06b 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -610,7 +610,7 @@ char *tdb_error(TDB_CONTEXT *tdb)
{TDB_ERR_OOM, "Out of memory"},
{TDB_ERR_EXISTS, "Record exists"},
{TDB_ERR_NOEXIST, "Record does not exist"},
- {-1, NULL}};
+ {(enum TDB_ERROR)-1, NULL}};
if (tdb != NULL) {
for (i=0;emap[i].estring;i++) {
if (tdb->ecode == emap[i].ecode) return emap[i].estring;