Skip to contentSkip to conversation

3.18.3 + latest bcache-dev

DISCUSSION Stephen R. van den Berg 3 participants 8 messages Jan 21, 2015 – Jan 22, 2015 bcache (block layer cache)

lore
Share & tools
lore
#0 lore raw

I have:
16GB RAM
16GB SSD swap
5 x 6TB HDD bcache backing storage
2 x 490GB SSD bcache cache (Crucial M550, 4KB block, 2M bucket size) writeback and trim enabled on bcache.
I used the latestbcache tools from git.

On the backing storage, I created a BTRFS using nossd and notrim.

Now, whenever I boot, I end up with exactly 4 bcache_writebac processes pegged at 99 or 100% CPU. This is on an octocore cpu. top shows it as 50% system time. The four processes are marked as R, but I cannot trace them.

Even after waiting for several minutes, the cpu load does not come down. The mounted volume simply seems to work, though.

Any ideas?

Signature · 1 line
Stephen.
#1 lore raw

Try increasing btree_scan_ratelimit?

Quoted 25 lines · Stephen R. van den Berg

I have:
16GB RAM
16GB SSD swap
5 x 6TB HDD bcache backing storage
2 x 490GB SSD bcache cache (Crucial M550, 4KB block, 2M bucket size) writeback and trim enabled on bcache.
I used the latestbcache tools from git.

On the backing storage, I created a BTRFS using nossd and notrim.

Now, whenever I boot, I end up with exactly 4 bcache_writebac processes pegged at 99 or 100% CPU. This is on an octocore cpu. top shows it as 50% system time. The four processes are marked as R, but I cannot trace them.

Even after waiting for several minutes, the cpu load does not come down. The mounted volume simply seems to work, though.

Any ideas?
--
Stephen.
--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 1 line · Kent Overstreet

Try increasing btree_scan_ratelimit?

Well, before I could try this, the 100% CPU usage was gone (after several hours).

However, something else happened:

a. During some heavy traffic mostly writing to the btrfs filesystem
the kernel halted. AFAICS inside some btrfs recovery code.
b. Kernel messages show something like this leading up to the freeze:

Jan 21 11:21:40 ip144 kernel: ata11.00: exception Emask 0x0 SAct 0x7fffffff SErr 0x0 action 0x0
Jan 21 11:21:40 ip144 kernel: ata11.00: irq_stat 0x40000008
Jan 21 11:21:40 ip144 kernel: ata11.00: failed command: READ FPDMA QUEUED
Jan 21 11:21:40 ip144 kernel: ata11.00: cmd 60/00:c0:10:d0:d9/04:00:01:00:00/40 tag 24 ncq 524288 in
Jan 21 11:21:40 ip144 kernel:         res 41/40:00:d0:d1:d9/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Jan 21 11:21:40 ip144 kernel: ata11.00: status: { DRDY ERR }
Jan 21 11:21:40 ip144 kernel: ata11.00: error: { UNC }
Jan 21 11:21:40 ip144 kernel: ata11.00: configured for UDMA/133
Jan 21 11:21:40 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:21:40 ip144 kernel: Result: hostbyte=0x00 driverbyte=0x08
Jan 21 11:21:40 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:21:40 ip144 kernel: Sense Key : 0x3 [current] [descriptor]
Jan 21 11:21:40 ip144 kernel: Descriptor sense data with sense descriptors (in hex):
Jan 21 11:21:40 ip144 kernel:        72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00 
Jan 21 11:21:40 ip144 kernel:        01 d9 d1 d0 
Jan 21 11:21:40 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:21:40 ip144 kernel: ASC=0x11 ASCQ=0x4
Jan 21 11:21:40 ip144 kernel: sd 10:0:0:0: [sdg] CDB: 
Jan 21 11:21:40 ip144 kernel: cdb[0]=0x88: 88 00 00 00 00 00 01 d9 d0 10 00 00 04 00 00 00
Jan 21 11:21:40 ip144 kernel: blk_update_request: I/O error, dev sdg, sector 31052240
Jan 21 11:21:40 ip144 kernel: ata11: EH complete
Jan 21 11:21:40 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 1, flush 0, corrupt 0, gen 0
Jan 21 11:21:40 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 2, flush 0, corrupt 0, gen 0
Jan 21 11:21:40 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 3, flush 0, corrupt 0, gen 0
Jan 21 11:21:40 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 4, flush 0, corrupt 0, gen 0
Jan 21 11:21:40 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 5, flush 0, corrupt 0, gen 0

