The performance of a large number of files

xue jiaolong jiaolongxue at outlook.com
Fri Nov 4 01:12:35 UTC 2016


test environment

  *   client: windows8
  *   server: centos7.1
  *   smbd version:

[root at localhost samba]# ps aux | grep smbd
root      3378  0.0  0.3 386040  5800 ?        Ss   20:43   0:00 /usr/sbin/smbd
root      3380  0.0  0.1 386040  3108 ?        S    20:43   0:00 /usr/sbin/smbd
root      3385  0.0  0.3 390600  7004 ?        S    20:44   0:00 /usr/sbin/smbd
root      3504  0.0  0.0 112648   976 pts/0    R+   21:09   0:00 grep --color=auto smbd
[root at localhost samba]# /usr/sbin/smbd --version
Version 4.2.10

test procedure

  *   modify smb.conf

[root at localhost samba]# testparm -s -c
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[1111]"
Loaded services file OK.
Server role: ROLE_STANDALONE

# Global parameters
[global]
    workgroup = MYGROUP
    server string = Samba Server Version %v
    security = USER
    log file = /var/log/samba/log.%m
    max log size = 900000000
    server max protocol = SMB2
    idmap config * : backend = tdb


[1111]
    comment = share
    path = /tmp
    read only = No

  *   restart smbd service

[root at localhost samba]# service smb restart
Redirecting to /bin/systemctl restart  smb.service

  *   map a directory to a network disk

[cid:Image366.png at 1582ce51c6e16f]

  *   Write the test program

    var writewg sync.WaitGroup
        var i uint64
        for i = 0; i < files; i++ {
            writewg.Add(1);
            ctx.sem <- true
            go func(index uint64) {
                if isdir {
                    subdir := path + "/dir_" + strconv.FormatUint(index, 10)
                    os.MkdirAll(subdir, 0777)
                } else {
                    file := path + "/file_" + strconv.FormatUint(index, 10)
                    f, err := os.OpenFile(file, os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModePerm|os.ModeTemporary)
                    if err != nil {
                        fmt.Println("OpenFile ", file, " failed ", err );
                    } else {
                        f.Write(ctx.data[0:])
                        f.Close()
                    }
                }
                atomic.AddUint64(&ctx.task.Ops, 1)
                <- ctx.sem
                writewg.Add(-1)
            }(i)
        }
        writewg.Wait()

  *   run my test program
create 500 files

  *   View the log

[root at localhost samba]# grep "smbd_dirptr_get_entry mask=.*file_0" log.xjl | wc -l
500
[root at localhost samba]# grep "SMB2_OP_FIND" log.xjl | wc -l
1020


发件人: Volker Lendecke<mailto:vl at samba.org>
发送时间: ‎2016‎年‎11‎月‎2‎日, ‎星期三 ‎17‎:‎30
收件人: live:jiaolongxue<mailto:jiaolongxue at outlook.com>
抄送: samba-technical at lists.samba.org<mailto:samba-technical at lists.samba.org>

xue jiaolong <jiaolongxue at outlook.com> writes:

> 发自 Windows 邮件
>
> 发件人: live:jiaolongxue<mailto:jiaolongxue at outlook.com>
> 发送时间: ‎2016‎年‎11‎月‎2‎日, ‎星期三 ‎16‎:‎18
> 收件人: live:jiaolongxue<mailto:jiaolongxue at outlook.com>
>
> When I copy the directory with 500 sub-files, it is like this
> [cid:Image881.png at 15824158dfb372]
> ​[cid:Image1001.png at 158241e24f93ea]

Well, log files as images don't really make sense. It might also be an
explorer application that is notified every time a file is dropped.

Try

change notify = no

as a setting in the [global] section of your smb.conf file and see if
the enumerations disappear.

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Image366.png
Type: image/png
Size: 88906 bytes
Desc: Image366.png
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161104/28efa9b8/Image366.png>


More information about the samba-technical mailing list