# [CIFS] Very slow file transfer

## polu

I have a fileserver running Gentoo Linux to share some files using Samba:

```

[global]

   netbios name = tuxxie

   workgroup = tux-inside

   server string = tuxxie

   security = user

   encrypt passwords = yes

   password level = 20

   hosts allow = 192.168.1. 127.0.0.

   load printers = no

   printing = cups

   log file = /var/log/samba.%m

   max log size = 50

   socket options = TCP_NODELAY IPTOS_LOWDELAY

   invalid users = root

   domain master = no

[Films]

path = /mnt/films

browsable = yes

writable = yes

valid users = jboelen

...

```

My cliënt computer is connected using a gigabit ethernet connection and has a Windows 7 / Gentoo Linux dual boot. When I copy a large file using Windows a get around 52MB/sec, which is not bad. However, when I copy the exact same file in Linux using Cifs I only get 8.9MB/sec. My /etc/fstab entry is looks like this:

```

//192.168.1.11/Films /mnt/tuxxie/Films cifs auto,credentials=/root/.credentials,uid=jboelen 0 0

```

When I browse the share in Nautilus using smb://192.168.1.11/Films I get around 38MB/sec. I also copied the same file using FTP, in Windows I have a transfer rate of 83MB/sec, and using the Linux cliënt 58MB/sec. 

To summarize the transfer rates:

```

Windows CIFS: 52MB/sec

Windows FTP: 83MB/sec

Linux CIFS: 8,9MB/sec

Gnome SMB: 38MB/sec

Linux FTP: 58MB/sec

```

I don't care if the transfer rate in Windows is higher, but I can't live with 8,9MB/sec. Is there any way to improve the speed of mount.cifs? I tried some values with the rsize and wsize parameter, but that doesn't seem to make any difference.

----------

## gerdesj

mount.cifs is using part of the kernel.  smb.conf is part of Samba.  I think nautilus etc use Samba.

They are not the same.  

So, you have a speed drop using the kernel implementation of CIFS.

What kernel version are you using?  For that matter what sort of NIC do you have and what driver are you using (lspci -k   might help here)

Cheers

Jon

----------

## polu

On my desktop pc I'm using:

Kernel: gentoo-sources-2.6.37 (amd64)

NIC: Realtek 8169

On my laptop I have the same problem (well, it's a little bit faster: 15 MB/sec):

Kernel: gentoo-sources-2.6.36-r5 (x86)

NIC: Intel e1000

Some things I've tried:

```

rmmod cifs

modprobe cifs CIFSMaxBufSize=130048

mount //server/share /mountpoint -o rsize=130048,wsize=130048

or

mount //server/share /mountpoint -o rsize=130048,wsize=130048,directio

```

And some other values, but doesn't seem to work

```

/etc/samba/smb.conf

  read raw = yes

  write raw = yes

```

Doesn't work, and seems to slow down my Windows client

----------

## dsamersoff

Run into the same problem.  60mb/s by smbclient/get but 8mb/s using mount.cifs

Any ideas ?

----------

## baaann

This blog entry may be worth exploring?

----------

## dsamersoff

Tried it - nothing changed drastically  15mb READ (vs 10mb) and 2.5 mb WRITE (not changed). 

I'm not surprised because it's just another "shell" for the same kernel CIFS fs driver.

----------

## till

I have noticed the same performance regression in gentoo-sources-2.6.37-r1 and gentoo-sources-2.6.36-r5 (about 4-12 MiB/s).

gentoo-sources-2-6-34-r12 do work well with 30-50 MiB/s.

Can someone confirm this for the vanilla sources too? if not we should fill a bug about this in gentoo (i didnt find any). 

anybody solved this problem?

----------

## ICETEA

I have exactly the same problem(~12MBit/s) with vanilla kernel 2.6.37. I think it started with this version, maybe 2.6.36.

----------

## till

I opened a bug https://bugs.gentoo.org/show_bug.cgi?id=357463

----------

## dE_logics

Why not just use NFS?

----------

## dsamersoff

Do you know good NFS client for MS Windows? 

Personally, I have a mixed network and don't want to deal with bunch of independent access methods.

----------

## polu

I was on vacation for a few days, so I kind of abandoned this thread. 

Anyway, I'm also using a mixed network with both Linux and Windows clients and servers, so using NFS isn't really a solution. I'll try to run some test with different kernels and settings...   :Confused: 

----------

## avx

G-sources 2.6.38, same problem here. ~16MB write per CIFS, my Macbook writes ~65MB via AFP.

----------

## polu

I tried multiple kernel versions (older and newer ones) but it doesn't make any difference.   :Sad: 

I also shared the same data using NFS, and that does give me reasonable transfer rates. But I don't see how you can secure NFS in a good way.   :Rolling Eyes: 

----------

## iandoug

Mmm I found this post looking for a solution to a slightly different problem, but they may be connected.

I've got an Apacer AL670 media player with a 1 GB Western Digital USB drive connected to it. I managed to connect to the Apacer via the LAN in the last few days. The Apacer box is running linux (apparently Venus).

I also noticed the slow transfer speeds... downloading from the box is much faster than uploading to it.

However I also noticed that the lights on the LAN switch are going bezerk now, even though I have closed the Konqueror window that I used to connect to the Apacer (so as far as I am concerned, there should not be any traffic in or out).

Fired up EtherApe to have a look, and I see an EXTREMELY busy CIFS connection running at around 1.3 to 1.5 Mbps but have no idea what it is doing. Presumably some network overhead or something.

But if there is that much 'useless' traffic on the link, perhaps that is why the data speeds are so slow?

Now, how do I get the traffic to stop, short of shutting down Samba?

{edit: I shut Samba down, did not help. Exited KDE, that DID help... is this perhaps a KDE problem? Am at 4.4.5 stable).}

