From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH] xfs: don't take the i_mutex in ->fsync() Date: Tue, 19 Jul 2011 10:41:48 -0400 Message-ID: <20110719144148.GA3941@infradead.org> References: <1311079293-3271-1-git-send-email-josef@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, david@fromorbit.com To: Josef Bacik Return-path: Received: from 173-166-109-252-newengland.hfc.comcastbusiness.net ([173.166.109.252]:60466 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980Ab1GSOlv (ORCPT ); Tue, 19 Jul 2011 10:41:51 -0400 Content-Disposition: inline In-Reply-To: <1311079293-3271-1-git-send-email-josef@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Jul 19, 2011 at 08:41:33AM -0400, Josef Bacik wrote: > In pushing down the i_mutex into the ->fsync() handlers I introduced a deadlock > since xfs will call xfs_file_fsync in the O_SYNC case while still holding the > i_mutex case. In talking with Dave he said that xfs doesn't really need to hold > the i_mutex in xfs_file_sync() so just drop the taking of i_mutex and we should > be good to go. Thanks, We need some serialized around the xfs_ioend_wait call to prvent new ioends coming in from starving our wait, be that i_mutex or the iolock. The right fix for you patch for now is fixing xfs_file_aio_write to call xfs_file_fsync correctly, that is removing the filemap_write_and_wait_range call, and instead moving the fsync call into the section where we have dropped the iolock and i_mutex. Dave and I can then later look into dropping i_mutex in fsync and replacing it with the iolock and/or finding a way to reduce the number of lock roundtrips in the O_SYNC path.