The above repeats like 10 times in 4 second intervals (more or less), and then a final:

Jan 21 11:35:32 ip144 kernel: ata11.00: exception Emask 0x0 SAct 0x7fffffff SErr 0x0 action 0x0
Jan 21 11:35:32 ip144 kernel: ata11.00: irq_stat 0x40000008
Jan 21 11:35:32 ip144 kernel: ata11.00: failed command: READ FPDMA QUEUED
Jan 21 11:35:32 ip144 kernel: ata11.00: cmd 60/80:58:90:f2:da/01:00:01:00:00/40 tag 11 ncq 196608 in
Jan 21 11:35:32 ip144 kernel:         res 41/40:00:90:f2:da/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Jan 21 11:35:32 ip144 kernel: ata11.00: status: { DRDY ERR }
Jan 21 11:35:32 ip144 kernel: ata11.00: error: { UNC }
Jan 21 11:35:32 ip144 kernel: ata11.00: configured for UDMA/133
Jan 21 11:35:32 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:35:32 ip144 kernel: Result: hostbyte=0x00 driverbyte=0x08
Jan 21 11:35:32 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:35:32 ip144 kernel: Sense Key : 0x3 [current] [descriptor]
Jan 21 11:35:32 ip144 kernel: Descriptor sense data with sense descriptors (in hex):
Jan 21 11:35:32 ip144 kernel:        72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00 
Jan 21 11:35:32 ip144 kernel:        01 da f2 90 
Jan 21 11:35:32 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 11:35:32 ip144 kernel: ASC=0x11 ASCQ=0x4
Jan 21 11:35:32 ip144 kernel: sd 10:0:0:0: [sdg] CDB: 
Jan 21 11:35:32 ip144 kernel: cdb[0]=0x88: 88 00 00 00 00 00 01 da f2 90 00 00 01 80 00 00
Jan 21 11:35:32 ip144 kernel: blk_update_request: I/O error, dev sdg, sector 31126160
Jan 21 11:35:32 ip144 kernel: ata11: EH complete
Jan 21 11:35:32 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 130, flush 0, corrupt 0, gen 0
Jan 21 11:35:32 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 131, flush 0, corrupt 0, gen 0
Jan 21 11:35:32 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 132, flush 0, corrupt 0, gen 0
Jan 21 11:35:32 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 133, flush 0, corrupt 0, gen 0
Jan 21 11:35:32 ip144 kernel: BTRFS: bdev /dev/bcache2 errs: wr 0, rd 134, flush 0, corrupt 0, gen 0
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131932160 (dev /dev/bcache2 sector 31126160)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131981312 (dev /dev/bcache2 sector 31126256)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131936256 (dev /dev/bcache2 sector 31126168)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131964928 (dev /dev/bcache2 sector 31126224)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131923968 (dev /dev/bcache2 sector 31126144)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131948544 (dev /dev/bcache2 sector 31126192)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131944448 (dev /dev/bcache2 sector 31126184)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 131956736 (dev /dev/bcache2 sector 31126208)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 132001792 (dev /dev/bcache2 sector 31126296)
Jan 21 11:35:33 ip144 kernel: BTRFS: read error corrected: ino 318562 off 132009984 (dev /dev/bcache2 sector 31126312)

After that the system freezes with a kernel oops in btrfs land.

c. Upon reboot, the kernel reports the following:

Jan 21 11:43:46 ip144 kernel: bcache: register_cache() registered cache device sda3
Jan 21 11:43:46 ip144 kernel: bcache: register_cache() registered cache device sdb3
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdg
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdc
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdf
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sde
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdd
Jan 21 11:43:46 ip144 kernel: bcache: error on 04063132-f7e1-4f29-a3aa-675491b426f4: sdb3: bad magic (got 17495323148306469098 expect 5629218783827753365) while reading prios from bucket 16868
Jan 21 11:43:46 ip144 kernel: bcache: register_bcache() error opening /dev/sdb3: error reading priorities
Jan 21 11:43:46 ip144 kernel: bcache: bch_cache_read_only() sda3 read only
Jan 21 11:43:46 ip144 kernel: bcache: bch_cache_read_only() sdb3 read only
Jan 21 11:43:46 ip144 kernel: bcache: cache_set_free() Cache set 04063132-f7e1-4f29-a3aa-675491b426f4 unregistered
Jan 21 11:43:46 ip144 kernel: bcache: bch_cache_release() sda3 removed
Jan 21 11:43:46 ip144 kernel: bcache: bch_cache_release() sdb3 removed

