From patchwork Wed Feb 28 17:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10249075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66EE660211 for ; Wed, 28 Feb 2018 17:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47FCA28E16 for ; Wed, 28 Feb 2018 17:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CA8928E2A; Wed, 28 Feb 2018 17:46:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D25B628E16 for ; Wed, 28 Feb 2018 17:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933124AbeB1RqL (ORCPT ); Wed, 28 Feb 2018 12:46:11 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60916 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933245AbeB1Rp7 (ORCPT ); Wed, 28 Feb 2018 12:45:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jlsbc6SGwAmFMofUnEv+Z6je7NYkrmRfg24jXqBZvKY=; b=dBQTqT2SSpBYCOsYEG90QPn4B 5e5ax1/i++ntbaG4Mr4D3t3TVB/1Gdq2BAGqtJttrq9GCqjCFCwRLZ/EYoyffHP1btT8TghXX4uxg cEWuAB8moWxJK7SV4vH/jFkA+EPfByE+TJiKpxTrKxfehGCTxpEYZ2COAPBlLEbHD9vNbKTxPr2Ic sM5sRQ2HsB+xOjBdWGkrO64ifomxXXiHr2t2pe0V7D1L96s7X+tH4VaxwedgJzpZ0vaA697knMwNi A4+DkwXDO0kJ2ASzpCn4vAFD/y5KpgEmD9WHamrAYnHW1EXef4/3hOiw6yi9YMXOgs8+tQn39a7zv /DNBEhz6g==; Received: from 71-83-125-253.static.reno.nv.charter.com ([71.83.125.253] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1er5nf-0000nk-Ia; Wed, 28 Feb 2018 17:45:55 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: david@fromorbit.com Subject: [PATCH 2/3] xfs: don't start out with the exclusive ilock for direct I/O Date: Wed, 28 Feb 2018 09:45:51 -0800 Message-Id: <20180228174552.31919-3-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180228174552.31919-1-hch@lst.de> References: <20180228174552.31919-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no reason to take the ilock exclusively at the start of xfs_file_iomap_begin for direct I/O, given that it will be demoted just before calling xfs_iomap_write_direct anyway. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner --- fs/xfs/xfs_iomap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 4e771e0f1170..ee01859b77a5 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -965,13 +965,11 @@ static inline bool needs_cow_for_zeroing(struct xfs_bmbt_irec *imap, int nimaps) static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) { /* - * COW writes will allocate delalloc space, so we need to make sure - * to take the lock exclusively here. + * COW writes may allocate delalloc space or convert unwritten COW + * extents, so we need to make sure to take the lock exclusively here. */ if (xfs_is_reflink_inode(ip) && (flags & (IOMAP_WRITE | IOMAP_ZERO))) return true; - if ((flags & IOMAP_DIRECT) && (flags & IOMAP_WRITE)) - return true; return false; }