# ext3 slow when the partition is full?

## nitm

Hello,

I have two disks, which are relatively fast (the one is faster than the other)

```

/dev/sda: WDC WD6400AAKS-65A7B0

/dev/sdb: Hitachi HDT725032VLA360

# hdparm -tT /dev/sd?

/dev/sda:

 Timing cached reads:   10428 MB in  2.00 seconds = 5217.77 MB/sec

 Timing buffered disk reads:  332 MB in  3.01 seconds = 110.25 MB/sec

/dev/sdb:

 Timing cached reads:   10106 MB in  2.00 seconds = 5056.54 MB/sec

 Timing buffered disk reads:  214 MB in  3.01 seconds =  71.16 MB/sec

```

On them I have two big partitions, which are quite full.

```

# mount

/dev/sdb8 on /home type ext3 (rw,noatime)

/dev/sda6 on /mnt/data type ext3 (rw,noatime)

# df -h

/dev/sdb8             265G  259G  6.4G  98% /home

/dev/sda6             565G  499G   66G  89% /mnt/data

```

On both this partitions I have low read speed (around 5 MB/s). 

Here is the load measured with iostats 1 1000 -dxm while doing cp /home/data/bigfile /dev/null

```

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util

sda               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

sdb              13.00     0.00  296.00    1.00     9.64     0.00    66.51     5.26   18.30   3.38 100.40

```

And the load while cp /mnt/data/bigfile /dev/null

```

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util

sda               0.99     0.00  344.55    0.00     7.09     0.00    42.11     6.29   18.30   2.89  99.41

sdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

```

The strange thing is that doing cp /mnt/data/oldbigfile /dev/null results in:

```

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util

sda               0.00     0.00  888.00    0.00   107.62     0.00   248.22     2.00    2.25   1.12  99.60

sdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00

```

Does someone know an explanations why's that happening?

Is ext3 flawed? Does xfs work better?

My /home partition have various kinds of files: small, big, and files are deleted often (I compile things very often).

My /mnt/data partition on the other hand has only big files (music, video and some photos) and there are rare deletions, so there should not be any fragmentation (or I'm wrong? ), but the partition behaves the same as the /home one?

Please help, because I could not find any info on the internet and the forum, but I've tried and that is not the first time I do so.

Best regards

----------

## VinzC

You're just experiencing fragmentation. Fragmentation kills disks performance in general, regardless of the file systems. Maybe the impact is more important on ext3, I don't know. It's quite possible that some disk brands are more impacted than others OTOH.

[EDIT: Fragmentation always occurs at some time. Defrag is simply easier with Linux filesystems as they all try to find the best place that fits first.]

There is a limit beyond which a file system will spend more time trying to figure out what is the best place for a file or splitting the file in chunks to fill the "holes". Make room on your disk or use a larger disk and you'll see...

----------

## Akkara

 *nitm wrote:*   

> Does xfs work better?

 

Xfs has a utility to defragment the filesystem.  (See xfs_fsr in sys-fs/xfsprogs).  Ext3 can't (that I know of).

But when a disk gets too full (usually this means more than 95%), even xfs's defragmenter doesn't do much because there simply isn't a good selection of contiguous blocks left to put things in.

----------

## VinzC

 *Akkara wrote:*   

> Xfs has a utility to defragment the filesystem.  (See xfs_fsr in sys-fs/xfsprogs).  Ext3 can't (that I know of).

 

FYI it can: move the file to another file system and put it back to its original location. Doesn't work if the disk is almost full however.

I've been told a long time ago that free space should always be greater than 25% otherwise filsystem drivers spend much more time trying to find appropriate places. Even if it's purely arbitrary, I always tend to have more than 25% free space.

----------

## nitm

Thanks to all for the answer.

I've found the cause of the problem: Transmission  :Sad: 

It creates the files very fragmented. 

I've changed the preallocation option in it and now the situation is normal.

On another machine I'm using ext4 and there the fragmentation is less because of the design of the ext4 (using extents).

So this will be my fs of choice for the future.

----------

