Dear all: I used samba version 4.8.6 .I want to creat and write file in a dir,but the dir have a lots file ,may be 200000+.The creat or write will be slowly more than 1s. I watched the code ,the operation will be running the unix_convert .the function is time-consuming . if I modify the code get_real_filename_full_scan in the filename.c .the client will be failed to find some file .but the write speed will be improved . static int get_real_filename_full_scan(connection_struct *conn, const char *path, const char *name, bool mangled, TALLOC_CTX *mem_ctx, char **found_name) { struct smb_Dir *cur_dir; const char *dname = NULL; char *talloced = NULL; char *unmangled_name = NULL; long curpos; struct smb_filename *smb_fname = NULL; /* handle null paths */ if ((path == NULL) || (*path == 0)) { path = "."; } /* If we have a case-sensitive filesystem, it doesn't do us any * good to search for a name. If a case variation of the name was * there, then the original stat(2) would have found it. */ errno = ENOENT; return -1; if (!mangled && !(conn->fs_capabilities & FILE_CASE_SENSITIVE_SEARCH)) { errno = ENOENT; return -1; } the smb.conf has some parm like this: case sensitive = Yes default case = upper preserve case = No short preserve case = No can I help me ? -- Email:lqb_hebust at 163.com 2019年5月29日
Jeremy Allison
2019-May-29 16:04 UTC
[Samba] How to improve the performance with unix_convert ?
On Wed, May 29, 2019 at 09:39:10PM +0800, 李庆波 via samba wrote:> Dear all: > I used samba version 4.8.6 .I want to creat and write file in a dir,but the dir have a lots file ,may be 200000+.The creat or write will be slowly more than 1s. > I watched the code ,the operation will be running the unix_convert .the function is time-consuming . > if I modify the code get_real_filename_full_scan in the filename.c .the client will be failed to find some file .but the write speed will be improved .Yes, scanning the directory for cache misses can be expensive. If you can make a separate share for this, and can canonicalize the name to a single case (or use a case insensitive filesystem underneath) you can remove these scans. See here: https://wiki.samba.org/index.php/Performance_Tuning "Directories with a Large Number of Files" for details.