[Top] [All Lists]

Re: [PATCH 04/10] xfs: implement freezing by emptying the AIL

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 04/10] xfs: implement freezing by emptying the AIL
From: Mark Tinguely <tinguely@xxxxxxx>
Date: Wed, 18 Apr 2012 12:53:14 -0500
Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
In-reply-to: <20120417082633.GH6734@dastard>
References: <20120327164400.967415009@xxxxxxxxxxxxxxxxxxxxxx> <20120327164644.830680325@xxxxxxxxxxxxxxxxxxxxxx> <4F8C22D4.3040908@xxxxxxx> <20120416235432.GZ6734@dastard> <20120417042023.GG6734@dastard> <20120417082633.GH6734@dastard>
User-agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120122 Thunderbird/9.0
On 04/17/12 03:26, Dave Chinner wrote:

Yeah, it's pretty clear what is happening here. We don't have
freeze protection against EOF zeroing operations. At least
xfs_setattr_size() and xfs_change_file_space() fail to check for
freeze, and that is initially what I though was causing this problem.

However, adding freeze checks into the relevant paths didn't make
the hangs go away, so there's more to it than that. Basically, we've
been getting races between checking for freeze, the dirtying of the
pages and the flusher thread syncing out the dirty data. i.e.:

Thread 1                Thread 2                freeze          flusher thread
write inode A
check for freeze
                                        grab s_umount
                                                                iterate dirty 
                                                                inode A not in 
                                                                iterate dirty 
                                                                inode A not in 
dirty pages
mark inode A dirty
write inode A done.
                                        drop s_umount
                                        freeze done
                        grab s_umount
                                                                iterate dirty 
                                                                Flush dirty 
inode A

Before we added the transactional inode size updates, this race
simply went unnoticed because nothing caused the flusher thread to
block. All the problems I see are due to overwrites of allocated
space - if there was real allocation then the delalloc conversion
would have always hung. Now we see that when we need to extend the
file size when writing, we ahve to allocate a transaction and hence
the flusher thread now hangs.

While I can "fix" the xfs_setattr_size() and xfs_change_file_space()
triggers, they don't close the above race condition, so this problem
is essentially unfixable in XFS. The only reason we have not tripped
over it before is that the flusher thread didn't hang waiting for a
transaction reservation when the race was hit.

So why didn't this happen before Christoph's patch set? That's
something I can't explain. Oh, wait, yes I can - 068 hangs even
without this patch of Christoph's. Actually, looking at my xfstests
logs, I can trace the start of the failures back to mid march, and
that coincided with an update to the xfstests installed on my test
boxes. Which coincides with when my machines first saw this change:

commit 281627df3eb55e1b729b9bb06fff5ff112929646
Author: Christoph Hellwig<hch@xxxxxxxxxxxxx>
Date:   Tue Mar 13 08:41:05 2012 +0000

     xfs: log file size updates at I/O completion time

That confirms my analysis above - the problem is being exposed by new
code in the writeback path that does transaction allocation where it
didn't used to.

Clearly the problem is not really the new code in Christoph's
patches - it's an existing freeze problem that has previously
resulted in data writes occuring after a freeze has completed (of
which we have had rare complaints about). That sounds pretty dire,
except for one thing: Jan Kara's patch set that fixes all these
freeze problems:


And now that I've run some testing with Jan's patch series, along
with Christoph's and mine (75-odd patches;), a couple of my test
VMs have been running test 068 in a tight loop for about half an
hour without a hang, so I'd consider this problem fixed by Jan's
freeze fixes given I could reliably hang it in 2-3 minutes before
adding Jan's patch set to my stack.

So the fix for this problem is getting Jan's patch set into the
kernel at the same time we get the inode size logging changes into
the kernel. What do people think about that for a plan?


-- Dave Chinner david@xxxxxxxxxxxxx

Just a heads up, Jan's freeze patch did clear up the test 086 hang on my test box as well, but the 106 (quota test) hang on one of the mounts is still there.


<Prev in Thread] Current Thread [Next in Thread>