bisecting fixing commit since dc641794929713c30b5c375da0c664d7e00bfded building syzkaller on a4718693a3d9fcabb02299b2ec07c19d8208c539 testing commit dc641794929713c30b5c375da0c664d7e00bfded with gcc (GCC) 8.1.0 run #0: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #1: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #2: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #3: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #4: crashed: WARNING: suspicious RCU usage run #5: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #6: crashed: WARNING: suspicious RCU usage run #7: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #8: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #9: crashed: WARNING: suspicious RCU usage in trace_call_bpf testing current HEAD 91b4db5313a2c793aabc2143efb8ed0cf0fdd097 testing commit 91b4db5313a2c793aabc2143efb8ed0cf0fdd097 with gcc (GCC) 8.1.0 all runs: OK # git bisect start 91b4db5313a2c793aabc2143efb8ed0cf0fdd097 dc641794929713c30b5c375da0c664d7e00bfded Bisecting: 37296 revisions left to test after this (roughly 15 steps) [54d50897d544c874562253e2a8f70dfcad22afe8] linux/kernel.h: split *_MAX and *_MIN macros into testing commit 54d50897d544c874562253e2a8f70dfcad22afe8 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 54d50897d544c874562253e2a8f70dfcad22afe8 Bisecting: 18699 revisions left to test after this (roughly 14 steps) [aa9d6e0f33aea8a1879e7e53fe0e436943f9ce0c] linux/netlink.h: drop unnecessary extern prefix testing commit aa9d6e0f33aea8a1879e7e53fe0e436943f9ce0c with gcc (GCC) 8.1.0 all runs: OK # git bisect bad aa9d6e0f33aea8a1879e7e53fe0e436943f9ce0c Bisecting: 9358 revisions left to test after this (roughly 13 steps) [c7a2c49ea6c9eebbe44ff2c08b663b2905ee2c13] Merge tag 'nfs-for-4.20-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs testing commit c7a2c49ea6c9eebbe44ff2c08b663b2905ee2c13 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad c7a2c49ea6c9eebbe44ff2c08b663b2905ee2c13 Bisecting: 4947 revisions left to test after this (roughly 12 steps) [3f80e08f40cdb308589a49077c87632fa4508b21] tcp: add tcp_reset_xmit_timer() helper testing commit 3f80e08f40cdb308589a49077c87632fa4508b21 with gcc (GCC) 8.1.0 run #0: basic kernel testing failed: failed to copy test binary to VM: failed to run ["scp" "-P" "22" "-F" "/dev/null" "-o" "UserKnownHostsFile=/dev/null" "-o" "BatchMode=yes" "-o" "IdentitiesOnly=yes" "-o" "StrictHostKeyChecking=no" "-o" "ConnectTimeout=10" "-i" "/syzkaller/jobs/linux/workdir/image/key" "/tmp/syz-executor467003403" "root@10.128.15.204:./syz-executor467003403"]: exit status 1 ssh: connect to host 10.128.15.204 port 22: Connection timed out lost connection run #1: OK run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 3f80e08f40cdb308589a49077c87632fa4508b21 Bisecting: 2283 revisions left to test after this (roughly 11 steps) [d5486377b8c526e4f373ec0506c4c5398c99082e] Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue testing commit d5486377b8c526e4f373ec0506c4c5398c99082e with gcc (GCC) 8.1.0 all runs: OK # git bisect bad d5486377b8c526e4f373ec0506c4c5398c99082e Bisecting: 1010 revisions left to test after this (roughly 10 steps) [52890d2afc6a06d6121ae1fd4bfc2448b0d67728] Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip testing commit 52890d2afc6a06d6121ae1fd4bfc2448b0d67728 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 52890d2afc6a06d6121ae1fd4bfc2448b0d67728 Bisecting: 510 revisions left to test after this (roughly 9 steps) [2b6318a09fd346edea42a60f8d0c07b2eea2d079] Merge branch 'linux-4.19' of git://github.com/skeggsb/linux into drm-fixes testing commit 2b6318a09fd346edea42a60f8d0c07b2eea2d079 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 2b6318a09fd346edea42a60f8d0c07b2eea2d079 Bisecting: 236 revisions left to test after this (roughly 8 steps) [28619527b8a712590c93d0a9e24b4425b9376a8c] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net testing commit 28619527b8a712590c93d0a9e24b4425b9376a8c with gcc (GCC) 8.1.0 run #0: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #1: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #2: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #3: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #4: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #5: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #6: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #7: crashed: WARNING: suspicious RCU usage run #8: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #9: crashed: WARNING: suspicious RCU usage # git bisect good 28619527b8a712590c93d0a9e24b4425b9376a8c Bisecting: 118 revisions left to test after this (roughly 7 steps) [3d0e7a9e00fd8f0de499ac3f57331d0d378304c4] Merge tag 'md/4.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md testing commit 3d0e7a9e00fd8f0de499ac3f57331d0d378304c4 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 3d0e7a9e00fd8f0de499ac3f57331d0d378304c4 Bisecting: 61 revisions left to test after this (roughly 6 steps) [b36fdc6853a38a6f8749897a33435635019e0647] Merge tag 'gpio-v4.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio testing commit b36fdc6853a38a6f8749897a33435635019e0647 with gcc (GCC) 8.1.0 run #0: crashed: WARNING: suspicious RCU usage run #1: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #2: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #3: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #4: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #5: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #6: crashed: WARNING: suspicious RCU usage run #7: crashed: WARNING: suspicious RCU usage in trace_call_bpf run #8: crashed: WARNING: suspicious RCU usage in corrupted run #9: crashed: WARNING: suspicious RCU usage in trace_call_bpf # git bisect good b36fdc6853a38a6f8749897a33435635019e0647 Bisecting: 31 revisions left to test after this (roughly 5 steps) [631267f6adcc8d760d145dbd33d83d133d2733d7] Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu testing commit 631267f6adcc8d760d145dbd33d83d133d2733d7 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 631267f6adcc8d760d145dbd33d83d133d2733d7 Bisecting: 16 revisions left to test after this (roughly 4 steps) [db44bf4b4768a0664d3c9d9000ecb747de31ded8] Merge tag 'apparmor-pr-2018-09-06' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor testing commit db44bf4b4768a0664d3c9d9000ecb747de31ded8 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad db44bf4b4768a0664d3c9d9000ecb747de31ded8 Bisecting: 6 revisions left to test after this (roughly 3 steps) [b9b8a41adeff5666b402996020b698504c927353] btrfs: use after free in btrfs_quota_enable testing commit b9b8a41adeff5666b402996020b698504c927353 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad b9b8a41adeff5666b402996020b698504c927353 Bisecting: 2 revisions left to test after this (roughly 2 steps) [de02b9f6bb65a6a1848f346f7a3617b7a9b930c0] Btrfs: fix data corruption when deduplicating between different files testing commit de02b9f6bb65a6a1848f346f7a3617b7a9b930c0 with gcc (GCC) 8.1.0 run #0: basic kernel testing failed: failed to copy test binary to VM: failed to run ["scp" "-P" "22" "-F" "/dev/null" "-o" "UserKnownHostsFile=/dev/null" "-o" "BatchMode=yes" "-o" "IdentitiesOnly=yes" "-o" "StrictHostKeyChecking=no" "-o" "ConnectTimeout=10" "-i" "/syzkaller/jobs/linux/workdir/image/key" "/tmp/syz-executor581906061" "root@10.128.0.54:./syz-executor581906061"]: exit status 1 ssh: connect to host 10.128.0.54 port 22: Connection timed out lost connection run #1: OK run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad de02b9f6bb65a6a1848f346f7a3617b7a9b930c0 Bisecting: 0 revisions left to test after this (roughly 1 step) [d4682ba03ef618b6ef4be7cedc7aacaf505d3a58] Btrfs: sync log after logging new name testing commit d4682ba03ef618b6ef4be7cedc7aacaf505d3a58 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad d4682ba03ef618b6ef4be7cedc7aacaf505d3a58 Bisecting: 0 revisions left to test after this (roughly 0 steps) [8ecebf4d767e2307a946c8905278d6358eda35c3] Btrfs: fix unexpected failure of nocow buffered writes after snapshotting when low on space testing commit 8ecebf4d767e2307a946c8905278d6358eda35c3 with gcc (GCC) 8.1.0 all runs: OK # git bisect bad 8ecebf4d767e2307a946c8905278d6358eda35c3 8ecebf4d767e2307a946c8905278d6358eda35c3 is the first bad commit commit 8ecebf4d767e2307a946c8905278d6358eda35c3 Author: Robbie Ko Date: Mon Aug 6 10:30:30 2018 +0800 Btrfs: fix unexpected failure of nocow buffered writes after snapshotting when low on space Commit e9894fd3e3b3 ("Btrfs: fix snapshot vs nocow writting") forced nocow writes to fallback to COW, during writeback, when a snapshot is created. This resulted in writes made before creating the snapshot to unexpectedly fail with ENOSPC during writeback when success (0) was returned to user space through the write system call. The steps leading to this problem are: 1. When it's not possible to allocate data space for a write, the buffered write path checks if a NOCOW write is possible. If it is, it will not reserve space and success (0) is returned to user space. 2. Then when a snapshot is created, the root's will_be_snapshotted atomic is incremented and writeback is triggered for all inode's that belong to the root being snapshotted. Incrementing that atomic forces all previous writes to fallback to COW during writeback (running delalloc). 3. This results in the writeback for the inodes to fail and therefore setting the ENOSPC error in their mappings, so that a subsequent fsync on them will report the error to user space. So it's not a completely silent data loss (since fsync will report ENOSPC) but it's a very unexpected and undesirable behaviour, because if a clean shutdown/unmount of the filesystem happens without previous calls to fsync, it is expected to have the data present in the files after mounting the filesystem again. So fix this by adding a new atomic named snapshot_force_cow to the root structure which prevents this behaviour and works the following way: 1. It is incremented when we start to create a snapshot after triggering writeback and before waiting for writeback to finish. 2. This new atomic is now what is used by writeback (running delalloc) to decide whether we need to fallback to COW or not. Because we incremented this new atomic after triggering writeback in the snapshot creation ioctl, we ensure that all buffered writes that happened before snapshot creation will succeed and not fallback to COW (which would make them fail with ENOSPC). 3. The existing atomic, will_be_snapshotted, is kept because it is used to force new buffered writes, that start after we started snapshotting, to reserve data space even when NOCOW is possible. This makes these writes fail early with ENOSPC when there's no available space to allocate, preventing the unexpected behaviour of writeback later failing with ENOSPC due to a fallback to COW mode. Fixes: e9894fd3e3b3 ("Btrfs: fix snapshot vs nocow writting") Signed-off-by: Robbie Ko Reviewed-by: Filipe Manana Signed-off-by: David Sterba :040000 040000 5eb7b5114159d80e4d2fe0ddc488140630321bc0 63919bdec226d2b461c9f2bf8caf8359b02ba31e M fs revisions tested: 18, total time: 4h22m9.612182081s (build: 1h26m37.583393449s, test: 2h48m53.711072041s) first good commit: 8ecebf4d767e2307a946c8905278d6358eda35c3 Btrfs: fix unexpected failure of nocow buffered writes after snapshotting when low on space cc: ["clm@fb.com" "dsterba@suse.com" "fdmanana@suse.com" "josef@toxicpanda.com" "linux-btrfs@vger.kernel.org" "linux-kernel@vger.kernel.org" "robbieko@synology.com"]