From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Chinner Subject: Re: [PATCH 1/3] xfs: add RWF_NONBLOCK support Date: Thu, 2 Oct 2014 08:23:27 +1000 Message-ID: <20141001222327.GT4758@dastard> References: <1412197494-7655-1-git-send-email-hch@lst.de> <1412197494-7655-2-git-send-email-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Milosz Tanski , linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com To: Christoph Hellwig Return-path: Received: from ipmail07.adl2.internode.on.net ([150.101.137.131]:22023 "EHLO ipmail07.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbaJAWXm (ORCPT ); Wed, 1 Oct 2014 18:23:42 -0400 Content-Disposition: inline In-Reply-To: <1412197494-7655-2-git-send-email-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Oct 01, 2014 at 11:04:52PM +0200, Christoph Hellwig wrote: > Add support for non-blocking reads. The guts are handled by the generic > code, the only addition is a non-blocking variant of xfs_rw_ilock. > > Signed-off-by: Christoph Hellwig > --- > fs/xfs/xfs_file.c | 30 +++++++++++++++++++++++++----- > 1 file changed, 25 insertions(+), 5 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index cf61271..f9efffc 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -61,6 +61,23 @@ xfs_rw_ilock( > xfs_ilock(ip, type); > } > > +static inline bool > +xfs_rw_ilock_nowait( > + struct xfs_inode *ip, > + int type) > +{ > + if (type & XFS_IOLOCK_EXCL) { > + if (!mutex_trylock(&VFS_I(ip)->i_mutex)) > + return false; > + } > + if (!xfs_ilock_nowait(ip, type)) { > + mutex_unlock(&VFS_I(ip)->i_mutex); Shouldn't that be: if (type & XFS_IOLOCK_EXCL) { mutex_unlock(&VFS_I(ip)->i_mutex); Cheers, Dave. -- Dave Chinner david@fromorbit.com