[Pkg-samba-maint] Bug#798532: samba: wrong file block size if 'strict allocate' is enabled for samba

nelson dozenbox at yahoo.com
Thu Sep 10 10:52:30 UTC 2015


Package: samba
Version: 2:4.1.17+dfsg-2
Severity: normal
Tags: patch

Dear Maintainer,


   When I add 'strict  allocate = yes' to /etc/samba/smb.conf, then copy file via samba, the block usage of the file will be greater than its real size. For example, copy a 8KB file via samba, you will find the block usage is 1MB. But if remove 'strict allocate = yes' from /etc/samba/smb.conf and do the same test, file size is correct(of cause, 4KB roundup for EXT4).

  # hdparm --fibmap 8k.bin 

  8k.bin:
   filesystem blocksize 4096, begins at LBA 195311616; assuming 512 byte sectors.
   byte_offset  begin_LBA    end_LBA    sectors
             0  202758144  202758159         16
          8192  202758160  202760191       2032

  # du -sh 8k.bin 
  1.0M    8k.bin

  # ls -l 8k.bin 
  -rwx------ 1 nelson nelson 8192 Aug 21 10:58 8k.bin

  By tracing samba daemon, it shows that these functions be called (pseudo-code) : 

  open(8k.bin) 
  ...
  fallocate(8k.bin, 1, 0, 1048576)
  ...
  fallocate(8k.bin, 0, 0, 8192)  // -> here should be truncate(8k.bin, 8192)
  ...
  write()
  ...
  close(8k.bin).

  Here is my patch for this bug. Please check, thanks.

*** vfs_default.c.ori   2015-09-10 17:55:09.172488319 +0800
--- vfs_default.c       2015-09-10 17:57:08.104484805 +0800
***************
*** 1807,1813 ****
                return 0;
  
        /* Shrink - just ftruncate. */
!       if (pst->st_ex_size > len)
                return ftruncate(fsp->fh->fd, len);
  
        space_to_write = len - pst->st_ex_size;
--- 1807,1813 ----
                return 0;
  
        /* Shrink - just ftruncate. */
!       if (pst->st_ex_blocks * 512 > len)
                return ftruncate(fsp->fh->fd, len);
  
        space_to_write = len - pst->st_ex_size;




-- System Information:
Debian Release: 8.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages samba depends on:
ii  adduser                              3.113+nmu3
ii  dpkg                                 1.17.25
ii  libasn1-8-heimdal                    1.6~rc2+dfsg-9
ii  libbsd0                              0.7.0-2
ii  libc6                                2.19-18+deb8u1
ii  libcomerr2                           1.42.12-1.1
ii  libhdb9-heimdal [heimdal-hdb-api-8]  1.6~rc2+dfsg-9
ii  libkdc2-heimdal                      1.6~rc2+dfsg-9
ii  libkrb5-26-heimdal                   1.6~rc2+dfsg-9
ii  libldb1                              2:1.1.17-2
ii  libpam-modules                       1.1.8-3.1
ii  libpam-runtime                       1.1.8-3.1
ii  libpopt0                             1.16-10
ii  libpython2.7                         2.7.9-2
ii  libroken18-heimdal                   1.6~rc2+dfsg-9
ii  libtalloc2                           2.1.1-2
ii  libtdb1                              1.3.1-1
ii  libtevent0                           0.9.21-1
ii  lsb-base                             4.1+Debian13+nmu1
ii  multiarch-support                    2.19-18+deb8u1
ii  procps                               2:3.3.9-9
ii  python                               2.7.9-1
ii  python-dnspython                     1.12.0-1
ii  python-ntdb                          1.0-5
ii  python-samba                         2:4.1.17+dfsg-2
pn  python2.7:any                        <none>
ii  samba-common                         2:4.1.17+dfsg-2
ii  samba-common-bin                     2:4.1.17+dfsg-2
ii  samba-dsdb-modules                   2:4.1.17+dfsg-2
ii  samba-libs                           2:4.1.17+dfsg-2
ii  tdb-tools                            1.3.1-1
ii  update-inetd                         4.43

Versions of packages samba recommends:
ii  attr               1:2.4.47-2
ii  logrotate          3.8.7-1+b1
ii  samba-vfs-modules  2:4.1.17+dfsg-2

Versions of packages samba suggests:
pn  bind9          <none>
pn  bind9utils     <none>
pn  ctdb           <none>
pn  ldb-tools      <none>
pn  ntp            <none>
pn  smbldap-tools  <none>
ii  winbind        2:4.1.17+dfsg-2

-- no debconf information



More information about the Pkg-samba-maint mailing list