generic/04[89] fail on XFS due to change in writeback code
Hi all,
I've been seeing generic/04[89] fails on XFS since 4.2-rc1 from time to time, but the failure isn't reproduced on every test host. Recently I finally got a host that could reproduce the failure reliably.
It's a regression since 4.1 kernel based on my tests, 4.1 kernel passed the tests and the failures showed up starting from 4.2-rc1.
What xfstests generic/04[89] test is
[root@dhcp-66-86-11 xfstests]# ./lsqa.pl tests/generic/04[89] FSQA Test No. 048
Test for NULL files problem
test inode size is on disk after sync
--------------------------------------------------
FSQA Test No. 049
Test for NULL files problem
test inode size is on disk after sync - expose log replay bug
--------------------------------------------------
And the failure is like (test files have zero size)
root@dhcp-66-86-11 xfstests]# ./check generic/048
FSTYP -- xfs (non-debug) PLATFORM -- Linux/x86_64 dhcp-66-86-11 4.2.0-rc5 MKFS_OPTIONS -- -f -bsize=4096 /dev/sda6
MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/sda6 /mnt/testarea/scratch
generic/048 28s ... - output mismatch (see /root/xfstests/results//generic/048.out.bad)
--- tests/generic/048.out 2015-07-16 17:28:15.800000000 +0800
+++ /root/xfstests/results//generic/048.out.bad 2015-08-12 18:04:52.923000000 +0800
@@ -1 +1,32 @@
QA output created by 048
+file /mnt/testarea/scratch/969 has incorrect size - sync failed +file /mnt/testarea/scratch/970 has incorrect size - sync failed +file /mnt/testarea/scratch/971 has incorrect size - sync failed +file /mnt/testarea/scratch/972 has incorrect size - sync failed +file /mnt/testarea/scratch/973 has incorrect size - sync failed +file /mnt/testarea/scratch/974 has incorrect size - sync failed
...
And I bisected to the following commit
commit e79729123f6392b36450113c6c52074b7d389c85
Author: Tejun Heo <[email protected]> Date: Fri May 22 17:13:48 2015 -0400
writeback: don't issue wb_writeback_work if clean
There are several places in fs/fs-writeback.c which queues wb_writeback_work without checking whether the target wb (bdi_writeback) has dirty inodes or not. The only thing wb_writeback_work does is writing back the dirty inodes for the target wb and queueing a work item for a clean wb is essentially noop. There are some side effects such as bandwidth stats being updated and triggering tracepoints but these don't affect the operation in any meaningful way.
This patch makes all writeback_inodes_sb_nr() and sync_inodes_sb() skip wb_queue_work() if the target bdi is clean. Also, it moves dirtiness check from wakeup_flusher_threads() to __wb_start_writeback() so that all its callers benefit from the check.
While the overhead incurred by scheduling a noop work isn't currently significant, the overhead may be higher with cgroup writeback support as we may end up issuing noop work items to a lot of clean wb's.
Attachments are my xfstests config file and host info requested by
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
If you need more info please let me know.
Thanks,
Eryu
It's a RHEL7 kvm guest running on RHEL6.6 with 8G mem and 4 vcpus.
The disk configuration in guest xml is
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/home/osimage/rhel7.img'/>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/></disk>
[root@dhcp-66-86-11 ~]# grep -c proc /proc/cpuinfo 4
[root@dhcp-66-86-11 ~]# cat /proc/meminfo
MemTotal: 7912932 kB MemFree: 7547480 kB MemAvailable: 7599440 kB Buffers: 944 kB Cached: 219292 kB SwapCached: 0 kB Active: 170072 kB Inactive: 106352 kB Active(anon): 56476 kB Inactive(anon): 8384 kB Active(file): 113596 kB Inactive(file): 97968 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 8257532 kB SwapFree: 8257532 kB Dirty: 42556 kB Writeback: 0 kB AnonPages: 56020 kB Mapped: 33008 kB Shmem: 8552 kB Slab: 42520 kB SReclaimable: 18648 kB SUnreclaim: 23872 kB KernelStack: 2336 kB PageTables: 3280 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 12213996 kB Committed_AS: 260636 kB VmallocTotal: 34359738367 kB VmallocUsed: 26336 kB VmallocChunk: 34359623680 kB HardwareCorrupted: 0 kB AnonHugePages: 12288 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 69620 kB DirectMap2M: 8318976 kB
[root@dhcp-66-86-11 ~]# cat /proc/mounts
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=3943408k,nr_inodes=985852,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs rw,seclabel,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0/dev/sda3 / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0/dev/sda1 /boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0/dev/sda6 /mnt/testarea/scratch xfs rw,context=system_u:object_r:nfs_t:s0,relatime,attr2,inode64,noquota 0 0/dev/sda5 /mnt/testarea/test xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
[root@dhcp-66-86-11 ~]# cat /proc/partitions
major minor #blocks name
8 0 314572800 sda 8 1 512000 sda1 8 2 8257536 sda2 8 3 52428800 sda3 8 4 1 sda4 8 5 15728640 sda5 8 6 15728640 sda6 8 7 15728640 sda7 8 8 15728640 sda8 8 9 15728640 sda9 8 10 15728640 sda10 8 11 15728640 sda11 8 16 104857600 sdb 8 17 104856576 sdb1
[root@dhcp-66-86-11 ~]# lvs
[root@dhcp-66-86-11 ~]#
TEST_DEV=/dev/sda5
TEST_DIR=/mnt/testarea/test # mount point of TEST PARTITION
SCRATCH_MNT=/mnt/testarea/scratch # mount point for SCRATCH PARTITION
SCRATCH_DEV=/dev/sda6
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Eryu Guan
Hi all,
I've been seeing generic/04[89] fails on XFS since 4.2-rc1 from time to time, but the failure isn't reproduced on every test host. Recently I finally got a host that could reproduce the failure reliably.
[snip]
Quoted 3 lines
Attachments are my xfstests config file and host info requested by
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Oh, one more thing, I'm using xfsprogs 4.2.0-rc1 from upstream, but xfsprogs version doesn't matter here, xfsprogs-3.2.2-1.el7 shipped with RHEL7.1 makes no difference in my testing.
Thanks,
Eryu
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
In reply to Eryu Guan[cc linux-fsdevel because it looks like a sync regression in the generic writeback code. Also, not trimming away original email so people can read it in full. ]
Quoted 8 lines · Eryu Guan
Hi all,
I've been seeing generic/04[89] fails on XFS since 4.2-rc1 from time to time, but the failure isn't reproduced on every test host. Recently I finally got a host that could reproduce the failure reliably.
It's a regression since 4.1 kernel based on my tests, 4.1 kernel passed the tests and the failures showed up starting from 4.2-rc1.
I've seen this failure twice on one of my 1p/1GB RAM VMs in the past couple of weeks running 4.2-rc4 and 4.2-rc6, but I haven't been able to reproduce it reliably (2 failures in ~50 runs on the VM) so haven't been able to track down the cause. I even thought yesterday I should ask and see if anyone else is seeing this test fail occasionally, but then shit happened around here....
It might be a couple of days before I really get a chance to dig into this, so it might be best if Tejun can look into it first.
Cheers,
Dave.
Quoted 195 lines
What xfstests generic/04[89] test is
[root@dhcp-66-86-11 xfstests]# ./lsqa.pl tests/generic/04[89] FSQA Test No. 048
Test for NULL files problem
test inode size is on disk after sync--------------------------------------------------
FSQA Test No. 049Test for NULL files problem
test inode size is on disk after sync - expose log replay bug--------------------------------------------------
And the failure is like (test files have zero size)
root@dhcp-66-86-11 xfstests]# ./check generic/048
FSTYP -- xfs (non-debug) PLATFORM -- Linux/x86_64 dhcp-66-86-11 4.2.0-rc5 MKFS_OPTIONS -- -f -bsize=4096 /dev/sda6
MOUNT_OPTIONS-- -o context=system_u:object_r:nfs_t:s0/dev/sda6/mnt/testarea/scratchgeneric/048 28s ... - output mismatch (see
/root/xfstests/results//generic/048.out.bad)
--- tests/generic/048.out 2015-07-16 17:28:15.800000000 +0800
+++/root/xfstests/results//generic/048.out.bad2015-08-12 18:04:52.923000000 +0800
@@ -1 +1,32 @@
QA output created by 048
+file/mnt/testarea/scratch/969has incorrect size - sync failed +file/mnt/testarea/scratch/970has incorrect size - sync failed +file/mnt/testarea/scratch/971has incorrect size - sync failed +file/mnt/testarea/scratch/972has incorrect size - sync failed +file/mnt/testarea/scratch/973has incorrect size - sync failed +file/mnt/testarea/scratch/974has incorrect size - sync failed
...And I bisected to the following commit
commit
e79729123f6392b36450113c6c52074b7d389c85Author: Tejun Heo <[email protected]> Date: Fri May 22 17:13:48 2015 -0400writeback: don't issue
wb_writeback_workif cleanThere are several places in
fs/fs-writeback.cwhich queueswb_writeback_workwithout checking whether the target wb (bdi_writeback) has dirty inodes or not. The only thingwb_writeback_workdoes is writing back the dirty inodes for the target wb and queueing a work item for a clean wb is essentially noop. There are some side effects such as bandwidth stats being updated and triggering tracepoints but these don't affect the operation in any meaningful way.This patch makes all
writeback_inodes_sb_nr()andsync_inodes_sb()skipwb_queue_work()if the target bdi is clean. Also, it moves dirtiness check fromwakeup_flusher_threads()to__wb_start_writeback()so that all its callers benefit from the check.While the overhead incurred by scheduling a noop work isn't currently significant, the overhead may be higher with cgroup writeback support as we may end up issuing noop work items to a lot of clean wb's.
Signed-off-by Tejun Heo <[email protected]>Cc Jens Axboe <[email protected]>Cc Jan Kara <[email protected]>Signed-off-by Jens Axboe <[email protected]>Attachments are my xfstests config file and host info requested by
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3FIf you need more info please let me know.
Thanks,
EryuIt's a RHEL7 kvm guest running on RHEL6.6 with 8G mem and 4 vcpus.
The disk configuration in guest xml is
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/> <source file='/home/osimage/rhel7.img'/> <target dev='hda' bus='ide'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/></disk>
[root@dhcp-66-86-11 ~]# grep -c proc
/proc/cpuinfo4
[root@dhcp-66-86-11 ~]# cat/proc/meminfoMemTotal: 7912932 kB MemFree: 7547480 kB MemAvailable: 7599440 kB Buffers: 944 kB Cached: 219292 kB SwapCached: 0 kB Active: 170072 kB Inactive: 106352 kB Active(anon): 56476 kB Inactive(anon): 8384 kB Active(file): 113596 kB Inactive(file): 97968 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 8257532 kB SwapFree: 8257532 kB Dirty: 42556 kB Writeback: 0 kB AnonPages: 56020 kB Mapped: 33008 kB Shmem: 8552 kB Slab: 42520 kB SReclaimable: 18648 kB SUnreclaim: 23872 kB KernelStack: 2336 kB PageTables: 3280 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 12213996 kB Committed_AS: 260636 kB VmallocTotal: 34359738367 kB VmallocUsed: 26336 kB VmallocChunk: 34359623680 kB HardwareCorrupted: 0 kB AnonHugePages: 12288 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 69620 kB DirectMap2M: 8318976 kB[root@dhcp-66-86-11 ~]# cat
/proc/mounts
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=3943408k,nr_inodes=985852,mode=755 0 0
securityfs/sys/kernel/securitysecurityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs/dev/shmtmpfs rw,seclabel,nosuid,nodev 0 0
devpts/dev/ptsdevpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs/sys/fs/cgrouptmpfs rw,seclabel,nosuid,nodev,noexec,mode=755 0 0
cgroup/sys/fs/cgroup/systemdcgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 pstore/sys/fs/pstorepstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
cgroup/sys/fs/cgroup/cpusetcgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup/sys/fs/cgroup/cpu,cpuacctcgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup/sys/fs/cgroup/blkiocgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup/sys/fs/cgroup/memorycgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup/sys/fs/cgroup/devicescgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup/sys/fs/cgroup/freezercgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup/sys/fs/cgroup/net_clscgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0
cgroup/sys/fs/cgroup/perf_eventcgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup/sys/fs/cgroup/hugetlbcgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
configfs/sys/kernel/configconfigfs rw,relatime 0 0/dev/sda3/ xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
selinuxfs/sys/fs/selinuxselinuxfs rw,relatime 0 0
systemd-1/proc/sys/fs/binfmt_miscautofs rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0
debugfs/sys/kernel/debugdebugfs rw,seclabel,relatime 0 0
hugetlbfs/dev/hugepageshugetlbfs rw,seclabel,relatime 0 0
mqueue/dev/mqueuemqueue rw,seclabel,relatime 0 0/dev/sda1/boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0/dev/sda6/mnt/testarea/scratchxfs rw,context=system_u:object_r:nfs_t:s0,relatime,attr2,inode64,noquota 0 0/dev/sda5/mnt/testarea/testxfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
[root@dhcp-66-86-11 ~]# cat/proc/partitions
major minor #blocks name8 0 314572800 sda 8 1 512000 sda1 8 2 8257536 sda2 8 3 52428800 sda3 8 4 1 sda4 8 5 15728640 sda5 8 6 15728640 sda6 8 7 15728640 sda7 8 8 15728640 sda8 8 9 15728640 sda9 8 10 15728640 sda10 8 11 15728640 sda11 8 16 104857600 sdb 8 17 104856576 sdb1[root@dhcp-66-86-11 ~]# lvs
[root@dhcp-66-86-11 ~]#TEST_DEV=/dev/sda5
TEST_DIR=/mnt/testarea/test # mount point of TEST PARTITION
SCRATCH_MNT=/mnt/testarea/scratch # mount point for SCRATCH PARTITION
SCRATCH_DEV=/dev/sda6_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Signature · 2 lines
Dave Chinner [email protected]
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Quoted 2 lines · Dave Chinner
It might be a couple of days before I really get a chance to dig into this, so it might be best if Tejun can look into it first.
Yeap, have been looking into it since yesterday. I have some suspicions. I'll write once I know more.
Thanks.
Signature · 1 line
tejun
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Quoted 6 lines · Tejun Heo
Quoted 2 lines · Dave Chinner
It might be a couple of days before I really get a chance to dig into this, so it might be best if Tejun can look into it first.
Yeap, have been looking into it since yesterday. I have some suspicions. I'll write once I know more.
So, here are what I've found out till now.
* I can't reproduce it for some reason.
* There's a bug in b_dirty_time handling. sync_inodes_sb() should schedule writebacks regardless of b_dirty_time but it currently isn't. I'm working on a patch to fix it.
* But I can't see how the above bug would lead to failure of size sync. One possibility is that wb_has_dirty_io() and/or bdi_has_dirty_io() is getting out of sync for some reason. I'll write up a debug patch for this.
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/1 writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Dave Chinnere79729123f63 ("writeback: don't issue wb_writeback_work if clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and made sync_inodes_sb() skip I_DIRTY_TIME inodes. This patch fixes the breakage by
* Removing bdi_has_dirty_io() shortcut from bdi_split_work_to_wbs(). The callers are already testing the condition.
* Removing bdi_has_dirty_io() shortcut from sync_inodes_sb() so that it always calls into bdi_split_work_to_wbs().
* Making bdi_split_work_to_wbs() consider the b_dirty_time list for WB_SYNC_ALL writebacks.
---
Hello,
So, this fixes I_DIRTY_TIME syncing problem for ext4 but AFAICS xfs doesn't even use the generic inode metadata writeback path, so this most likely won't do anything for the originally reported problem. I'll post another patch for debugging.
Thanks.
fs/fs-writeback.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/fs-writeback.c +9 -9
@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && + (base_work->sync_mode ==WB_SYNC_NONE || +list_empty (&wb->b_dirty_time))) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);
@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;
@@ -2275,8 +2275,8 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* bdi_has_dirty() ignores I_DIRTY_TIME but we can't, always kick wbs */ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerRe: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello,
Quoted 12 lines · Tejun Heo
e79729123f63("writeback: don't issuewb_writeback_workif clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and madesync_inodes_sb()skipI_DIRTY_TIMEinodes. This patch fixes the breakage by* Removing
bdi_has_dirty_io()shortcut frombdi_split_work_to_wbs(). The callers are already testing the condition.* Removing
bdi_has_dirty_io()shortcut fromsync_inodes_sb()so that it always calls intobdi_split_work_to_wbs().
Quoted 7 lines
* Making
bdi_split_work_to_wbs()consider theb_dirty_timelist forWB_SYNC_ALLwritebacks.Signed-off-by Tejun Heo <[email protected]>Fixes e79729123f63 ("writeback: don't issue wb_writeback_work if clean")Cc Ted Ts'o <[email protected]>Cc Jan Kara <[email protected]>
So the patch looks good to me. But the fact that is fixes Eryu's problem means there is something fishy going on. Either inodes get wrongly attached to b_dirty_time list or bdi_has_dirty_io() somehow misbehaves only temporarily and we don't catch it with the debug patch.
Can we add a test to wb_has_dirty_io() to also check whether it matches bdi_has_dirty_io()? Since Eryu doesn't use lazytime (I assume, Eryu, please speak up if you do), we could also warn if b_dirty_time lists get non-empty. Hmm?
Honza
Quoted 58 lines
---
Hello,So, this fixes
I_DIRTY_TIMEsyncing problem for ext4 but AFAICS xfs doesn't even use the generic inode metadata writeback path, so this most likely won't do anything for the originally reported problem. I'll post another patch for debugging.Thanks.
fs/fs-writeback.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)fs/fs-writeback.c +9
-9@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && + (base_work->sync_mode ==WB_SYNC_NONE || +list_empty (&wb->b_dirty_time))) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;@@ -2275,8 +2275,8 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* bdi_has_dirty() ignores I_DIRTY_TIME but we can't, always kick wbs */ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 20 lines · Tejun Heo
Quoted 19 lines
e79729123f63("writeback: don't issuewb_writeback_workif clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and madesync_inodes_sb()skipI_DIRTY_TIMEinodes. This patch fixes the breakage by* Removing
bdi_has_dirty_io()shortcut frombdi_split_work_to_wbs(). The callers are already testing the condition.* Removing
bdi_has_dirty_io()shortcut fromsync_inodes_sb()so that it always calls intobdi_split_work_to_wbs().* Making
bdi_split_work_to_wbs()consider theb_dirty_timelist forWB_SYNC_ALLwritebacks.Signed-off-by Tejun Heo <[email protected]>Fixes e79729123f63 ("writeback: don't issue wb_writeback_work if clean")Cc Ted Ts'o <[email protected]>Cc Jan Kara <[email protected]>
Quoted 9 lines · Jan Kara
So the patch looks good to me. But the fact that is fixes Eryu's problem means there is something fishy going on. Either inodes get wrongly attached to
b_dirty_timelist orbdi_has_dirty_io()somehow misbehaves only temporarily and we don't catch it with the debug patch.Can we add a test to
wb_has_dirty_io()to also check whether it matchesbdi_has_dirty_io()? Since Eryu doesn't use lazytime (I assume, Eryu, please speak up if you do), we could also warn ifb_dirty_timelists get non-empty. Hmm?
Hi,
I had an unstable system when running latest Linus tree with Tejun's patch applied on top. Nothing fishy in the logs after rebooting without the patch, but remote access with ssh when patch applied did not work (as if /home partition could not be read). This system has / as ext4 and other partitions (including /home) as XFS. Trying to login on tty instead of X resulted in hang of X. I could reboot with sysrq, but can't do further tests at the moment.
Back to same tree without the patch resulted in normal system.
So just a heads up the patch doesn't seem OK in its current state.
Cheers
Damien
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Damien.
Quoted 11 lines · Damien Wyart
I had an unstable system when running latest Linus tree with Tejun's patch applied on top. Nothing fishy in the logs after rebooting without the patch, but remote access with ssh when patch applied did not work (as if /home partition could not be read). This system has / as ext4 and other partitions (including /home) as XFS. Trying to login on tty instead of X resulted in hang of X. I could reboot with sysrq, but can't do further tests at the moment.
Back to same tree without the patch resulted in normal system.
So just a heads up the patch doesn't seem OK in its current state.
Have you been able to reproduce the failure? That sounds like an unlikely failure mode for the patch.
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 10 lines
Quoted 10 lines
I had an unstable system when running latest Linus tree with Tejun's patch applied on top. Nothing fishy in the logs after rebooting without the patch, but remote access with ssh when patch applied did not work (as if /home partition could not be read). This system has / as ext4 and other partitions (including /home) as XFS. Trying to login on tty instead of X resulted in hang of X. I could reboot with sysrq, but can't do further tests at the moment.
Back to same tree without the patch resulted in normal system. So just a heads up the patch doesn't seem OK in its current state.
Hi Tejun,
Quoted 2 lines
Have you been able to reproduce the failure? That sounds like an unlikely failure mode for the patch.
Unfortunately (as it would be nice to understand what happened), no. I reapplied the patch on top of rc7 and could not reproduce the unstability after several reboots.
I will continue running with the patch and report if anything strange appears again...
Signature · 6 lines
Damien _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Jan KaraHello, Jan.
Quoted 2 lines · Jan Kara
So the patch looks good to me. But the fact that is fixes Eryu's problem means there is something fishy going on. Either inodes get wrongly attached
Seriously, it shouldn't affect size syncing or xfs but then again my understanding of xfs is severely limited.
Quoted 7 lines
to
b_dirty_timelist orbdi_has_dirty_io()somehow misbehaves only temporarily and we don't catch it with the debug patch.Can we add a test to
wb_has_dirty_io()to also check whether it matchesbdi_has_dirty_io()? Since Eryu doesn't use lazytime (I assume, Eryu, please speak up if you do), we could also warn ifb_dirty_timelists get non-empty. Hmm?
Sure, will prep a patch soon.
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerRe: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 8 lines · Tejun Heo
Hello, Jan.
Quoted 2 lines · Jan Kara
So the patch looks good to me. But the fact that is fixes Eryu's problem means there is something fishy going on. Either inodes get wrongly attached
Seriously, it shouldn't affect size syncing or xfs but then again my understanding of xfs is severely limited.
Well, i_size == 0 in XFS usually means that writeback didn't get to flushing delay allocated pages - inode size on disk gets increased only after the pages are written out in ->end_io callback. So at least this part makes some sense to me.
Honza
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 7 lines · Jan Kara
Quoted 6 lines · Tejun Heo
Hello, Jan.
Quoted 2 lines · Jan Kara
So the patch looks good to me. But the fact that is fixes Eryu's problem means there is something fishy going on. Either inodes get wrongly attached
Quoted 7 lines
Quoted 2 lines
Seriously, it shouldn't affect size syncing or xfs but then again my understanding of xfs is severely limited.
Well,
i_size== 0 in XFS usually means that writeback didn't get to flushing delay allocated pages - inode size on disk gets increased only after the pages are written out in ->end_io callback. So at least this part makes some sense to me.
Hmm... the only possibility I can think of is tot_write_bandwidth being zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.
Thanks.
Signature · 1 line
tejun
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello,
Quoted 4 lines · Tejun Heo
Hmm... the only possibility I can think of is
tot_write_bandwidthbeing zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.
So, I can now reproduce the bug (it takes a lot of trials but lowering the number of tested files helps quite a bit) and instrumented all the early exit paths w/o the fix patch. bdi_has_dirty_io() and wb_has_dirty_io() are never out of sync with the actual dirty / io lists even when the test 048 fails, so the bug at least is not caused by writeback skipping due to buggy bdi/wb_has_dirty_io() result. Whenever it skips, all the lists are actually empty (verified while holding list_lock).
One suspicion I have is that this could be a subtle timing issue which is being exposed by the new short-cut path. Anything which adds delay seems to make the issue go away. Dave, does anything ring a bell?
As for the proposed I_DIRTY_TIME fix, I think it'd be a good idea to merge it. It fixes a clear brekage regardless of this xfs issue.
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 17 lines · Tejun Heo
Hello,
Quoted 4 lines · Tejun Heo
Hmm... the only possibility I can think of is
tot_write_bandwidthbeing zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.So, I can now reproduce the bug (it takes a lot of trials but lowering the number of tested files helps quite a bit) and instrumented all the early exit paths w/o the fix patch.
bdi_has_dirty_io()andwb_has_dirty_io()are never out of sync with the actual dirty / io lists even when the test 048 fails, so the bug at least is not caused by writeback skipping due to buggy bdi/wb_has_dirty_io() result. Whenever it skips, all the lists are actually empty (verified while holdinglist_lock).
Quoted 3 lines
One suspicion I have is that this could be a subtle timing issue which is being exposed by the new short-cut path. Anything which adds delay seems to make the issue go away. Dave, does anything ring a bell?
No, it doesn't. The data writeback mechanisms XFS uses are all generic. It marks inodes I_DIRTY_PAGES and lets the generic code take care of everything else. Yes, we do delayed allocation during writeback, and we log the inode size updates during IO completion, so if inode sizes are not getting updated, then Occam's Razor suggests that writeback is not happening.
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint triggerxfs_file_buffered_write once per write syscallxfs_file_sync once per fsync per inodexfs_vm_writepage every ->writepage callxfs_setfilesize every IO completion that updates inode size
And it's probably best to also include all the writeback tracepoints, too, for context. That will tell you what inodes and what part of them are getting written back and when....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 29 lines · Dave Chinner
Quoted 17 lines · Tejun Heo
Hello,
Quoted 4 lines · Tejun Heo
Hmm... the only possibility I can think of is
tot_write_bandwidthbeing zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.So, I can now reproduce the bug (it takes a lot of trials but lowering the number of tested files helps quite a bit) and instrumented all the early exit paths w/o the fix patch.
bdi_has_dirty_io()andwb_has_dirty_io()are never out of sync with the actual dirty / io lists even when the test 048 fails, so the bug at least is not caused by writeback skipping due to buggy bdi/wb_has_dirty_io() result. Whenever it skips, all the lists are actually empty (verified while holdinglist_lock).Quoted 3 lines
One suspicion I have is that this could be a subtle timing issue which is being exposed by the new short-cut path. Anything which adds delay seems to make the issue go away. Dave, does anything ring a bell?
No, it doesn't. The data writeback mechanisms XFS uses are all generic. It marks inodes
I_DIRTY_PAGESand lets the generic code take care of everything else. Yes, we do delayed allocation during writeback, and we log the inode size updates during IO completion, so if inode sizes are not getting updated, then Occam's Razor suggests that writeback is not happening.
Quoted 7 lines
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint trigger
xfs_file_buffered_writeonce per write syscallxfs_file_synconce per fsync per inodexfs_vm_writepageevery ->writepage callxfs_setfilesizeevery IO completion that updates inode size
I gave the tracepoints a try, but my root fs is xfs so I got many noises. I'll try to install a new vm with ext4 as root fs. But I'm not sure if the new vm could reproduce the failure, will see.
BTW, I guess xfs_vm_writepage should be xfs_writepage, and xfs_file_sync should be xfs_file_fsync?
Thanks,
Eryu
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 38 lines · Eryu Guan
Quoted 29 lines · Dave Chinner
Quoted 17 lines · Tejun Heo
Hello,
Quoted 4 lines · Tejun Heo
Hmm... the only possibility I can think of is
tot_write_bandwidthbeing zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.So, I can now reproduce the bug (it takes a lot of trials but lowering the number of tested files helps quite a bit) and instrumented all the early exit paths w/o the fix patch.
bdi_has_dirty_io()andwb_has_dirty_io()are never out of sync with the actual dirty / io lists even when the test 048 fails, so the bug at least is not caused by writeback skipping due to buggy bdi/wb_has_dirty_io() result. Whenever it skips, all the lists are actually empty (verified while holdinglist_lock).Quoted 3 lines
One suspicion I have is that this could be a subtle timing issue which is being exposed by the new short-cut path. Anything which adds delay seems to make the issue go away. Dave, does anything ring a bell?
No, it doesn't. The data writeback mechanisms XFS uses are all generic. It marks inodes
I_DIRTY_PAGESand lets the generic code take care of everything else. Yes, we do delayed allocation during writeback, and we log the inode size updates during IO completion, so if inode sizes are not getting updated, then Occam's Razor suggests that writeback is not happening.Quoted 7 lines
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint trigger
xfs_file_buffered_writeonce per write syscallxfs_file_synconce per fsync per inodexfs_vm_writepageevery ->writepage callxfs_setfilesizeevery IO completion that updates inode size
Quoted 3 lines
I gave the tracepoints a try, but my root fs is xfs so I got many noises. I'll try to install a new vm with ext4 as root fs. But I'm not sure if the new vm could reproduce the failure, will see.
I installed a new vm with ext4 as root fs and got some trace info.
On the new vm, only generic/048 is reproducible, generic/049 always passes. And I can only reproduce generic/048 when xfs tracepoints are enabled, if writeback tracepoints are enabled too, I can no longer reproduce the failure.
All tests are done on 4.2-rc7 kernel.
This is the trace-cmd I'm using:
cd /mnt/ext4 trace-cmd record -e xfs_file_buffered_write \ -e xfs_file_fsync \ -e xfs_writepage \ -e xfs_setfilesize & pushd /path/to/xfstests ./check generic/048 popd kill -s 2 $! trace-cmd report >trace_report.txt
I attached three files:
1) xfs-trace-generic-048.txt.bz2 trace report result
2) xfs-trace-generic-048.diff generic/048 failure diff output, could know which files has incorrect size
3) xfs-trace-generic-048.metadump.bz2 metadump of SCRATCH_DEV, which contains the test files
If more info is needed please let me know.
Thanks,
Eryu
root/xfstests/results//generic/048.out.bad renamed from generic/048.out +8 -0
@@ -1 +1,9 @@ QA output created by 048 +file /mnt/testarea/scratch/982 has incorrect size - sync failed +file /mnt/testarea/scratch/983 has incorrect size - sync failed +file /mnt/testarea/scratch/984 has incorrect size - sync failed +file /mnt/testarea/scratch/985 has incorrect size - sync failed +file /mnt/testarea/scratch/987 has incorrect size - sync failed +file /mnt/testarea/scratch/989 has incorrect size - sync failed +file /mnt/testarea/scratch/991 has incorrect size - sync failed +file /mnt/testarea/scratch/993 has incorrect size - sync failed
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Eryu GuanQuoted 38 lines · Eryu Guan
Quoted 29 lines · Dave Chinner
Quoted 17 lines · Tejun Heo
Hello,
Quoted 4 lines · Tejun Heo
Hmm... the only possibility I can think of is
tot_write_bandwidthbeing zero when it shouldn't be. I've been staring at the code for a while now but nothing rings a bell. Time for another debug patch, I guess.So, I can now reproduce the bug (it takes a lot of trials but lowering the number of tested files helps quite a bit) and instrumented all the early exit paths w/o the fix patch.
bdi_has_dirty_io()andwb_has_dirty_io()are never out of sync with the actual dirty / io lists even when the test 048 fails, so the bug at least is not caused by writeback skipping due to buggy bdi/wb_has_dirty_io() result. Whenever it skips, all the lists are actually empty (verified while holdinglist_lock).Quoted 3 lines
One suspicion I have is that this could be a subtle timing issue which is being exposed by the new short-cut path. Anything which adds delay seems to make the issue go away. Dave, does anything ring a bell?
No, it doesn't. The data writeback mechanisms XFS uses are all generic. It marks inodes
I_DIRTY_PAGESand lets the generic code take care of everything else. Yes, we do delayed allocation during writeback, and we log the inode size updates during IO completion, so if inode sizes are not getting updated, then Occam's Razor suggests that writeback is not happening.Quoted 7 lines
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint trigger
xfs_file_buffered_writeonce per write syscallxfs_file_synconce per fsync per inodexfs_vm_writepageevery ->writepage callxfs_setfilesizeevery IO completion that updates inode size
Quoted 3 lines
I gave the tracepoints a try, but my root fs is xfs so I got many noises. I'll try to install a new vm with ext4 as root fs. But I'm not sure if the new vm could reproduce the failure, will see.
I installed a new vm with ext4 as root fs and got some trace info.
On the new vm, only generic/048 is reproducible, generic/049 always passes. And I can only reproduce generic/048 when xfs tracepoints are enabled, if writeback tracepoints are enabled too, I can no longer reproduce the failure.
All tests are done on 4.2-rc7 kernel.
This is the trace-cmd I'm using:
cd /mnt/ext4 trace-cmd record -e xfs_file_buffered_write \ -e xfs_file_fsync \ -e xfs_writepage \ -e xfs_setfilesize & pushd /path/to/xfstests ./check generic/048 popd kill -s 2 $! trace-cmd report >trace_report.txt
I attached three files:
1) xfs-trace-generic-048.txt.bz2[1] trace report result
2) xfs-trace-generic-048.diff generic/048 failure diff output, could know which files has incorrect size
3) xfs-trace-generic-048.metadump.bz2 metadump of SCRATCH_DEV, which contains the test files
If more info is needed please let me know.
Thanks,
Eryu
[1] attach this file in a following mail, to avoid xfs list 500k limit
root/xfstests/results//generic/048.out.bad renamed from generic/048.out +8 -0
@@ -1 +1,9 @@ QA output created by 048 +file /mnt/testarea/scratch/982 has incorrect size - sync failed +file /mnt/testarea/scratch/983 has incorrect size - sync failed +file /mnt/testarea/scratch/984 has incorrect size - sync failed +file /mnt/testarea/scratch/985 has incorrect size - sync failed +file /mnt/testarea/scratch/987 has incorrect size - sync failed +file /mnt/testarea/scratch/989 has incorrect size - sync failed +file /mnt/testarea/scratch/991 has incorrect size - sync failed +file /mnt/testarea/scratch/993 has incorrect size - sync failed
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 1 line · Eryu Guan
On Thu, Aug 20, 2015 at 02:12:24PM +0800, Eryu Guan wrote:
[snip]
Quoted 28 lines
I installed a new vm with ext4 as root fs and got some trace info.
On the new vm, only generic/048 is reproducible, generic/049 always passes. And I can only reproduce generic/048 when xfs tracepoints are enabled, if writeback tracepoints are enabled too, I can no longer reproduce the failure.
All tests are done on 4.2-rc7 kernel.
This is the trace-cmd I'm using:
cd /mnt/ext4 trace-cmd record -e xfs_file_buffered_write \ -e xfs_file_fsync \ -e xfs_writepage \ -e xfs_setfilesize & pushd /path/to/xfstests ./check generic/048 popd kill -s 2 $! trace-cmd report >trace_report.txtI attached three files:
1) xfs-trace-generic-048.txt.bz2[1] trace report result
2) xfs-trace-generic-048.diff generic/048 failure diff output, could know which files has incorrect size
3) xfs-trace-generic-048.metadump.bz2 metadump ofSCRATCH_DEV, which contains the test files
Quoted 6 lines
If more info is needed please let me know.
Thanks,
Eryu[1] attach this file in a following mail, to avoid xfs list 500k limit
Attached this file in this mail.
Eryu
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Eryu. Thanks a lot for the trace.
So, this is from the end of the trace from the failed test.
...
kworker/u8:1-1563 [002] 22016.987530: xfs_writepage: dev 253:6 ino 0xef64fe pgoff 0x9ff000 size 0xa00000 offset 0 length 0 delalloc 1 unwritten 0
kworker/2:1-49 [002] 22017.373595: xfs_setfilesize: dev 253:6 ino 0xef6504 isize 0xa00000 disize 0x0 offset 0x0 count 10481664...
Maybe I'm misunderstanding the code but all xfs_writepage() calls are from unbound workqueues - the writeback workers - while xfs_setfilesize() are from bound workqueues, so I wondered why that was and looked at the code and the setsize functions are run off of a separate work item which is queued from the end_bio callback and I can't tell who would be waiting for them. Dave, what am I missing?
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 7 lines · Tejun Heo
Hello, Eryu. Thanks a lot for the trace.
So, this is from the end of the trace from the failed test.
...
kworker/u8:1-1563 [002] 22016.987530: xfs_writepage: dev 253:6 ino 0xef64fe pgoff 0x9ff000 size 0xa00000 offset 0 length 0 delalloc 1 unwritten 0 kworker/2:1-49 [002] 22017.373595: xfs_setfilesize: dev 253:6 ino 0xef6504 isize 0xa00000 disize 0x0 offset 0x0 count 10481664
Quoted 8 lines
...
Maybe I'm misunderstanding the code but all
xfs_writepage()calls are from unbound workqueues - the writeback workers - whilexfs_setfilesize()are from bound workqueues, so I wondered why that was and looked at the code and the setsize functions are run off of a separate work item which is queued from theend_biocallback and I can't tell who would be waiting for them. Dave, what am I missing?
xfs_setfilesize runs transactions, so it can't be run from IO completion context as it needs to block (i.e. on log space or inode locks). It also can't block log IO completion, nor metadata Io completion, as only log IO completion can free log space, and the inode lock might be waiting on metadata buffer IO completion (e.g. during delayed allocation). Hence we have multiple IO completion workqueues to keep these things separated and deadlock free. i.e. they all get punted to a workqueue where they are then processed in a context that can block safely.
Quoted 1 line
kworker/u8:1-1563 [002] 22016.987530: xfs_writepage: dev 253:6 ino 0xef64fe pgoff 0x9ff000 size 0xa00000 offset 0 length 0 delalloc 1 unwritten 0
There will be one of these per page that is submitted to XFS. There won't be one per page, because XFS clusters writes itself. This trace is telling us that the page at offset 0x9ff000 was submitted, the in-memory size of the inode at this time is 0xa00000 (i.e. this is the last dirty page in memory) and that the it is a delayed allocation extent (i.e. hasn't been written before).
Quoted 1 line
kworker/2:1-49 [002] 22017.373595: xfs_setfilesize: dev 253:6 ino 0xef6504 isize 0xa00000 disize 0x0 offset 0x0 count 10481664
There will be one of these per IO completion that extents the inode size. This one tells us the in-memory inode size is 0xa00000, the current on-disk inode size is 0, and the IO being completed spans the offsets 0 to 10481664 (0x9ff000). Which means it does not include the page submitted by the above trace, and after the setsize transaction, isize=0xa00000 and disize=0x9ff000.
Note that these two traces are from different inodes - you need to match traces from "ino 0xef6504" with other traces from the same inode.
Also, note that the trace is not complete - there are many, many missing trace events in the output....
What is interesting from the trace is that all the file size updates have this pattern:
kworker/2:1-49 [002] 22017.377918: xfs_setfilesize: dev 253:6 ino 0xef64fd isize 0xa00000 disize 0x0 offset 0x0 count 10481664
kworker/2:1-49 [002] 22017.378438: xfs_setfilesize: dev 253:6 ino 0xef64fd isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096There are two IOs being done - one for everything but the last page, and one for the last page. This is either a result of the writeback context limiting the number of pages per writeback slice, or the page clustering that XFS does in xfs_vm_writepage() not quite getting everything right (maybe an off-by-one?).
However, this doesn't appear to be a contributing factor. The 9 files that have the wrong file size at the end of the test match up exactly with the last 9 writepage submissions and IO completions; they happen after all the IO completions occur for all the good files.
This implies that the sync is either not submitting all the inodes for IO correctly or it is not waiting for all the inodes it submitted to be marked clean. We really need the writeback control tracepoints in the output to determine exactly what the sync was doing when it submitted these last inodes for writeback....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Dave.
Quoted 7 lines · Dave Chinner
Quoted 6 lines
Maybe I'm misunderstanding the code but all
xfs_writepage()calls are from unbound workqueues - the writeback workers - whilexfs_setfilesize()are from bound workqueues, so I wondered why that was and looked at the code and the setsize functions are run off of a separate work item which is queued from theend_biocallback and I can't tell who would be waiting for them. Dave, what am I missing?
Quoted 9 lines
xfs_setfilesizeruns transactions, so it can't be run from IO completion context as it needs to block (i.e. on log space or inode locks). It also can't block log IO completion, nor metadata Io completion, as only log IO completion can free log space, and the inode lock might be waiting on metadata buffer IO completion (e.g. during delayed allocation). Hence we have multiple IO completion workqueues to keep these things separated and deadlock free. i.e. they all get punted to a workqueue where they are then processed in a context that can block safely.
I'm still a bit confused. What prevents the following from happening?
1. io completion of last dirty page of an inode and work item for xfs_setfilesize() is queued.
2. inode removed from dirty list.
3. __sync_filesystem() invokes sync_inodes_sb(). There are no dirty pages, so it finishes.
4. xfs_fs_sync_fs() is called which calls _xfs_log_force() but the work item from #1 hasn't run yet, so the size update isn't written out.
5. Crash.
Is it that _xfs_log_force() waits for the setfilesize transaction created during writepage?
Thanks.
Signature · 1 line
tejun
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 20 lines · Tejun Heo
Hello, Dave.
Quoted 7 lines · Dave Chinner
Quoted 6 lines
Maybe I'm misunderstanding the code but all
xfs_writepage()calls are from unbound workqueues - the writeback workers - whilexfs_setfilesize()are from bound workqueues, so I wondered why that was and looked at the code and the setsize functions are run off of a separate work item which is queued from theend_biocallback and I can't tell who would be waiting for them. Dave, what am I missing?Quoted 9 lines
xfs_setfilesizeruns transactions, so it can't be run from IO completion context as it needs to block (i.e. on log space or inode locks). It also can't block log IO completion, nor metadata Io completion, as only log IO completion can free log space, and the inode lock might be waiting on metadata buffer IO completion (e.g. during delayed allocation). Hence we have multiple IO completion workqueues to keep these things separated and deadlock free. i.e. they all get punted to a workqueue where they are then processed in a context that can block safely.
Quoted 6 lines
I'm still a bit confused. What prevents the following from happening?
1. io completion of last dirty page of an inode and work item for
xfs_setfilesize()is queued.2. inode removed from dirty list.
The inode has already been removed from the dirty list - that happens at inode writeback submission time, not IO completion.
Quoted 2 lines
3.
__sync_filesystem()invokessync_inodes_sb(). There are no dirty pages, so it finishes.
There are no dirty pages, but the pages aren't clean, either. i.e they are still under writeback. Hence we need to invoke wait_inodes_sb() to wait for writeback on all pages to complete before returning.
Quoted 3 lines
4.
xfs_fs_sync_fs()is called which calls_xfs_log_force()but the work item from #1 hasn't run yet, so the size update isn't written out.
The bug here is that wait_inodes_sb() has not been run, therefore ->syncfs is being run before IO completions have been processed and pages marked clean.
Quoted 4 lines
5. Crash.
Is it that
_xfs_log_force()waits for the setfilesize transaction created during writepage?
No, it's wait_inodes_sb() that does the waiting for data IO completion for sync.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Dave.
Quoted 9 lines · Dave Chinner
Quoted 6 lines
I'm still a bit confused. What prevents the following from happening?
1. io completion of last dirty page of an inode and work item for
xfs_setfilesize()is queued.2. inode removed from dirty list.
The inode has already been removed from the dirty list - that happens at inode writeback submission time, not IO completion.
Ah, yeah, right, somehow was thinking requeue_io() was being called from completion path. That's where I was confused.
Thanks.
Signature · 1 line
tejun
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Dave ChinnerQuoted 1 line · Dave Chinner
On Tue, Aug 18, 2015 at 12:54:39PM -0700, Tejun Heo wrote:
[snip]
Quoted 9 lines
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint trigger
xfs_file_buffered_writeonce per write syscallxfs_file_synconce per fsync per inodexfs_vm_writepageevery ->writepage callxfs_setfilesizeevery IO completion that updates inode size
Quoted 3 lines
And it's probably best to also include all the writeback tracepoints, too, for context. That will tell you what inodes and what part of them are getting written back and when....
I finally reproduced generic/048 with both xfs and writeback tracepoints enabled, please download the trace dat file and trace report file from
http://128.199.137.77/writeback/
Thanks,
Eryu
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 12 lines · Eryu Guan
Quoted 1 line · Dave Chinner
On Tue, Aug 18, 2015 at 12:54:39PM -0700, Tejun Heo wrote:
[snip]
Quoted 9 lines
I'd suggest looking at some of the XFS tracepoints during the test:
tracepoint trigger
xfs_file_buffered_writeonce per write syscallxfs_file_synconce per fsync per inodexfs_vm_writepageevery ->writepage callxfs_setfilesizeevery IO completion that updates inode size
Quoted 8 lines
Quoted 3 lines
And it's probably best to also include all the writeback tracepoints, too, for context. That will tell you what inodes and what part of them are getting written back and when....
I finally reproduced generic/048 with both xfs and writeback tracepoints enabled, please download the trace dat file and trace report file from
OK, so only one inode the wrong size this time. The writeback tracing is too verbose - it captures everything on the the backing device so there's a huge amount of noise in the trace, and I can't filter it easily because everything is recorded as "bdi 253:0" even though we only want traces from "dev 253:6".
As such, there are lots of missing events in the trace again. We do not need these writeback tracepoints:
writeback_mark_inode_dirty
writeback_dirty_inode_start
writeback_dirty_inode
writeback_dirty_page
writeback_write_inode
And they are the ones causing most of the noise. This brings the trace down from 7.1 million events to ~90,000 events and brings the test behaviour right into focus. The inode that had the short length:
kworker/u8:1-1563 [002] 71028.844716: writeback_single_inode_start: bdi 253:0: ino=15688963 state=I_DIRTY_SYNC|I_DIRTY_DATASYNC|I_DIRTY_PAGES|I_SYNC dirtied_when=4356811543 age=18446744069352740 index=0 to_write=34816 wrote=0
kworker/u8:1-1563 [002] 71028.844718: wbc_writepage: bdi 253:0: towrt=34816 skip=0 mode=0 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
kworker/u8:1-1563 [002] 71028.844740: xfs_writepage: dev 253:6 ino 0xef6503 pgoff 0x0 size 0xa00000 offset 0 length 0 delalloc 1 unwritten 0
kworker/u8:1-1563 [002] 71028.845740: wbc_writepage: bdi 253:0: towrt=32257 skip=0 mode=0 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
kworker/u8:1-1563 [002] 71028.845741: xfs_writepage: dev 253:6 ino 0xef6503 pgoff 0x9ff000 size 0xa00000 offset 0 length 0 delalloc 1 unwritten 0
kworker/u8:1-1563 [002] 71028.845788: writeback_single_inode: bdi 253:0: ino=15688963 state=I_SYNC dirtied_when=4356811543 age=18446744069352740 index=2559 to_write=34816 wrote=2560And so we can see that writeback pushed all 2560 pages of the file to disk.
However, because of all the noise, the xfs io completion events are missing for this inode. I know that at least one of them occurred, because their is this transaction in the log:
INODE: #regs: 3 ino: 0xef6503 flags: 0x5 dsize: 16
size 0x9ff000 nblocks 0xa00 extsize 0x0 nextents 0x1
It is, however, the last inode to be updated in the log before the unmount record, and it is the only one that does not have a size of 0xa00000 bytes. It has the right block count, but it it appears that we haven't captured the final IO completion transaction. It was most definitely not the last inode written by writeback; it was the 6th last, and that is ordered correctly given the file name was "993", the 6th last file created by the test.
However, I see completions for the inode written before (0xef6502) and after (0xef6504) but none for 0xef6503. Yet from the trace in the log we know that at least one of them occurred, because there's a transaction to say it happened.
As it is, there is an off-by-one in the page clustering mapping check in XFS that is causing the last page of the inode to be issued as a separate IO. That's not the cause of the problem however, because we can see from the trace that the IO for the entire file appears to be issued. What we don't see yet is what is happening on the IO completion side, and hence why the sync code is not waiting correctly for all the IO that was issued to be waited on properly.
Eryu, can you try again, this time manually specifying the writeback tracepoints so you exclude the really noisy ones? You can also drop the xfs_file_buffered_write and xfs_file_fsync tracepoints as well, as we can see that the incoming side of the code is doing the right thing....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 1 line · Dave Chinner
On Fri, Aug 21, 2015 at 06:20:53PM +0800, Eryu Guan wrote:
[snip]
Quoted 6 lines
Eryu, can you try again, this time manually specifying the writeback tracepoints so you exclude the really noisy ones? You can also drop the
xfs_file_buffered_writeandxfs_file_fsynctracepoints as well, as we can see that the incoming side of the code is doing the right thing....
I excluded the writeback tracepoints you mentioned
writeback_mark_inode_dirtywriteback_dirty_inode_startwriteback_dirty_inodewriteback_dirty_pagewriteback_write_inode
and left all other writeback tracepoints enabled, also dropped xfs_file_buffered_write and xfs_file_fsync.
This time I can reproduce generic/048 quickly and please download the trace info from below
http://128.199.137.77/writeback-v2/
Thanks,
Eryu
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 18 lines · Eryu Guan
Quoted 1 line · Dave Chinner
On Fri, Aug 21, 2015 at 06:20:53PM +0800, Eryu Guan wrote:
[snip]
Quoted 6 lines
Eryu, can you try again, this time manually specifying the writeback tracepoints so you exclude the really noisy ones? You can also drop the
xfs_file_buffered_writeandxfs_file_fsynctracepoints as well, as we can see that the incoming side of the code is doing the right thing....I excluded the writeback tracepoints you mentioned
writeback_mark_inode_dirtywriteback_dirty_inode_startwriteback_dirty_inodewriteback_dirty_pagewriteback_write_inode
Quoted 7 lines
and left all other writeback tracepoints enabled, also dropped
xfs_file_buffered_writeandxfs_file_fsync.This time I can reproduce generic/048 quickly and please download the trace info from below
ok:
$ ls -li /mnt/scr total 102396 15688948 -rw------- 1 root root 0 Aug 22 14:31 978 15688950 -rw------- 1 root root 0 Aug 22 14:31 980 15688952 -rw------- 1 root root 10481664 Aug 22 14:31 982 15688957 -rw------- 1 root root 0 Aug 22 14:31 987 15688961 -rw------- 1 root root 0 Aug 22 14:31 991 15688963 -rw------- 1 root root 0 Aug 22 14:31 993 15688964 -rw------- 1 root root 0 Aug 22 14:31 994 15688966 -rw------- 1 root root 0 Aug 22 14:31 996 15688967 -rw------- 1 root root 0 Aug 22 14:31 997 15688968 -rw------- 1 root root 0 Aug 22 14:31 998 $
So, looking at what is on disk and what is in the log:
Inode # Size block count flushiter
dec hex inode log inode log inode log
15688948 0xef64f4 0 0 0xa00 0xa00 0 0 15688950 0xef64f6 0 0 0xa00 0xa00 0 0 15688952 0xef64f8 0x9ff000 0x9ff000 0x9ff 0xa00 1 0 15688957 0xef64fd 0 0 0xa00 0xa00 0 0 15688961 0xef6501 0 0 0xa00 0xa00 0 0 15688963 0xef6503 0 0 0xa00 0xa00 0 0 15688964 0xef6504 0 0 0xa00 0xa00 0 0 15688966 0xef6506 0 0 0xa00 0xa00 0 0 15688967 0xef6507 0 0 0xa00 0xa00 0 0 15688968 0xef6508 0 0 0xa00 0xa00 0 0
Now, inode #15688952 looks like there's some weirdness going on there with a non-zero flushiter and a block count that doesn't match between what is in the log and what is on disk. However, this is a result of the second mount that checks the file sizes and extent counts - it loads the inode into memory, checks it, and then when it is purged from the cache on unmount the blocks beyond EOF are punched away and the inode writen to disk. Hence there is a second transaction in the log for that inode after all the other inodes have been unlinked:
INODE: #regs: 3 ino: 0xef64f8 flags: 0x5 dsize: 16
.....
size 0x9ff000 nblocks 0x9ff extsize 0x0 nextents 0x1
It is preceeded in the log by modifications to the AGF and frees space btree buffers. It's then followed by the superblock buffer and the unmount record. Hence this is not unexpected.
What it does tell us, though, is that the log never recorded file size changes for all of the inode with zero size. We see the block count of 0xa00, which means the delayed allocation transaction during IO submission has hit the disk, but there are none of the IO completion transactions in the log.
So let's go look at the event trace now now that we know the EOF size update transactions were not run before the filesystem shut down.
Inode # writeback completion
hex first last first last
0xef64f4 0-0x9ff000 yes no no 0xef64f6 0-0x9ff000 yes no no 0xef64f8 0-0x9ff000 yes no no 0xef64fd 0-0x9ff000 yes no no 0xef6501 0-0x9ff000 yes no no 0xef6503 no no no no 0xef6504 no no no no 0xef6506 no no no no 0xef6507 no no no no 0xef6508 no no no no
Ok, so we still can't trust the event trace to be complete - we know from the log and the on-disk state that that allocation occurred for those last 5 inodes, so we can't read anything into the fact the traces for completions are missing.
Eryu, can you change the way you run the event trace to be:
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>
rather than running the trace as a background operation elsewhere? Maybe that will give better results.
Also, it would be informative to us if you can reproduce this with a v5 filesystem (i.e. mkfs.xfs -m crc=1) because it has much better on-disk information for sequence-of-event triage like this. If you can reproduce it with a v5 filesystem, can you post the trace and metadump?
Other things to check (separately):
- change godown to godown -f
- add a "sleep 5" before running godown after sync
- add a "sleep 5; sync" before running godown
i.e. I'm wondering if sync is not waiting for everything, and so we aren't capturing the IO completions because the filesystem is already shut down by the time they are delivered...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 7 lines · Dave Chinner
Eryu, can you change the way you run the event trace to be:
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>rather than running the trace as a background operation elsewhere? Maybe that will give better results.
The results are here
http://128.199.137.77/writeback-v3/
Quoted 6 lines
Also, it would be informative to us if you can reproduce this with a v5 filesystem (i.e. mkfs.xfs -m crc=1) because it has much better on-disk information for sequence-of-event triage like this. If you can reproduce it with a v5 filesystem, can you post the trace and metadump?
This seems to be harder to reproduce with tracepoints enabled, but I'll keep trying, and the tests below.
Thanks,
Eryu
Quoted 7 lines
Other things to check (separately):
- change godown to godown -f
- add a "sleep 5" before running godown after sync
- add a "sleep 5; sync" before running godown
Quoted 15 lines
i.e. I'm wondering if sync is not waiting for everything, and so we aren't capturing the IO completions because the filesystem is already shut down by the time they are delivered...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 4 lines · Eryu Guan
Quoted 3 lines · Dave Chinner
Eryu, can you change the way you run the event trace to be:
Quoted 8 lines
Quoted 4 lines
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>rather than running the trace as a background operation elsewhere? Maybe that will give better results.
The results are here
OK, the trace is still missing a few events, but it's much more complete, and contains the events that tell more of the story:
$ ls -li /mnt/scr total 51196 15688955 -rw------- 1 root root 10481664 Aug 24 13:06 985 15688959 -rw------- 1 root root 0 Aug 24 13:06 989 15688961 -rw------- 1 root root 0 Aug 24 13:06 991 15688964 -rw------- 1 root root 0 Aug 24 13:06 994 15688966 -rw------- 1 root root 0 Aug 24 13:06 996 $
Inode # Size block count flushiter
dec hex inode log inode log inode log
15688955 0xef64fb 0x9ff000 0x9ff000 0x9ff 0xa00 1 0 15688959 0xef64ff 0 0 0xa00 0xa00 0 0 15688961 0xef6501 0 0 0xa00 0xa00 0 0 15688964 0xef6504 0 0 0xa00 0xa00 0 0 15688966 0xef6506 0 0 0xa00 0xa00 0 0
Ok, that tallies with the previous symptoms. However, the trace tells us something different. the xfs_setfilesize events. here's the last 12 xfs_setfilesize events delivered in the trace (trimmed for brevity and focus):
ino 0xef64fa isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef64fa isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 409 ino 0xef64fb isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef64fb isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096 ino 0xef64ff isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef64ff isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096 ino 0xef6501 isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef6501 isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096 ino 0xef6504 isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef6504 isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096 ino 0xef6506 isize 0xa00000 disize 0x0 offset 0x0 count 10481664 ino 0xef6506 isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096
Yeah, the last 9 transactions corresponding to these events are not in the log. Which means, most likely, that they occurred after ->sync_fs forced the log out. THe next thing that happens is the fs is shut down, and that's preventing the dirty log from being written to disk.
Eryu, this can be confirmed by add the xfs_log_force event to the trace.
What I can't see in the traces is where sync is doing a blocking sync pass on the fileystem. The wbc control structure being passed to XFS is:
wbc_writepage: bdi 253:0: towrt=45569 skip=0 mode=0 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
Which is not coming from sync_inodes_sb() as the sync mode is incorrect (i.e. not WB_SYNC_ALL). It looks to me that writeback is coming from a generic bdi flusher command rather than a directed superblock sync. i.e. through wakeup_flusher_threads() which sets:
work->sync_mode = WB_SYNC_NONE;
work->nr_pages = nr_pages;
work->range_cyclic = range_cyclic;
work->reason = reason;
work->auto_free = 1;as the reason is "sync":
sync-18849 writeback_queue: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync
sync-18849 writeback_queue: bdi 253:0: sb_dev 253:1 nr_pages=9223372036854775807 sync_mode=1 kupdate=0 range_cyclic=0 background=0 reason=sync
....
kworker/u8:1-1563 writeback_exec: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync
kworker/u8:1-1563 writeback_start: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=syncThe next writeback_queue/writeback_exec tracepoint pair are:
....
kworker/2:1-17163 xfs_setfilesize: dev 253:6 ino 0xef6506 isize 0xa00000 disize 0x0 offset 0x0 count 10481664
kworker/2:1-17163 xfs_setfilesize: dev 253:6 ino 0xef6506 isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096
sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775798 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775797 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775796 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775795 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff
umount-18852 writeback_queue: bdi 253:0: sb_dev 253:6 nr_pages=22059 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync
kworker/u8:1-1563 writeback_exec: bdi 253:0: sb_dev 253:6 nr_pages=22059 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync....
which shows unmount being the next writeback event queued and executed after the IO completions have come in (that missed the log). What is missing is the specific queue/exec events for sync_sb_inodes() from the sync code for each filesystem.
Anyway, Eryum long and short of it is that you don't need to worry about testing all the different combinations - we now know that the completion events are occurring, so let's focus on whether the sync code is not waiting for them correctly. Can you trace the following events:
xfs_log_force
xfs_setfilesize
writeback_queue
writeback_exec
writeback_start
writeback_queue_io
writeback_written
writeback_pages_written
basically I'm trying to see if we've got all the BDI events as we'd expect then to be queued and run for sync, and when the ->sync_fs call occurs during the sync process before shutdown and unmount...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 9 lines · Dave Chinner
Quoted 8 lines · Eryu Guan
Quoted 7 lines · Dave Chinner
Eryu, can you change the way you run the event trace to be:
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>rather than running the trace as a background operation elsewhere? Maybe that will give better results.
[snip]
Quoted 15 lines
Anyway, Eryum long and short of it is that you don't need to worry about testing all the different combinations - we now know that the completion events are occurring, so let's focus on whether the sync code is not waiting for them correctly. Can you trace the following events:
xfs_log_force
xfs_setfilesize
writeback_queue
writeback_exec
writeback_start
writeback_queue_io
writeback_written
writeback_pages_written
Quoted 3 lines
basically I'm trying to see if we've got all the BDI events as we'd expect then to be queued and run for sync, and when the ->sync_fs call occurs during the sync process before shutdown and unmount...
I collected two versions of trace info with crc enabled.
http://128.199.137.77/writeback-crc/
This version traced the same events as previous runs.
http://128.199.137.77/writeback-crc-v2/
And this version only traced the events you listed above.
And the results of other tests to check(all done with v4 xfs, with no tracepoints enabled):
Quoted 2 lines
Other things to check (separately):
- change godown to godown -f
Passed 100 loops.
Quoted 1 line
- add a "sleep 5" before running godown after sync
Failed, if you need the trace info please let me know.
Quoted 1 line
- add a "sleep 5; sync" before running godown
Passed 100 loops.
Thanks,
Eryu
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 32 lines · Eryu Guan
Quoted 9 lines · Dave Chinner
Quoted 8 lines · Eryu Guan
Quoted 7 lines · Dave Chinner
Eryu, can you change the way you run the event trace to be:
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>rather than running the trace as a background operation elsewhere? Maybe that will give better results.
[snip]
Quoted 15 lines
Anyway, Eryum long and short of it is that you don't need to worry about testing all the different combinations - we now know that the completion events are occurring, so let's focus on whether the sync code is not waiting for them correctly. Can you trace the following events:
xfs_log_force
xfs_setfilesize
writeback_queue
writeback_exec
writeback_start
writeback_queue_io
writeback_written
writeback_pages_writtenQuoted 3 lines
basically I'm trying to see if we've got all the BDI events as we'd expect then to be queued and run for sync, and when the ->sync_fs call occurs during the sync process before shutdown and unmount...
I collected two versions of trace info with crc enabled.
Quoted 7 lines
http://128.199.137.77/writeback-crc/
This version traced the same events as previous runs.
http://128.199.137.77/writeback-crc-v2/
And this version only traced the events you listed above.
OK, I'll look into these later.
Quoted 7 lines
And the results of other tests to
check(all done with v4 xfs, with no tracepoints enabled):Quoted 2 lines
Other things to check (separately):
- change godown to godown -fPassed 100 loops.
Yup, I expected that from the last set of traces - the "-f" flag triggers a log force before shutdown, and that flushes out transactions that sync missed.
Quoted 3 lines
Quoted 1 line
- add a "sleep 5" before running godown after sync
Failed, if you need the trace info please let me know.
Expected, still nothing to flush transactions before shutdown.
Quoted 3 lines
Quoted 1 line
- add a "sleep 5; sync" before running godown
Passed 100 loops.
expected - sync flushed the transactions it missed on the first pass.
Thanks for running these tests!
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerRe: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Dave ChinnerQuoted 13 lines · Dave Chinner
Quoted 12 lines · Eryu Guan
Quoted 7 lines · Dave Chinner
Eryu, can you change the way you run the event trace to be:
$ sudo trace-cmd <options> -o <outfile location> ./check <test options>rather than running the trace as a background operation elsewhere? Maybe that will give better results.
The results are here
<snip>
Quoted 36 lines
What I can't see in the traces is where sync is doing a blocking sync pass on the fileystem. The wbc control structure being passed to XFS is:
wbc_writepage: bdi 253:0: towrt=45569 skip=0 mode=0 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffffWhich is not coming from
sync_inodes_sb()as the sync mode is incorrect (i.e. notWB_SYNC_ALL). It looks to me that writeback is coming from a generic bdi flusher command rather than a directed superblock sync. i.e. throughwakeup_flusher_threads()which sets:work->sync_mode = WB_SYNC_NONE; work->nr_pages = nr_pages; work->range_cyclic = range_cyclic; work->reason = reason; work->auto_free = 1;as the reason is "sync":
sync-18849 writeback_queue: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync sync-18849 writeback_queue: bdi 253:0: sb_dev 253:1 nr_pages=9223372036854775807 sync_mode=1 kupdate=0 range_cyclic=0 background=0 reason=sync .... kworker/u8:1-1563 writeback_exec: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync kworker/u8:1-1563 writeback_start: bdi 253:0: sb_dev 0:0 nr_pages=308986 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=syncThe next writeback_queue/writeback_exec tracepoint pair are:
....
kworker/2:1-17163 xfs_setfilesize: dev 253:6 ino 0xef6506 isize 0xa00000 disize 0x0 offset 0x0 count 10481664 kworker/2:1-17163 xfs_setfilesize: dev 253:6 ino 0xef6506 isize 0xa00000 disize 0x9ff000 offset 0x9ff000 count 4096 sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775798 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775797 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775796 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff sync-18849 wbc_writepage: bdi 253:0: towrt=9223372036854775795 skip=0 mode=1 kupd=0 bgrd=0 reclm=0 cyclic=0 start=0x0 end=0x7fffffffffffffff umount-18852 writeback_queue: bdi 253:0: sb_dev 253:6 nr_pages=22059 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync kworker/u8:1-1563 writeback_exec: bdi 253:0: sb_dev 253:6 nr_pages=22059 sync_mode=0 kupdate=0 range_cyclic=0 background=0 reason=sync
Quoted 6 lines
....
which shows unmount being the next writeback event queued and executed after the IO completions have come in (that missed the log). What is missing is the specific queue/exec events for
sync_sb_inodes()from the sync code for each filesystem.
Bah, I see the problem and indeed it was introduced by commit e79729123f639 "writeback: don't issue wb_writeback_work if clean". The problem is that we bail out of sync_inodes_sb() if there is no dirty IO. Which is wrong because we have to wait for any outstanding IO (i.e. call wait_sb_inodes()) regardless of dirty state! And that also explains why Tejun's patch fixes the problem because it backs out the change to the exit condition in sync_inodes_sb().
So Tejun's patch from this thread is indeed fixing the real problem but the comment in sync_inodes_sb() should be fixed to mention wait_sb_inodes() must be called in all cases... Tejun, will you fixup the comment please?
Honza
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Jan.
Quoted 5 lines · Jan Kara
Quoted 4 lines
which shows unmount being the next writeback event queued and executed after the IO completions have come in (that missed the log). What is missing is the specific queue/exec events for
sync_sb_inodes()from the sync code for each filesystem.
Quoted 7 lines
Bah, I see the problem and indeed it was introduced by commit
e79729123f639"writeback: don't issuewb_writeback_workif clean". The problem is that we bail out ofsync_inodes_sb()if there is no dirty IO. Which is wrong because we have to wait for any outstanding IO (i.e. callwait_sb_inodes()) regardless of dirty state! And that also explains why Tejun's patch fixes the problem because it backs out the change to the exit condition insync_inodes_sb().
Dang, I'm an idiot sandwich.
Quoted 3 lines
So Tejun's patch from this thread is indeed fixing the real problem but the comment in
sync_inodes_sb()should be fixed to mentionwait_sb_inodes()must be called in all cases... Tejun, will you fixup the comment please?
Will post an updated patch. Kudos to Eryu and Dave for chasing it down.
Thanks a lot.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello,
Quoted 9 lines · Tejun Heo
Quoted 7 lines
Bah, I see the problem and indeed it was introduced by commit
e79729123f639"writeback: don't issuewb_writeback_workif clean". The problem is that we bail out ofsync_inodes_sb()if there is no dirty IO. Which is wrong because we have to wait for any outstanding IO (i.e. callwait_sb_inodes()) regardless of dirty state! And that also explains why Tejun's patch fixes the problem because it backs out the change to the exit condition insync_inodes_sb().Dang, I'm an idiot sandwich.
A question tho, so this means that an inode may contain dirty or writeback pages w/o the inode being on one of the dirty lists. Looking at the generic filesystem and writeback code, this doesn't seem true in general. Is this something xfs specific?
Thanks.
Signature · 1 line
tejun
Jan Kara
reviewerRe: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 11 lines · Tejun Heo
Hello,
Quoted 8 lines · Tejun Heo
Quoted 7 lines
Bah, I see the problem and indeed it was introduced by commit
e79729123f639"writeback: don't issuewb_writeback_workif clean". The problem is that we bail out ofsync_inodes_sb()if there is no dirty IO. Which is wrong because we have to wait for any outstanding IO (i.e. callwait_sb_inodes()) regardless of dirty state! And that also explains why Tejun's patch fixes the problem because it backs out the change to the exit condition insync_inodes_sb().
Quoted 6 lines
Quoted 1 line
Dang, I'm an idiot sandwich.
A question tho, so this means that an inode may contain dirty or writeback pages w/o the inode being on one of the dirty lists. Looking at the generic filesystem and writeback code, this doesn't seem true in general. Is this something xfs specific?
Inode may contain writeback pages (but not dirty pages) without being on any of the dirty lists. That is correct. Josef Bacik had patches to create a list to track inodes with pages under writeback but they clashed with your patch series and they didn't get rebased yet AFAIR.
Honza
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello, Jan.
Quoted 2 lines · Jan Kara
Inode may contain writeback pages (but not dirty pages) without being on any of the dirty lists. That is correct. Josef Bacik had patches to create
Hmmm... Can you please expand on how / why that happens? It's kinda weird to require writeback to walk all inodes regardless of their dirty states.
Quoted 2 lines
a list to track inodes with pages under writeback but they clashed with your patch series and they didn't get rebased yet AFAIR.
Wouldn't it make more sense to simply put them on one of the existing b_* lists?
Thanks.
Signature · 1 line
tejun
Jan Kara
reviewerRe: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Quoted 9 lines · Tejun Heo
Hello, Jan.
Quoted 2 lines · Jan Kara
Inode may contain writeback pages (but not dirty pages) without being on any of the dirty lists. That is correct. Josef Bacik had patches to create
Hmmm... Can you please expand on how / why that happens? It's kinda weird to require writeback to walk all inodes regardless of their dirty states.
It is inefficient, yes. But note that 'writeback' and 'dirty' states are completely independent. Page can be in any of the !dirty & !writeback, dirty & !writeback, !dirty & writeback, dirty & writeback states. So mixing tracking of writeback and dirty state of an inode just makes the code even messier.
Quoted 5 lines
Quoted 2 lines
a list to track inodes with pages under writeback but they clashed with your patch series and they didn't get rebased yet AFAIR.
Wouldn't it make more sense to simply put them on one of the existing b_* lists?
Logically it just doesn't make sense because as I wrote above dirty and writeback states are completely independent. Also you'd have to detect & skip inodes that don't really have any dirty pages to write and all the detection of "is there any data to write" would get more complicated. A separate list for inodes under writeback as Josef did is IMO the cleanest solution.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello,
Quoted 2 lines · Jan Kara
It is inefficient, yes. But note that 'writeback' and 'dirty' states are completely independent. Page can be in any of the !dirty & !writeback,
That isn't true for pages being dirtied through set_page_dirty(). It's guaranteed that a dirty inode remains on one of the b_* lists till there's no dirty page and writeback is complete.
Quoted 3 lines
dirty & !writeback, !dirty & writeback, dirty & writeback states. So mixing tracking of writeback and dirty state of an inode just makes the code even messier.
I'm curious where and why they would deviate. Can you give me some examples? AFAICS, anything which uses the usual set_page_dirty() path shouldn't do that.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
a list to track inodes with pages under writeback but they clashed with your patch series and they didn't get rebased yet AFAIR.
Wouldn't it make more sense to simply put them on one of the existing b_* lists?
Quoted 6 lines
Logically it just doesn't make sense because as I wrote above dirty and writeback states are completely independent. Also you'd have to detect & skip inodes that don't really have any dirty pages to write and all the detection of "is there any data to write" would get more complicated. A separate list for inodes under writeback as Josef did is IMO the cleanest solution.
Given that the usual code path tracks dirty and writeback together, I don't think it's nonsensical; however, I'm more curious how common writeback w/o dirtying case is.
Thanks.
Signature · 1 line
tejun
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
Hello,
Quoted 3 lines · Tejun Heo
That isn't true for pages being dirtied through
set_page_dirty(). It's guaranteed that a dirty inode remains on one of the b_* lists till there's no dirty page and writeback is complete.
I got confused here. inodes get removed from b_* once all IOs are issued.
Thanks.
Signature · 6 lines
tejun _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH block/for-linus] writeback: fix syncing of I_DIRTY_TIME inodes
In reply to Tejun HeoQuoted 9 lines · Tejun Heo
Hello,
Quoted 2 lines · Jan Kara
It is inefficient, yes. But note that 'writeback' and 'dirty' states are completely independent. Page can be in any of the !dirty & !writeback,
That isn't true for pages being dirtied through
set_page_dirty(). It's guaranteed that a dirty inode remains on one of the b_* lists till there's no dirty page and writeback is complete.
IO submission calls clear_page_dirty_for_io(), so by the time that all the pages have been submitted for IO, there are no dirty pages. IO submission also calls set_page_writeback() once the filesystem has decided to do IO on the page, and then IO completion calls end_page_writeback() to clear that state.
IOWs, the page transitions from (dirty && !writeback) before submission to (!dirty && writeback) after submission, and to (!dirty && !writeback) once IO completion occurs.
And you'll note that filemap_fdatawait() blocks on pages with the PAGECACHE_TAG_WRITEBACK tag set in the mapping tree, not dirty pages. Hence sync has to wait for all pages to transition out of writeback before we can consider the inode to be clean.
Quoted 7 lines
Quoted 3 lines
dirty & !writeback, !dirty & writeback, dirty & writeback states. So mixing tracking of writeback and dirty state of an inode just makes the code even messier.
I'm curious where and why they would deviate. Can you give me some examples? AFAICS, anything which uses the usual
set_page_dirty()path shouldn't do that.
mmaped files.
page_mkwrite dirties page (dirty && !writeback)
writepage clear_page_dirty_for_io (!dirty && !writeback)
writepage starts writeback (!dirty && writeback)page_mkwrite dirties page (dirty && writeback)
io completes (dirty && !writeback)
This is done so we don't lose dirty state from page faults whilst the page is under IO and hence have sync miss the page next time through....
Of course, this behaviour is different if you have a filesystem or block device that requires stable pages (e.g. btrfs for data CRC validity). In this case, the page fault will block until the writeback state goes away...
Quoted 13 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
a list to track inodes with pages under writeback but they clashed with your patch series and they didn't get rebased yet AFAIR.
Wouldn't it make more sense to simply put them on one of the existing b_* lists?
Quoted 6 lines
Logically it just doesn't make sense because as I wrote above dirty and writeback states are completely independent. Also you'd have to detect & skip inodes that don't really have any dirty pages to write and all the detection of "is there any data to write" would get more complicated. A separate list for inodes under writeback as Josef did is IMO the cleanest solution.
Quoted 3 lines
Given that the usual code path tracks dirty and writeback together, I don't think it's nonsensical; however, I'm more curious how common writeback w/o dirtying case is.
I suspect you've misunderstood the progression here. You can't get writeback without first going through dirty. But the transition to writeback clears the dirty page state so that we can capture page state changes while writeback is in progress.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 writeback: sync_inodes_sb() must write out I_DIRTY_TIME inodes and always call wait_sb_inodes()
In reply to Tejun Heoe79729123f63 ("writeback: don't issue wb_writeback_work if clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and broke sync_inodes_sb().
* sync_inodes_sb() must write out I_DIRTY_TIME inodes but I_DIRTY_TIME inodes dont't contribute to bdi/wb_has_dirty_io() tests and were being skipped over.
* inodes are taken off wb->b_dirty/io/more_io lists after writeback starts on them. sync_inodes_sb() skipping wait_sb_inodes() when bdi_has_dirty_io() breaks it by making it return while writebacks are in-flight.
This patch fixes the breakages by
* Removing bdi_has_dirty_io() shortcut from bdi_split_work_to_wbs(). The callers are already testing the condition.
* Removing bdi_has_dirty_io() shortcut from sync_inodes_sb() so that it always calls into bdi_split_work_to_wbs() and wait_sb_inodes().
* Making bdi_split_work_to_wbs() consider the b_dirty_time list for WB_SYNC_ALL writebacks.
Kudos to Eryu, Dave and Jan for tracking down the issue.
--- fs/fs-writeback.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
fs/fs-writeback.c +13 -9
@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && + (base_work->sync_mode ==WB_SYNC_NONE || +list_empty (&wb->b_dirty_time))) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);
@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;
@@ -2275,8 +2275,12 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* +* Can't skip on !bdi_has_dirty() because we should wait for !dirty +* inodes under writeback and I_DIRTY_TIME inodes ignored by +* bdi_has_dirty() need to be written out too. +*/ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 block/for-linus] writeback: sync_inodes_sb() must write out I_DIRTY_TIME inodes and always call wait_sb_inodes()
Quoted 27 lines · Tejun Heo
e79729123f63("writeback: don't issuewb_writeback_workif clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and brokesync_inodes_sb().*
sync_inodes_sb()must write outI_DIRTY_TIMEinodes butI_DIRTY_TIMEinodes dont't contribute to bdi/wb_has_dirty_io() tests and were being skipped over.* inodes are taken off wb->b_dirty/io/more_io lists after writeback starts on them.
sync_inodes_sb()skippingwait_sb_inodes()whenbdi_has_dirty_io()breaks it by making it return while writebacks are in-flight.This patch fixes the breakages by
* Removing
bdi_has_dirty_io()shortcut frombdi_split_work_to_wbs(). The callers are already testing the condition.* Removing
bdi_has_dirty_io()shortcut fromsync_inodes_sb()so that it always calls intobdi_split_work_to_wbs()andwait_sb_inodes().* Making
bdi_split_work_to_wbs()consider theb_dirty_timelist forWB_SYNC_ALLwritebacks.Kudos to Eryu, Dave and Jan for tracking down the issue.
Quoted 7 lines
Signed-off-by Tejun Heo <[email protected]>Fixes e79729123f63 ("writeback: don't issue wb_writeback_work if clean")Reported-and-bisected-by Eryu Guan <[email protected]>Cc Dave Chinner <[email protected]>Cc Jan Kara <[email protected]>Cc Ted Ts'o <[email protected]>
Added for 4.2.
Signature · 6 lines
Jens Axboe _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 block/for-linus] writeback: sync_inodes_sb() must write out I_DIRTY_TIME inodes and always call wait_sb_inodes()
In reply to Tejun HeoQuoted 34 lines · Tejun Heo
e79729123f63("writeback: don't issuewb_writeback_workif clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and brokesync_inodes_sb().*
sync_inodes_sb()must write outI_DIRTY_TIMEinodes butI_DIRTY_TIMEinodes dont't contribute to bdi/wb_has_dirty_io() tests and were being skipped over.* inodes are taken off wb->b_dirty/io/more_io lists after writeback starts on them.
sync_inodes_sb()skippingwait_sb_inodes()whenbdi_has_dirty_io()breaks it by making it return while writebacks are in-flight.This patch fixes the breakages by
* Removing
bdi_has_dirty_io()shortcut frombdi_split_work_to_wbs(). The callers are already testing the condition.* Removing
bdi_has_dirty_io()shortcut fromsync_inodes_sb()so that it always calls intobdi_split_work_to_wbs()andwait_sb_inodes().* Making
bdi_split_work_to_wbs()consider theb_dirty_timelist forWB_SYNC_ALLwritebacks.Kudos to Eryu, Dave and Jan for tracking down the issue.
Signed-off-by Tejun Heo <[email protected]>Fixes e79729123f63 ("writeback: don't issue wb_writeback_work if clean")Reported-and-bisected-by Eryu Guan <[email protected]>Cc Dave Chinner <[email protected]>Cc Jan Kara <[email protected]>Cc Ted Ts'o <[email protected]>
Quoted 3 lines
--- fs/fs-writeback.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
The patch looks good. You can add:
Honza
Quoted 50 lines
fs/fs-writeback.c +13
-9@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && + (base_work->sync_mode ==WB_SYNC_NONE || +list_empty (&wb->b_dirty_time))) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;@@ -2275,8 +2275,12 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* +* Can't skip on !bdi_has_dirty() because we should wait for !dirty +* inodes under writeback and I_DIRTY_TIME inodes ignored by +* bdi_has_dirty() need to be written out too. +*/ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
In reply to Dave ChinnerHello, Eryu.
Can you please do the followings?
1. See if the "writeback: fix syncing of I_DIRTY_TIME inodes" patch changes anything.
2. If not, apply this patch. This patch *should* make the failures go away and might print out some error messages along with stack trace. Can you please verify that the failures go away with this patch and report the kernel messages if any trigger?
Thanks a lot.
fs/fs-writeback.c +8 -10
@@ -103,7 +103,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(wbc_writepastatic bool wb_io_lists_populated (struct bdi_writeback *wb) { -if (wb_has_dirty_io (wb)) { +if (test_bit (WB_has_dirty_io, &wb->state)) {return false; }else {set_bit (WB_has_dirty_io, &wb->state);
@@ -844,14 +844,13 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && base_work->sync_mode ==WB_SYNC_NONE ) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);
@@ -899,8 +898,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;
@@ -2275,8 +2273,8 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* bdi_has_dirty() ignores I_DIRTY_TIME but we can't, always kick wbs */ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
include/linux/backing-dev.h +23 -2
@@ -38,7 +38,17 @@ extern struct workqueue_struct *bdi_wq;static inline bool wb_has_dirty_io (struct bdi_writeback *wb) { -return test_bit (WB_has_dirty_io, &wb->state); +bool ret =test_bit (WB_has_dirty_io, &wb->state); + +if (!ret && (!list_empty (&wb->b_dirty) || !list_empty (&wb->b_io) || + !list_empty (&wb->b_more_io))) { +const char *name = wb->bdi->dev ?dev_name (wb->bdi->dev) :"UNK" ; + +pr_err ("wb_has_dirty_io: ERR %s has_dirty=%d b_dirty=%d b_io=%d b_more_io=%d\n" , + name, ret, !list_empty (&wb->b_dirty), !list_empty (&wb->b_io), !list_empty (&wb->b_more_io)); +WARN_ON (1 ); + } +return ret; }static inline bool bdi_has_dirty_io (struct backing_dev_info *bdi)
@@ -47,7 +57,18 @@ static inline bool bdi_has_dirty_io(stru* @bdi->tot_write_bandwidth is guaranteed to be > 0 if there are * any dirty wbs. See wb_update_write_bandwidth(). */ -return atomic_long_read (&bdi->tot_write_bandwidth); +bool ret =atomic_long_read (&bdi->tot_write_bandwidth); + +if (ret !=wb_has_dirty_io (&bdi->wb)) { +const char *name = bdi->dev ?dev_name (bdi->dev) :"UNK" ; + +pr_err ("bdi_has_dirty_io: ERR %s tot_write_bw=%ld b_dirty=%d b_io=%d b_more_io=%d\n" , + name,atomic_long_read (&bdi->tot_write_bandwidth), + !list_empty (&bdi->wb.b_dirty), !list_empty (&bdi->wb.b_io), !list_empty (&bdi->wb.b_more_io)); +WARN_ON (1 ); + } + +return ret; } static inline void __add_wb_stat(struct bdi_writeback *wb,
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Quoted 6 lines · Tejun Heo
Hello, Eryu.
Can you please do the followings?
1. See if the "writeback: fix syncing of
I_DIRTY_TIMEinodes" patch changes anything.
After applying this patch, I can no longer reproduce the failure.
Quoted 5 lines
2. If not, apply this patch. This patch *should* make the failures go away and might print out some error messages along with stack trace. Can you please verify that the failures go away with this patch and report the kernel messages if any trigger?
And this patch fixed the failure too, and no WARNING no kernel message triggered.
All my testings are based on 4.2-rc6 kernel (I confirmed rc6 kernel failed the test first), then applied the first patch, and reverted the first patch, and applied the second patch.
Quoted 2 lines
Thanks a lot.
Thanks for looking into this!
Eryu
Quoted 97 lines
Index:
work/fs/fs-writeback.c
===================================================================fs/fs-writeback.c +8
-10@@ -103,7 +103,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(wbc_writepastatic bool wb_io_lists_populated (struct bdi_writeback *wb) { -if (wb_has_dirty_io (wb)) { +if (test_bit (WB_has_dirty_io, &wb->state)) {return false; }else {set_bit (WB_has_dirty_io, &wb->state);@@ -844,14 +844,13 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && base_work->sync_mode ==WB_SYNC_NONE ) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);@@ -899,8 +898,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;@@ -2275,8 +2273,8 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* bdi_has_dirty() ignores I_DIRTY_TIME but we can't, always kick wbs */ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));Index:
work/include/linux/backing-dev.h
===================================================================include/linux/backing-dev.h +23
-2@@ -38,7 +38,17 @@ extern struct workqueue_struct *bdi_wq;static inline bool wb_has_dirty_io (struct bdi_writeback *wb) { -return test_bit (WB_has_dirty_io, &wb->state); +bool ret =test_bit (WB_has_dirty_io, &wb->state); + +if (!ret && (!list_empty (&wb->b_dirty) || !list_empty (&wb->b_io) || + !list_empty (&wb->b_more_io))) { +const char *name = wb->bdi->dev ?dev_name (wb->bdi->dev) :"UNK" ; + +pr_err ("wb_has_dirty_io: ERR %s has_dirty=%d b_dirty=%d b_io=%d b_more_io=%d\n" , + name, ret, !list_empty (&wb->b_dirty), !list_empty (&wb->b_io), !list_empty (&wb->b_more_io)); +WARN_ON (1 ); + } +return ret; }static inline bool bdi_has_dirty_io (struct backing_dev_info *bdi)@@ -47,7 +57,18 @@ static inline bool bdi_has_dirty_io(stru* @bdi->tot_write_bandwidth is guaranteed to be > 0 if there are * any dirty wbs. See wb_update_write_bandwidth(). */ -return atomic_long_read (&bdi->tot_write_bandwidth); +bool ret =atomic_long_read (&bdi->tot_write_bandwidth); + +if (ret !=wb_has_dirty_io (&bdi->wb)) { +const char *name = bdi->dev ?dev_name (bdi->dev) :"UNK" ; + +pr_err ("bdi_has_dirty_io: ERR %s tot_write_bw=%ld b_dirty=%d b_io=%d b_more_io=%d\n" , + name,atomic_long_read (&bdi->tot_write_bandwidth), + !list_empty (&bdi->wb.b_dirty), !list_empty (&bdi->wb.b_io), !list_empty (&bdi->wb.b_more_io)); +WARN_ON (1 ); + } + +return ret; } static inline void __add_wb_stat(struct bdi_writeback *wb,
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Hello, Eryu.
lol that wasn't supposed to fix the problem you were seeing. Can you please apply the following patch and see whether any warning triggers? Also, you aren't using lazytime, right?
Thanks.
fs/fs-writeback.c +13 -10
@@ -103,7 +103,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(wbc_writepastatic bool wb_io_lists_populated (struct bdi_writeback *wb) { -if (wb_has_dirty_io (wb)) { +if (test_bit (WB_has_dirty_io, &wb->state)) {return false; }else {set_bit (WB_has_dirty_io, &wb->state);
@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(structstruct wb_iter iter;might_sleep (); - -if (!bdi_has_dirty_io (bdi)) -return ; restart:rcu_read_lock ();bdi_for_each_wb (wb, bdi, &iter, next_blkcg_id) { -if (!wb_has_dirty_io (wb) || - (skip_if_busy &&writeback_in_progress (wb))) +/* SYNC_ALL writes out I_DIRTY_TIME too */ +if (!wb_has_dirty_io (wb) && + (base_work->sync_mode ==WB_SYNC_NONE || +list_empty (&wb->b_dirty_time))) +continue ; +if (skip_if_busy &&writeback_in_progress (wb))continue ; base_work->nr_pages =wb_split_bdi_pages (wb, nr_pages);
@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct {might_sleep (); -if (bdi_has_dirty_io (bdi) && - (!skip_if_busy || !writeback_in_progress (&bdi->wb))) { +if (!skip_if_busy || !writeback_in_progress (&bdi->wb)) { base_work->auto_free =0 ; base_work->single_wait =0 ; base_work->single_done =0 ;
@@ -2004,6 +2004,9 @@ void __mark_inode_dirty(struct inode *intrace_writeback_mark_inode_dirty (inode, flags); +WARN_ON_ONCE (!(sb->s_flags &MS_LAZYTIME ) && + !list_empty (&inode_to_bdi (inode)->wb.b_dirty_time)); +/* * Don't do this for I_DIRTY_PAGES - that doesn't actually * dirty the inode itself
@@ -2275,8 +2278,8 @@ void sync_inodes_sb(struct super_block * };struct backing_dev_info *bdi = sb->s_bdi; -/* Nothing to do? */ -if (!bdi_has_dirty_io (bdi) || bdi == &noop_backing_dev_info) +/* bdi_has_dirty() ignores I_DIRTY_TIME but we can't, always kick wbs */ +if (bdi == &noop_backing_dev_info)return ;WARN_ON (!rwsem_is_locked (&sb->s_umount));
include/linux/backing-dev.h +31 -2
@@ -38,7 +38,25 @@ extern struct workqueue_struct *bdi_wq;static inline bool wb_has_dirty_io (struct bdi_writeback *wb) { -return test_bit (WB_has_dirty_io, &wb->state); +bool ret =test_bit (WB_has_dirty_io, &wb->state); +long tot_write_bw =atomic_long_read (&wb->bdi->tot_write_bandwidth); + +if (!ret && (!list_empty (&wb->b_dirty) || !list_empty (&wb->b_io) || + !list_empty (&wb->b_more_io))) { +const char *name = wb->bdi->dev ?dev_name (wb->bdi->dev) :"UNK" ; + +pr_err ("wb_has_dirty_io: ERR %s has_dirty=%d b_dirty=%d b_io=%d b_more_io=%d\n" , + name, ret, !list_empty (&wb->b_dirty), !list_empty (&wb->b_io), !list_empty (&wb->b_more_io)); +WARN_ON (1 ); + } +if (ret && !tot_write_bw) { +const char *name = wb->bdi->dev ?dev_name (wb->bdi->dev) :"UNK" ; + +pr_err ("wb_has_dirty_io: ERR %s has_dirty=%d but tot_write_bw=%ld\n" , + name, ret, tot_write_bw); +WARN_ON (1 ); + } +return ret; }static inline bool bdi_has_dirty_io (struct backing_dev_info *bdi)
@@ -47,7 +65,18 @@ static inline bool bdi_has_dirty_io(stru* @bdi->tot_write_bandwidth is guaranteed to be > 0 if there are * any dirty wbs. See wb_update_write_bandwidth(). */ -return atomic_long_read (&bdi->tot_write_bandwidth); +bool ret =atomic_long_read (&bdi->tot_write_bandwidth); + +if (ret !=wb_has_dirty_io (&bdi->wb)) { +const char *name = bdi->dev ?dev_name (bdi->dev) :"UNK" ; + +pr_err ("bdi_has_dirty_io: ERR %s tot_write_bw=%ld b_dirty=%d b_io=%d b_more_io=%d\n" , + name,atomic_long_read (&bdi->tot_write_bandwidth), + !list_empty (&bdi->wb.b_dirty), !list_empty (&bdi->wb.b_io), !list_empty (&bdi->wb.b_more_io)); +WARN_ON (1 ); + } + +return ret; } static inline void __add_wb_stat(struct bdi_writeback *wb,
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Quoted 4 lines · Tejun Heo
Hello, Eryu.
lol that wasn't supposed to fix the problem you were seeing. Can you please apply the following patch and see whether any warning triggers?
Sure, will do.
Quoted 1 line
Also, you aren't using lazytime, right?
Correct, I'm not using lazytime.
Thanks,
Eryu
Re: generic/04[89] fail on XFS due to change in writeback code [4.2-rc1 regression]
Quoted 7 lines · Eryu Guan
Quoted 4 lines · Tejun Heo
Hello, Eryu.
lol that wasn't supposed to fix the problem you were seeing. Can you please apply the following patch and see whether any warning triggers?
Sure, will do.
Still no warning triggered, and test passed too with this patch.
Test patch applied on top of 4.2-rc6, ran generic/048 generic/049 20 times in loop.
Thanks,
Eryu