Why *is* there continuous high-speed traffic? (88 MB since I started typing).

thanks, Ian

----------

## jfgi

I'm also getting horrible speeds using CIFS. rsize and directio make no difference. It's the same in kernel 3.0.3 and 2.6.39

CIFS read: ~4MB/s

smbclient read: ~95MB/s

CIFS write: ~40MB/s

smbclient write: ~40 MB/s

----------

## solamour

I always thought CIFS was somewhat slower, but I just chalked it off as CIFS's overhead. I'd be interested in a real solution.

__

sol

----------

## pa1983

I know the thread is old but I had the same problem for a long time. I solved it a while ago, or well I found the solution at least for me in some blog som where.

I to had like 8-9Mb/sec over 1Gbit network just like the author of the tread is reporting. I didn't think about it much sens I ran two bonded nics for 2Gbit speeds from both server and workstation and used FTP an NFS for big transfers but samba is still very important in my network and when you some times move big files its a bit to slow with 16-18mb/sec. But I never seemed to find a smb.conf option that solved the problem. I had this problem long before I ran bonded nics to so it didn't have anything to do with it. It just made the problem less inconvenient.

I talked with gentoo devs in the IRC channel but no one seemes to have an answer or could find something wrong with my setup. And I could also get much better speeds with say nautilus. I also know I did not have this problem many years ago. Just the last few years.

I added this to my /etc/samba/smb.conf as suggested bu som blog I read like 6 months ago or so.

write cache size = 262144

large readwrite = yes

Now I believe the first option is what makes the difference but both where suggested as increasing performance. I haven't tested using just one of the options at a time but adding a 256Kb buffer I believe solves the main problem. Sens i run bonded nics I can now hit 104Mb/sec+ average from a 3Tb Seagate barracuda compared to the 16-18Mb/sec i had before over 2Gbit lan. Thats pretty good. Still slower then FTP that could hit 154Mb/sec but good enough.

I have had this problem on more then on system (have had two filservers at home with the same problem) so ether somethings fubar or I have done something wrong the last few years but I doubt it.

But I do know other people are having the same problem and usually there seems to be no solution.

Any way if some on is still having this problem try adding those two lines to smb.conf and restart samba server and see if that helps the transfer rates.

----------

## solamour

Interesting. Does increasing the cache size even bigger would make a difference as well?

__

sol

----------

## pa1983

I dont know I haven't tried. It seems fast enough for my 2Tb WD greens but I got two 3Tb Seagate Barracudas recently and they are a lot faster so I could give it a try. I got 8Gb o ram so should not be problem.

I would also be interested to know if this solves the problem for other people stuck at 8-9Mb/sec over Gbit lan. I had two filservers before with the same problem. After an upgrade I made one server with all the space I needed so I cant test on another machine my self atm.

EDIT:

I did som testing now and the strange thing is that I still get good speeds with both options disabled. Bigger buffers docent improve speeds either. But I did a complete system upgrade ( I actually recompiled everything both system and world after upgrading gcc) of gentoo when I added the 3Tb drives a few weeks ago including kernel and samba.

I dont know where the problem originates from, samba or the kernel but I have had it for a few years and no upgrade of either kernel samba or anything else have ever worked including world updates and the options I mentioned worked for me and have worked flawlessly sens. I basically ran the same setup for 6+ months just with those options and it worked perfect. So it did something to make it work properly. But who knows now that I upgraded the system if the problem is gone by default now sens I cant get the problem back even if I try my old smb.conf and yes I restarted the samba server before testing.

The strange thing now is that with the options off its actually even faster. Managed to hit 138Mb/sec average. Very strange. Basically back to my original smb.conf file.

I realy dont know whats going on. Im no dev so I can only guess but something must have changed for the better in samba or the kernel or both after the upgrade I did.

I primarily had the problem when I ran the later 2.6 kernels like 2.6.23-2.6.34 but if the kernel was to blame I dont know.

I use samba-3.5.15 and gentoo-sources-3.3.8 right now after the resent upgrade. The problem never went away with system wide upgrades before.

So if some on still has the problem it would be nice to see if those options still solves the problem and what version of samba and the linux kernel they use.

----------

