summaryrefslogtreecommitdiff
path: root/source3/smbd/dir.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-15 10:46:23 +0100
committerVolker Lendecke <vl@samba.org>2009-11-18 23:16:13 +0100
commitd1c34d405421e2969d6cf4fc7438f783e7d6b0a5 (patch)
tree031d6a32c255db2a6a13d3a04bc4ea881129585d /source3/smbd/dir.c
parentf6650f5d19ad90b8e1f392efbe211c4ffa0e70c0 (diff)
downloadsamba-d1c34d405421e2969d6cf4fc7438f783e7d6b0a5.tar.gz
samba-d1c34d405421e2969d6cf4fc7438f783e7d6b0a5.tar.bz2
samba-d1c34d405421e2969d6cf4fc7438f783e7d6b0a5.zip
s3: Replace some create_synthetic_smb_fname() calls
In very hot codepaths like the statcache copy_smb_filename and the subsequent recursive talloc_free is noticable in the CPU load.
Diffstat (limited to 'source3/smbd/dir.c')
-rw-r--r--source3/smbd/dir.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 5d18d452f8..5ce4a7b099 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -613,14 +613,13 @@ char *dptr_ReadDirName(TALLOC_CTX *ctx,
long *poffset,
SMB_STRUCT_STAT *pst)
{
- struct smb_filename *smb_fname_base = NULL;
+ struct smb_filename smb_fname_base;
char *name = NULL;
const char *name_temp = NULL;
char *talloced = NULL;
char *pathreal = NULL;
char *found_name = NULL;
int ret;
- NTSTATUS status;
SET_STAT_INVALID(*pst);
@@ -673,19 +672,14 @@ char *dptr_ReadDirName(TALLOC_CTX *ctx,
return NULL;
/* Create an smb_filename with stream_name == NULL. */
- status = create_synthetic_smb_fname(ctx, pathreal, NULL, NULL,
- &smb_fname_base);
- if (!NT_STATUS_IS_OK(status)) {
- return NULL;
- }
+ ZERO_STRUCT(smb_fname_base);
+ smb_fname_base.base_name = pathreal;
- if (SMB_VFS_STAT(dptr->conn, smb_fname_base) == 0) {
- *pst = smb_fname_base->st;
- TALLOC_FREE(smb_fname_base);
+ if (SMB_VFS_STAT(dptr->conn, &smb_fname_base) == 0) {
+ *pst = smb_fname_base.st;
name = talloc_strdup(ctx, dptr->wcard);
goto clean;
} else {
- TALLOC_FREE(smb_fname_base);
/* If we get any other error than ENOENT or ENOTDIR
then the file exists we just can't stat it. */
if (errno != ENOENT && errno != ENOTDIR) {
@@ -916,7 +910,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
bool isdots;
char *fname = NULL;
char *pathreal = NULL;
- struct smb_filename *smb_fname = NULL;
+ struct smb_filename smb_fname;
uint32_t mode = 0;
bool ok;
NTSTATUS status;
@@ -961,21 +955,15 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
}
/* Create smb_fname with NULL stream_name. */
- status = create_synthetic_smb_fname(ctx, pathreal,
- NULL, &sbuf,
- &smb_fname);
- TALLOC_FREE(pathreal);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(dname);
- TALLOC_FREE(fname);
- return false;
- }
+ ZERO_STRUCT(smb_fname);
+ smb_fname.base_name = pathreal;
+ smb_fname.st = sbuf;
- ok = mode_fn(ctx, private_data, smb_fname, &mode);
+ ok = mode_fn(ctx, private_data, &smb_fname, &mode);
if (!ok) {
TALLOC_FREE(dname);
TALLOC_FREE(fname);
- TALLOC_FREE(smb_fname);
+ TALLOC_FREE(pathreal);
continue;
}
@@ -984,7 +972,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
fname, (unsigned int)mode, (unsigned int)dirtype));
TALLOC_FREE(dname);
TALLOC_FREE(fname);
- TALLOC_FREE(smb_fname);
+ TALLOC_FREE(pathreal);
continue;
}
@@ -993,25 +981,29 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
struct file_id fileid;
fileid = vfs_file_id_from_sbuf(conn,
- &smb_fname->st);
+ &smb_fname.st);
get_file_infos(fileid, NULL, &write_time_ts);
if (!null_timespec(write_time_ts)) {
- update_stat_ex_mtime(&smb_fname->st,
+ update_stat_ex_mtime(&smb_fname.st,
write_time_ts);
}
}
DEBUG(3,("smbd_dirptr_get_entry mask=[%s] found %s "
"fname=%s (%s)\n",
- mask, smb_fname_str_dbg(smb_fname),
+ mask, smb_fname_str_dbg(&smb_fname),
dname, fname));
DirCacheAdd(dirptr->dir_hnd, dname, cur_offset);
TALLOC_FREE(dname);
+ status = copy_smb_filename(ctx, &smb_fname, _smb_fname);
+ TALLOC_FREE(pathreal);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
*_fname = fname;
- *_smb_fname = smb_fname;
*_mode = mode;
*_prev_offset = prev_offset;