Now, the data on this filesystem is non-critical, so I could either attempt a repair or wipe and start over. Any suggestions?
Writeback was on, so simply reformatting sdb3 most likely will result in mayhem. I should probably take out sdg and replace it with a drive without errors.

Signature · 1 line
Stephen.
#3 lore raw

Well, what I did was:
- Take out sdg.
- Reformat both caching and backing devices and started over.

I still have the kernel logs of the previous fault condition, but not the data anymore.

What I notice are:
- The 100% CPU usage for four bcache_writebac processes is back. I've already tried raising the value you suggested from 30 to 60, but I did not have an opportunity to reboot yet. Will report back on this.
- When I run bcache-super-show on the backing devices, it works just fine.
- When I run bcache-super-show on the caching devices (while in service) I get something like this:

sb.magic ok
sb.first_sector 8 [match]
sb.csum FFFFFFFF5D55BF8D [expected 726D3B42D08769EC]
Corrupt superblock (bad csum)

On both caching devices. Is this to be expected?

Signature · 1 line
Stephen.
#4 lore raw

patch (Re: 3.18.3 + latest bcache-dev)

Quoted 4 lines · Stephen R. van den Berg

What I notice are:
- The 100% CPU usage for four bcache_writebac processes is back. I've already tried raising the value you suggested from 30 to 60, but I did not have an opportunity to reboot yet. Will report back on this.

What I saw:
a. After running several hours, copying roughly 3.0TB through the two
SSD caching devices onto the BTRFS backing device consisting of four HDDs, the bcache_writebac processes were still eating 100% CPU each.
b. Then did a manual umount of the fs, then stopped the bcache device
through the proc filesystem.
c. Rebooted.
d. Came back in a patched kernel, 100% CPU usage is gone.

The patch I used (I did not investigate the correctness of the value picked, I simply doubled it as an initial guess):

commit 2abecdbd214c94741012de32759bb0de4c6adbf9

Author: Stephen R. van den Berg <[email protected]>
Date:   Tue Jan 13 23:24:52 2015 +0100

Increase btree_scan_ratelimit to avoid 100% CPU hogging.

drivers/md/bcache/super.c +1 -1
index 653419b..5fff8ad 100644
@@ -867,7 +867,7 @@ static struct cache_set *bch_cache_set_alloc(struct cache *ca)
 	c->error_limit	= 16 << IO_ERROR_SHIFT;
 
 	c->tiering_percent = 10;
-	c->btree_scan_ratelimit = 30;
+	c->btree_scan_ratelimit = 60;
 
 	c->copy_gc_enabled = 1;
 	c->tiering_enabled = 1;
Signature · 1 line
Stephen.
#5 lore raw

Re: patch (Re: 3.18.3 + latest bcache-dev)

Quoted 1 line · Stephen R. van den Berg

d. Came back in a patched kernel, 100% CPU usage is gone.

I spoke too soon. After some more copying, the 100% CPU is back, but different:
Before I had four or five HDDs, but in both cases I had four bcache_writebac processes running at 100%.
Now I have four HDDs, and also four bcache_writebac processes, but only three of those run at 100% CPU. The fourth one is idle (mostly).

Signature · 1 line
Stephen.
#6 lore raw
In reply to Stephen R. van den Berg
Quoted 9 lines · Stephen R. van den Berg
Jan 21 11:21:40 ip144 kernel: ata11.00: exception Emask 0x0 SAct 0x7fffffff SErr 0x0 action 0x0
Jan 21 11:21:40 ip144 kernel: ata11.00: irq_stat 0x40000008
Jan 21 11:21:40 ip144 kernel: ata11.00: failed command: READ FPDMA QUEUED
Jan 21 11:21:40 ip144 kernel: ata11.00: cmd 60/00:c0:10:d0:d9/04:00:01:00:00/40 tag 24 ncq 524288 in
Jan 21 11:21:40 ip144 kernel:         res 41/40:00:d0:d1:d9/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Jan 21 11:21:40 ip144 kernel: ata11.00: status: { DRDY ERR }
Jan 21 11:21:40 ip144 kernel: ata11.00: error: { UNC }
Jan 21 11:21:40 ip144 kernel: ata11.00: configured for UDMA/133

