diff options
author | Jeremy Allison <jra@samba.org> | 2013-05-24 10:33:38 -0700 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-06-10 20:14:12 +0200 |
commit | 2a65e8befef004fd18d17853a1b72155752346c8 (patch) | |
tree | 063e914136feb6214eb4aed09106dd576bb4f95d /source3 | |
parent | da2cf8a947b5beda3e32cb5d9c5b0899a3bf5f61 (diff) | |
download | samba-2a65e8befef004fd18d17853a1b72155752346c8.tar.gz samba-2a65e8befef004fd18d17853a1b72155752346c8.tar.bz2 samba-2a65e8befef004fd18d17853a1b72155752346c8.zip |
Optimization on POSIX platforms that have fstatat.
Tests show significant speedup in directory listings
by using fstatat instead of a full pathname walk.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jun 10 20:14:12 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/modules/vfs_default.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 8804e623ac..82d059c28f 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -376,11 +376,30 @@ static struct dirent *vfswrap_readdir(vfs_handle_struct *handle, START_PROFILE(syscall_readdir); result = readdir(dirp); - /* Default Posix readdir() does not give us stat info. - * Set to invalid to indicate we didn't return this info. */ - if (sbuf) - SET_STAT_INVALID(*sbuf); END_PROFILE(syscall_readdir); + if (sbuf) { + /* Default Posix readdir() does not give us stat info. + * Set to invalid to indicate we didn't return this info. */ + SET_STAT_INVALID(*sbuf); +#if defined(HAVE_DIRFD) && defined(HAVE_FSTATAT) + if (result != NULL) { + /* See if we can efficiently return this. */ + struct stat st; + int flags = (lp_posix_pathnames() ? + AT_SYMLINK_NOFOLLOW : 0); + int ret = fstatat(dirfd(dirp), + result->d_name, + &st, + flags); + if (ret == 0) { + init_stat_ex_from_stat(sbuf, + &st, + lp_fake_dir_create_times( + SNUM(handle->conn))); + } + } +#endif + } return result; } |