[Samba] Need help with file corruption issue

David Coppit david at coppit.org
Thu May 30 09:20:24 MDT 2013

Hi all,

I've run into an issue and am wondering if folks can give some advice
on how to resolve it.

Basically Samba appears to be getting confused, providing some other
file's contents.

Initially I saw this on a Windows host that has mounted a share from
CentOs, but I've been able to repro it on the CentOs host using a

Here's my test script:


use File::Temp qw( tempfile );
use strict;

$| = 1;

my $local_grid_share = '/grid/samba_stress_test';
my $mounted_grid_share = '/root/grid/samba_stress_test';

while (1) {
  my $content1 = rand() x 5 . "\n";

  my ($fh, $filepath) = tempfile( DIR => $local_grid_share );
  print $fh $content1;
  close $fh;

  system("chown xen $filepath");

  my ($filename) = $filepath =~ /.*\/(.*)/;

  print "----\n$filename... ";

  if (-f "$mounted_grid_share/$filename") {
    open IN, "$mounted_grid_share/$filename";
    local $/ = undef;
    my $content2 = <IN>;
    close IN;

    if ($content1 eq $content2) {
      print "Same!\n$filepath     :
$content1$mounted_grid_share/$filename: $content2";
    } else {
      print "Different!\n$filepath     :
$content1$mounted_grid_share/$filename: $content2";
  } else {
    print "File is missing!\n";

  unlink $filepath;

Here's the mount command and an illustration of the problem:

# ifconfig | grep inet.addr | grep -v
          inet addr:  Bcast:  Mask:

# mount -t cifs -ousername=the_user,password=the_password
// /root/grid

# mkdir /grid/samba_stress_test; chown xen /grid/samba_stress_test

# perl samba_stress_test.pl
<snip a lot of successful comparisons>
udCVYFNkc5... Same!
/grid/samba_stress_test/udCVYFNkc5     :
uETPmRzm99... Different!
/grid/samba_stress_test/uETPmRzm99     :

So the new file supposedly has the content of the previous *deleted*
file. Note that sometimes the content is truncated. (See above -- the
"#" for the next prompt is at the end of the previous line because
there's no newline).

If I re-share the mount that's on the Windows machine, and mount it in
this Linux machine, then it consistently repros on the second
iteration. With a little effort I can get the file from the Windows
machine and compare it, if that's helpful.

Here is some information about my setup:

# cat /etc/centos-release
CentOS release 6.3 (Final)

# yum list | grep '^samba'
samba.x86_64                          3.5.10-125.el6           @base
samba-client.x86_64                   3.5.10-125.el6           @base
samba-common.x86_64                   3.5.10-125.el6           @base
samba-winbind-clients.x86_64          3.5.10-125.el6           @base
samba4-libs.x86_64                    4.0.0-23.alpha11.el6     @base/$releasever
samba.x86_64                          3.6.9-151.el6            base
samba-client.x86_64                   3.6.9-151.el6            base
samba-common.i686                     3.6.9-151.el6            base
samba-common.x86_64                   3.6.9-151.el6            base
samba-doc.x86_64                      3.6.9-151.el6            base
samba-domainjoin-gui.x86_64           3.6.9-151.el6            base
samba-swat.x86_64                     3.6.9-151.el6            base
samba-winbind.x86_64                  3.6.9-151.el6            base
samba-winbind-clients.i686            3.6.9-151.el6            base
samba-winbind-clients.x86_64          3.6.9-151.el6            base
samba-winbind-devel.i686              3.6.9-151.el6            base
samba-winbind-devel.x86_64            3.6.9-151.el6            base
samba-winbind-krb5-locator.x86_64     3.6.9-151.el6            base
samba4.x86_64                         4.0.0-55.el6.rc4         base
samba4-client.x86_64                  4.0.0-55.el6.rc4         base
samba4-common.x86_64                  4.0.0-55.el6.rc4         base
samba4-dc.x86_64                      4.0.0-55.el6.rc4         base
samba4-dc-libs.x86_64                 4.0.0-55.el6.rc4         base
samba4-devel.i686                     4.0.0-23.alpha11.el6     base
samba4-devel.x86_64                   4.0.0-55.el6.rc4         base
samba4-libs.i686                      4.0.0-23.alpha11.el6     base
samba4-libs.x86_64                    4.0.0-55.el6.rc4         base
samba4-pidl.x86_64                    4.0.0-55.el6.rc4         base
samba4-python.x86_64                  4.0.0-55.el6.rc4         base
samba4-swat.x86_64                    4.0.0-55.el6.rc4         base
samba4-test.x86_64                    4.0.0-55.el6.rc4         base
samba4-winbind.x86_64                 4.0.0-55.el6.rc4         base
samba4-winbind-clients.x86_64         4.0.0-55.el6.rc4         base
samba4-winbind-krb5-locator.x86_64    4.0.0-55.el6.rc4         base

Share settings from /etc/samba/smb.conf:

        comment = Grid Share
        browseable = yes
        writeable = yes
        level2 oplocks = no
        oplocks = no
        path = /grid
        value user = the_user

More information about the samba mailing list