I'm not sure this is related. Do you see it during normal operation ever? It is possible that we're spinning in softirq context or something, starving the device, but I'm not sure...

Quoted 9 lines
Jan 21 11:43:46 ip144 kernel: bcache: register_cache() registered cache device sda3
Jan 21 11:43:46 ip144 kernel: bcache: register_cache() registered cache device sdb3
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdg
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdc
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdf
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sde
Jan 21 11:43:46 ip144 kernel: bcache: register_bdev() registered backing device sdd
Jan 21 11:43:46 ip144 kernel: bcache: error on 04063132-f7e1-4f29-a3aa-675491b426f4: sdb3: bad magic (got 17495323148306469098 expect 5629218783827753365) while reading prios from bucket 16868
Jan 21 11:43:46 ip144 kernel: bcache: register_bcache() error opening /dev/sdb3: error reading priorities

This is a bcache-dev bug that we just hit in our automation runs after adding some more reboot tests. We're working on it.

Slava

#7 lore raw
Quoted 10 lines · Slava Pestov
Quoted 8 lines · Stephen R. van den Berg
Jan 21 11:21:40 ip144 kernel: ata11.00: exception Emask 0x0 SAct 0x7fffffff SErr 0x0 action 0x0
Jan 21 11:21:40 ip144 kernel: ata11.00: irq_stat 0x40000008
Jan 21 11:21:40 ip144 kernel: ata11.00: failed command: READ FPDMA QUEUED
Jan 21 11:21:40 ip144 kernel: ata11.00: cmd 60/00:c0:10:d0:d9/04:00:01:00:00/40 tag 24 ncq 524288 in
Jan 21 11:21:40 ip144 kernel:         res 41/40:00:d0:d1:d9/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Jan 21 11:21:40 ip144 kernel: ata11.00: status: { DRDY ERR }
Jan 21 11:21:40 ip144 kernel: ata11.00: error: { UNC }
Jan 21 11:21:40 ip144 kernel: ata11.00: configured for UDMA/133
Quoted 3 lines

I'm not sure this is related. Do you see it during normal operation ever? It is possible that we're spinning in softirq context or something, starving the device, but I'm not sure...

In the second run now, with increased traffic, I do not see the above happening.

Maybe I cut it short, the whole message is:

Jan 21 12:09:14 ip144 kernel: ata11.00: exception Emask 0x0 SAct 0x3000 SErr 0x0 action 0x0
Jan 21 12:09:14 ip144 kernel: ata11.00: irq_stat 0x40000008
Jan 21 12:09:14 ip144 kernel: ata11.00: failed command: READ FPDMA QUEUED
Jan 21 12:09:14 ip144 kernel: ata11.00: cmd 60/00:68:e8:2b:da/01:00:01:00:00/40 tag 13 ncq 131072 in
Jan 21 12:09:14 ip144 kernel:         res 41/40:00:b0:2c:da/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Jan 21 12:09:14 ip144 kernel: ata11.00: status: { DRDY ERR }
Jan 21 12:09:14 ip144 kernel: ata11.00: error: { UNC }
Jan 21 12:09:14 ip144 kernel: ata11.00: configured for UDMA/133
Jan 21 12:09:14 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 12:09:14 ip144 kernel: Result: hostbyte=0x00 driverbyte=0x08
Jan 21 12:09:14 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 12:09:14 ip144 kernel: Sense Key : 0x3 [current] [descriptor]
Jan 21 12:09:14 ip144 kernel: Descriptor sense data with sense descriptors (in hex):
Jan 21 12:09:14 ip144 kernel:        72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00 
Jan 21 12:09:14 ip144 kernel:        01 da 2c b0 
Jan 21 12:09:14 ip144 kernel: sd 10:0:0:0: [sdg]  
Jan 21 12:09:14 ip144 kernel: ASC=0x11 ASCQ=0x4
Jan 21 12:09:14 ip144 kernel: sd 10:0:0:0: [sdg] CDB: 
Jan 21 12:09:14 ip144 kernel: cdb[0]=0x88: 88 00 00 00 00 00 01 da 2b e8 00 00 01 00 00 00
Jan 21 12:09:14 ip144 kernel: blk_update_request: I/O error, dev sdg, sector 31075504
Jan 21 12:09:14 ip144 kernel: ata11: EH complete

And it always happens upon a read error from HDD.

Signature · 1 line
Stephen.