From: Dave Chinner Subject: Re: Does fsync() block read and write ops on the same file? Date: Sun, 13 Dec 2009 10:05:20 +1100 Message-ID: <20091212230520.GM30608@discord.disaster> References: <82ein3npyc.fsf@mid.bfk.de> <20091211035521.GI30608@discord.disaster> <82hbrxhoxa.fsf@mid.bfk.de> <20091211124224.GK30608@discord.disaster> <824onxekp4.fsf@mid.bfk.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: Florian Weimer Return-path: Received: from bld-mail19.adl2.internode.on.net ([150.101.137.104]:43172 "HELO mail.internode.on.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S933122AbZLMBWg (ORCPT ); Sat, 12 Dec 2009 20:22:36 -0500 Content-Disposition: inline In-Reply-To: <824onxekp4.fsf@mid.bfk.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Dec 11, 2009 at 12:53:11PM +0000, Florian Weimer wrote: > * Dave Chinner: > > >> I'm not concerned with fsync latency per se. It's going to take a > >> while to write a few GBs scattered across the file. However, it's > >> annoying that read operations on the same file (which can't even see > >> the effect of the fsync operation) are blocked, some times for more > >> than two minutes. > > > > If they are blocking for that long then sysrq-w during that period > > will tell us exactly where in what filesystem they are blocking on.... > > Interesting. Is it possible to trigger this from the hang timer? > From that, I've got two traces: > > [307370.450502] Call Trace: > [307370.450555] [] dput+0x1c/0xdd > [307370.450590] [] __down_read+0x87/0xa1 > [307370.450641] [] :xfs:xfs_ilock+0x31/0x60 > [307370.450684] [] :xfs:xfs_read+0x147/0x21a > [307370.450718] [] do_sync_read+0xc9/0x10c > [307370.450750] [] autoremove_wake_function+0x0/0x2e > [307370.450787] [] vfs_read+0xaa/0x152 > [307370.450815] [] sys_read+0x45/0x6e > [307370.450844] [] system_call_after_swapgs+0x8a/0x8f That is xfs_ilock(inode, XFS_IOLOCK_SHARED), which means it is blocked on a either a concurrent write, truncate or preallocation occurring to the same file. ->fsync does not take the IOLOCK at all (it takes the ILOCK which protects non-IO related inode attributes), so that is not causing your pauses here.... Cheers, Dave. -- Dave Chinner david@fromorbit.com