Hi,
I have a test 4GB flash drive with bad sectors which I use to test file systems. Just dump dd to the entire of free space
Ext4 fails as soon as it encounters a bad block and complains about inode_write:
[11734.653017] EXT4-fs warning (device sde1): ext4_end_bio:317: I/O error -121 writing to inode 12 (offset 2155872256 size 4194304 starting block 617094)
[11734.754864] EXT4-fs warning (device sde1): ext4_end_bio:317: I/O error -121 writing to inode 12 (offset 2155872256 size 4194304 starting block 617124)
[11736.484040] EXT4-fs error (device sde1) in ext4_reserve_inode_write:4886: Journal has aborted
[11736.494118] EXT4-fs error (device sde1): mpage_map_and_submit_extent:2267: comm kworker/u128:6: Failed to mark inode 12 dirty
linux:/ # mount /dev/sde1 /mnt
linux:/ # dd_rescue /dev/zero /mnt/dd.bin
dd_rescue: (info): Using softbs=128.0kiB, hardbs=4.0kiB
dd_rescue: (info): ipos: 2363392.0k, opos: 2363392.0k, xferd: 2363392.0k
errs: 0, errxfer: 0.0k, succxfer: 2363392.0k
+curr.rate: 3731kB/s, avg.rate: 3550kB/s, avg.load: 0.5%
dd_rescue: (warning): write /mnt/dd.bin (2364544.0kiB): Read-only file system
dd_rescue: (warning): assumption rd(131072) == wr(-30) failed!
dd_rescue: (fatal): write /mnt/dd.bin (2364543.0kiB): Read-only file system!
dd_rescue: (info): Summary for /dev/zero -> /mnt/dd.bin
dd_rescue: (warning): sync /mnt/dd.bin (2364672.0skiB): Read-only file system!
dd_rescue: (info): ipos: 2364672.0k, opos: 2364672.0k, xferd: 2364672.0k
errs: 1, errxfer: 0.0k, succxfer: 2364543.0k
+curr.rate: 2801kB/s, avg.rate: 3090kB/s, avg.load: 0.4%
dd_rescue: (warning): fsync /mnt/dd.bin (2364672.0kiB): Read-only file system!
But btrfs while dumps errors in dmesg continues writing and reports written 11GB+ successfully until I kill dd using crtl+c:
[15702.279946] end_request: critical target error, dev sde, sector 3958304
[15702.279950] BTRFS: bdev /dev/sde1 errs: wr 67719, rd 0, flush 0, corrupt 0, gen 0
[15702.280030] BTRFS: bdev /dev/sde1 errs: wr 67720, rd 0, flush 0, corrupt 0, gen 0
[15702.280052] BTRFS: bdev /dev/sde1 errs: wr 67721, rd 0, flush 0, corrupt 0, gen 0
[15702.281510] BTRFS: lost page write due to I/O error on /dev/sde1
[15702.281536] BTRFS: lost page write due to I/O error on /dev/sde1
[15702.281590] BTRFS: error (device sde1) in write_all_supers:3498: errno=-5 IO failure (1 errors while writing supers)
[15702.281592] BTRFS info (device sde1): forced readonly
[15702.281593] BTRFS warning (device sde1): Skipping commit of aborted transaction.
[15702.281619] ------------ cut here ]------------
[15702.281831] WARNING: CPU: 1 PID: 11201 at ../fs/btrfs/super.c:259 __btrfs_abort_transaction+0x4b/0x110 [btrfs]()
[15702.281836] BTRFS: Transaction aborted (error -5)
[15702.281837] Modules linked in: binfmt_misc uas usb_storage fuse bnep bluetooth 6lowpan_iphc af_packet cfg80211 rfkill raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx md_mod coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd ppdev vmw_balloon serio_raw pcspkr e1000 battery parport_pc parport i2c_piix4 mptctl vmw_vmci shpchp processor button ac dm_mod btrfs xor raid6_pq sr_mod cdrom ata_generic crc32c_intel ata_piix vmwgfx drm_kms_helper ttm drm mptspi scsi_transport_spi mptscsih mptbase floppy sg
[15702.281898] CPU: 1 PID: 11201 Comm: btrfs-transacti Not tainted 3.16.2-1.gdcee397-desktop #1
[15702.281899] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013
[15702.281901] 0000000000000009 ffffffff81619ea5 ffff8800320e7d30 ffffffff8105bab7
[15702.281902] 00000000fffffffb ffff8800320e7d80 ffff880031da9a20 ffffffffa0203050
[15702.281903] 0000000000000623 ffffffff8105bb1c ffffffffa0207238 ffff880000000020
[15702.281905] Call Trace:
[15702.281997] <ffffffff8100519e>] dump_trace+0x8e/0x350
[15702.282000] <ffffffff81005506>] show_stack_log_lvl+0xa6/0x190
[15702.282002] <ffffffff81006c01>] show_stack+0x21/0x50
[15702.282030] <ffffffff81619ea5>] dump_stack+0x49/0x6a
[15702.282061] <ffffffff8105bab7>] warn_slowpath_common+0x77/0x90
[15702.282075] <ffffffff8105bb1c>] warn_slowpath_fmt+0x4c/0x50
[15702.282082] <ffffffffa015d02b>] __btrfs_abort_transaction+0x4b/0x110 [btrfs]
[15702.282113] <ffffffffa0189dcf>] cleanup_transaction+0x6f/0x2d0 [btrfs]
[15702.282194] <ffffffffa018b329>] btrfs_commit_transaction.part.21+0x259/0x9f0 [btrfs]
[15702.282218] <ffffffffa01865b5>] transaction_kthread+0x1a5/0x230 [btrfs]
[15702.282249] <ffffffff8107cd2d>] kthread+0xbd/0xe0
[15702.282266] <ffffffff81620afc>] ret_from_fork+0x7c/0xb0
[15702.282280] --- end trace a31a596d0b589efa ]---
[15702.282282] BTRFS: error (device sde1) in cleanup_transaction:1571: errno=-5 IO failure
linux:/ # mkfs.btrfs -f /dev/sde1
Btrfs v3.16
See http://btrfs.wiki.kernel.org for more information.
Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
fs created label (null) on /dev/sde1
nodesize 16384 leafsize 16384 sectorsize 4096 size 3.76GiB
linux:/ # mount /dev/sde1 /mnt
linux:/ # dd_rescue /dev/zero /mnt/dd.bin
dd_rescue: (info): Using softbs=128.0kiB, hardbs=4.0kiB
dd_rescue: (info): ipos: 11776000.0k, opos: 11776000.0k, xferd: 11776000.0k
errs: 0, errxfer: 0.0k, succxfer: 11776000.0k
+curr.rate: 2294kB/s, avg.rate: 3089kB/s, avg.load: 0.3%
^Cdd_rescue: (fatal): Caught signal 2 "Interrupt". Flush and exit after current block!
dd_rescue: (info): Summary for /dev/zero -> /mnt/dd.bin
dd_rescue: (warning): sync /mnt/dd.bin (11776512.0skiB): Input/output error!
dd_rescue: (info): ipos: 11776512.0k, opos: 11776512.0k, xferd: 11776512.0k
errs: 0, errxfer: 0.0k, succxfer: 11776512.0k
+curr.rate: 1722kB/s, avg.rate: 3016kB/s, avg.load: 0.3%
dd_rescue: (warning): fsync /mnt/dd.bin (11776512.0kiB): Read-only file system!
user@linux:~> df -h | grep sde1
/dev/sde1 3.8G 1.4G 2.1G 39% /mnt
user@linux:~> ls /mnt/ -l
total 1371492
-rw-r----- 1 root root 11981717504 Oct 20 11:57 dd.bin
Looks like a bug to me. What else think?