# Multi-second write latency with btrfs on SSD

## Abraxa

Hello all,

In January 2011 I got myself an SSD (Crucial RealSSD C300) which had superb read and write rates in the beginning. The FS of choice was btrfs as it's new and claims to have good SSD support. About a month later I had filled the SSD up to the point where btrfs would complain about the lack of space. I made some space again and keep about 17G (~7%) available at all times now. Despite that I now face multi-second latencies whenever *any* process is writing to the SSD, during which one CPU core stays at 100% load with the btrfs-endio-write process consuming all of that. This is extremely annoying and so I'm wondering what I can do. I tried searching for other cases of this problem but so far didn't find any as extreme as mine. With that I'm looking at several possibilities:

1) The SSD is to blame because of bad garbage collection (ie. it might not wipe cells when idle but only when a write is requested)

2) btrfs is to blame because of bugs (couldn't find similar reports, though)

3) The scheduler is to blame (though others suggest that the scheduler makes little difference)

I don't really think the kernel is the problem as I'm running a stock 2.6.36-gentoo-r8. I also have the "ssd" flag in the fstab for the root partition, so the TRIM command should be used already. I also use the most recent firmware for the C300.

Does anyone have an idea what I can do? I'm tempted to just wipe the drive and switch to ext4, however if it's the C300 itself that's causing this I'd have to repeat this process every 6 months or so, it seems. I'd like to avoid that, if possible.

Thanks in advance!

----------

## whig

Does dmesg show anything related to this?

I use a ssd w/ btrfs in a fake raid 0 setup for the root fs. Initramfs needed. My mount line is

```
/dev/sdc4       /       btrfs   ssd,max_inline=0,noatime,device=/dev/sdc4,device=/dev/sdb2      0 1
```

I'm not sure how many of those options are needed these days. Working well here at any rate. The max_inline was about reducing the amount of extra (meta?) data on the filesystem. btrfs needs _lots_ of free space. 7% too tight. I would aim for 30% free, but I'm not an expert.

----------

## lkraav

aha so this is you on crucial forums. i just replied about experiencing the same latency thing:

http://forum.crucial.com/t5/Solid-State-Drives-SSD/Multi-second-write-latency-with-C300/m-p/82604#M25063

its a longer thread over there, so i guess it makes sense to discuss on crucial forums.

----------

