[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
self-mount.

Here's my test script:

#!/usr/bin/perl

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";
      exit;
    }
  } else {
    print "File is missing!\n";
    exit;
  }

  unlink $filepath;
}

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

# ifconfig | grep inet.addr | grep -v 127.0.0.1
          inet addr:10.0.0.11  Bcast:10.0.0.255  Mask:255.255.255.0

# mount -t cifs -ousername=the_user,password=the_password
//10.0.0.11/grid /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     :
0.07392498237819470.07392498237819470.07392498237819470.07392498237819470.0739249823781947
/root/grid/samba_stress_test/udCVYFNkc5:
0.07392498237819470.07392498237819470.07392498237819470.07392498237819470.0739249823781947
----
uETPmRzm99... Different!
/grid/samba_stress_test/uETPmRzm99     :
0.9774832438332160.9774832438332160.9774832438332160.9774832438332160.977483243833216
/root/grid/samba_stress_test/uETPmRzm99:
0.07392498237819470.07392498237819470.07392498237819470.07392498237819470.073924982378#

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:

[grid]
        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