From: Eric Biggers <ebiggers@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: lazytime causing inodes to remain dirty after sync? Date: Thu, 5 Mar 2020 16:45:55 -0800 [thread overview] Message-ID: <20200306004555.GB225345@gmail.com> (raw) While testing my patch "fscrypt: don't evict dirty inodes after removing key" (https://lkml.kernel.org/r/20200305084138.653498-1-ebiggers@kernel.org), I've run into an issue where even after the filesystem is sync'ed and no files are in-use, inodes can remain dirty if the filesystem is mounted with -o lazytime. Thus, my patch causes some inodes to not be evicted when they should be. (lazytime is the default on f2fs, but ext4 supports it too.) This is caused by the following code in __writeback_single_inode() that redirties the inode if its access time is dirty: if (dirty & I_DIRTY_TIME) mark_inode_dirty_sync(inode); /* Don't write the inode if only I_DIRTY_PAGES was set */ if (dirty & ~I_DIRTY_PAGES) { int err = write_inode(inode, wbc); if (ret == 0) ret = err; } trace_writeback_single_inode(inode, wbc, nr_to_write); return ret; Here's a reproducer in the kvm-xfstests test appliance which demonstrates the problem using sync(), without fscrypt involved at all: sysctl vm.dirty_expire_centisecs=500 umount /vdc mkfs.ext4 -F /dev/vdc mount /vdc -o lazytime echo contents > /vdc/file sync ino=$(stat -c %i /vdc/file) echo 1 | tee /sys/kernel/debug/tracing/events/writeback/writeback_{single_inode_start,mark_inode_dirty,lazytime}/enable echo "ino == $ino" | tee /sys/kernel/debug/tracing/events/writeback/writeback_{single_inode_start,mark_inode_dirty,lazytime}/filter echo > /sys/kernel/debug/tracing/trace cat /vdc/file > /dev/null sync cat /sys/kernel/debug/tracing/trace_pipe The tracing shows that the inode for /vdc/file is written during the sync at 7.28s. But then, still during the sync, it's immediately re-dirtied. It then gets written again later in the background, after the sync. cat-286 [001] ...1 7.279433: writeback_mark_inode_dirty: bdi 254:32: ino=12 state= flags=I_DIRTY_TIME kworker/u8:0-8 [003] ...1 7.282647: writeback_single_inode_start: bdi 254:32: ino=12 state=I_SYNC|I_DIRTY_TIME|I_DIRTY_TIME_EXPIRED dirtied_when=4294879420 age=0 index=1 to_write=9223372036854775807 wrote=0 cgroup_ino=1 kworker/u8:0-8 [003] ...2 7.282660: writeback_lazytime: dev 254,32 ino 12 dirtied 4294879420 state I_SYNC|I_DIRTY_TIME|I_DIRTY_TIME_EXPIRED mode 0100644 kworker/u8:0-8 [003] ...1 7.283204: writeback_mark_inode_dirty: bdi 254:32: ino=12 state=I_SYNC flags=I_DIRTY_SYNC kworker/u8:0-8 [003] ...1 12.412079: writeback_single_inode_start: bdi 254:32: ino=12 state=I_DIRTY_SYNC|I_SYNC dirtied_when=4294879421 age=5 index=1 to_write=13312 wrote=0 cgroup_ino=1 Is this behavior intentional at all? It seems like a bug; it seems the inode should be written just once, during the sync. - Eric
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: [f2fs-dev] lazytime causing inodes to remain dirty after sync? Date: Thu, 5 Mar 2020 16:45:55 -0800 [thread overview] Message-ID: <20200306004555.GB225345@gmail.com> (raw) While testing my patch "fscrypt: don't evict dirty inodes after removing key" (https://lkml.kernel.org/r/20200305084138.653498-1-ebiggers@kernel.org), I've run into an issue where even after the filesystem is sync'ed and no files are in-use, inodes can remain dirty if the filesystem is mounted with -o lazytime. Thus, my patch causes some inodes to not be evicted when they should be. (lazytime is the default on f2fs, but ext4 supports it too.) This is caused by the following code in __writeback_single_inode() that redirties the inode if its access time is dirty: if (dirty & I_DIRTY_TIME) mark_inode_dirty_sync(inode); /* Don't write the inode if only I_DIRTY_PAGES was set */ if (dirty & ~I_DIRTY_PAGES) { int err = write_inode(inode, wbc); if (ret == 0) ret = err; } trace_writeback_single_inode(inode, wbc, nr_to_write); return ret; Here's a reproducer in the kvm-xfstests test appliance which demonstrates the problem using sync(), without fscrypt involved at all: sysctl vm.dirty_expire_centisecs=500 umount /vdc mkfs.ext4 -F /dev/vdc mount /vdc -o lazytime echo contents > /vdc/file sync ino=$(stat -c %i /vdc/file) echo 1 | tee /sys/kernel/debug/tracing/events/writeback/writeback_{single_inode_start,mark_inode_dirty,lazytime}/enable echo "ino == $ino" | tee /sys/kernel/debug/tracing/events/writeback/writeback_{single_inode_start,mark_inode_dirty,lazytime}/filter echo > /sys/kernel/debug/tracing/trace cat /vdc/file > /dev/null sync cat /sys/kernel/debug/tracing/trace_pipe The tracing shows that the inode for /vdc/file is written during the sync at 7.28s. But then, still during the sync, it's immediately re-dirtied. It then gets written again later in the background, after the sync. cat-286 [001] ...1 7.279433: writeback_mark_inode_dirty: bdi 254:32: ino=12 state= flags=I_DIRTY_TIME kworker/u8:0-8 [003] ...1 7.282647: writeback_single_inode_start: bdi 254:32: ino=12 state=I_SYNC|I_DIRTY_TIME|I_DIRTY_TIME_EXPIRED dirtied_when=4294879420 age=0 index=1 to_write=9223372036854775807 wrote=0 cgroup_ino=1 kworker/u8:0-8 [003] ...2 7.282660: writeback_lazytime: dev 254,32 ino 12 dirtied 4294879420 state I_SYNC|I_DIRTY_TIME|I_DIRTY_TIME_EXPIRED mode 0100644 kworker/u8:0-8 [003] ...1 7.283204: writeback_mark_inode_dirty: bdi 254:32: ino=12 state=I_SYNC flags=I_DIRTY_SYNC kworker/u8:0-8 [003] ...1 12.412079: writeback_single_inode_start: bdi 254:32: ino=12 state=I_DIRTY_SYNC|I_SYNC dirtied_when=4294879421 age=5 index=1 to_write=13312 wrote=0 cgroup_ino=1 Is this behavior intentional at all? It seems like a bug; it seems the inode should be written just once, during the sync. - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next reply other threads:[~2020-03-06 0:45 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-06 0:45 Eric Biggers [this message] 2020-03-06 0:45 ` [f2fs-dev] lazytime causing inodes to remain dirty after sync? Eric Biggers 2020-03-07 2:00 ` [PATCH] writeback: avoid double-writing the inode on a lazytime expiration Theodore Ts'o 2020-03-07 2:00 ` [f2fs-dev] " Theodore Ts'o 2020-03-11 3:20 ` Eric Biggers 2020-03-11 3:20 ` [f2fs-dev] " Eric Biggers 2020-03-11 12:57 ` Theodore Y. Ts'o 2020-03-11 12:57 ` [f2fs-dev] " Theodore Y. Ts'o 2020-03-12 0:07 ` Dave Chinner 2020-03-12 0:07 ` [f2fs-dev] " Dave Chinner 2020-03-12 14:34 ` Christoph Hellwig 2020-03-12 14:34 ` [f2fs-dev] " Christoph Hellwig 2020-03-12 22:39 ` Dave Chinner 2020-03-12 22:39 ` [f2fs-dev] " Dave Chinner 2020-03-20 2:46 ` Theodore Y. Ts'o 2020-03-20 2:46 ` [f2fs-dev] " Theodore Y. Ts'o 2020-03-20 2:52 ` [PATCH 1/2] " Theodore Ts'o 2020-03-20 2:52 ` [f2fs-dev] " Theodore Ts'o 2020-03-20 2:52 ` [PATCH 2/2] writeback, xfs: call dirty_inode() with I_DIRTY_TIME_EXPIRED when appropriate Theodore Ts'o 2020-03-20 2:52 ` [f2fs-dev] " Theodore Ts'o 2020-03-23 17:58 ` Theodore Y. Ts'o 2020-03-23 17:58 ` [f2fs-dev] " Theodore Y. Ts'o 2020-03-24 8:37 ` Christoph Hellwig 2020-03-24 8:37 ` [f2fs-dev] " Christoph Hellwig 2020-03-24 18:43 ` Theodore Y. Ts'o 2020-03-24 18:43 ` [f2fs-dev] " Theodore Y. Ts'o 2020-03-25 9:20 ` [PATCH 1/2] writeback: avoid double-writing the inode on a lazytime expiration Christoph Hellwig 2020-03-25 9:20 ` [f2fs-dev] " Christoph Hellwig 2020-03-25 15:21 ` Theodore Y. Ts'o 2020-03-25 15:21 ` [f2fs-dev] " Theodore Y. Ts'o 2020-03-25 15:47 ` Darrick J. Wong 2020-03-25 15:47 ` [f2fs-dev] " Darrick J. Wong 2020-03-11 23:54 ` [PATCH] " Dave Chinner 2020-03-11 23:54 ` [f2fs-dev] " Dave Chinner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200306004555.GB225345@gmail.com \ --to=ebiggers@kernel.org \ --cc=linux-ext4@vger.kernel.org \ --cc=linux-f2fs-devel@lists.sourceforge.net \ --cc=linux-fsdevel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.