From patchwork Fri Jun 15 13:01: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: 10466353 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 6CCC26020F for ; Fri, 15 Jun 2018 13:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6015028D67 for ; Fri, 15 Jun 2018 13:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54E8428D6B; Fri, 15 Jun 2018 13:02:33 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 E1AA728D69 for ; Fri, 15 Jun 2018 13:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936200AbeFONCb (ORCPT ); Fri, 15 Jun 2018 09:02:31 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36850 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936193AbeFONCa (ORCPT ); Fri, 15 Jun 2018 09:02:30 -0400 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=8ZC2/awSyDRCsRrPfQL/A3XyM/Q2GuZdheOgpYOcz78=; b=pmzjYEDIuAgr9fCxdzTwtpvdY 9fjGg1mAEZv9CMTDvXs8Rby3JVMAqzx4E43P3JpTwffB1f1YpHR0s4CjZoiYj7BkUcf6wtBS9y0TH vIjLdrS1/w7EHNacHMhmNgZR+qRyKmvUavtv+3lz8mbjgV9vk0KDT0x73QcIif49k0WYM5lvfErNB mDu/e2fSkt7exZB+Mxt7D2myusv8P5Y4hEbrSTsj4Hx1+o36/pzg9F1o+K4DzJnSxvFgymOlnwzFJ oEyKYksNaLs+DXUJ0Tc51U9YYiCffuOX+jStsSIxHi4gtgrVKsjTvQtwgfh8eAe4ZlYQDciOEBLWb C7HAtO9Bg==; Received: from 80-109-164-210.cable.dynamic.surfer.at ([80.109.164.210] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fToN2-0003Wa-Od; Fri, 15 Jun 2018 13:02:29 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 06/24] xfs: move locking into xfs_bmap_punch_delalloc_range Date: Fri, 15 Jun 2018 15:01:51 +0200 Message-Id: <20180615130209.1970-7-hch@lst.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615130209.1970-1-hch@lst.de> References: <20180615130209.1970-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 Both callers want the same looking, so do it only once. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_aops.c | 2 -- fs/xfs/xfs_bmap_util.c | 9 +++++---- fs/xfs/xfs_iomap.c | 3 --- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index d94dd6fe5127..026721c4991e 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -761,10 +761,8 @@ xfs_aops_discard_page( "page discard on page "PTR_FMT", inode 0x%llx, offset %llu.", page, ip->i_ino, offset); - xfs_ilock(ip, XFS_ILOCK_EXCL); error = xfs_bmap_punch_delalloc_range(ip, start_fsb, PAGE_SIZE / i_blocksize(inode)); - xfs_iunlock(ip, XFS_ILOCK_EXCL); if (error && !XFS_FORCED_SHUTDOWN(mp)) xfs_alert(mp, "page discard unable to remove delalloc mapping."); out_invalidate: diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 0070b877ed94..6690a038892d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -712,16 +712,15 @@ xfs_bmap_punch_delalloc_range( struct xfs_iext_cursor icur; int error = 0; - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - + xfs_ilock(ip, XFS_ILOCK_EXCL); if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK); if (error) - return error; + goto out_unlock; } if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got)) - return 0; + goto out_unlock; while (got.br_startoff + got.br_blockcount > start_fsb) { del = got; @@ -745,6 +744,8 @@ xfs_bmap_punch_delalloc_range( break; } +out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 85c66e78f9e8..758ad9572d04 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1205,11 +1205,8 @@ xfs_file_iomap_end_delalloc( truncate_pagecache_range(VFS_I(ip), XFS_FSB_TO_B(mp, start_fsb), XFS_FSB_TO_B(mp, end_fsb) - 1); - xfs_ilock(ip, XFS_ILOCK_EXCL); error = xfs_bmap_punch_delalloc_range(ip, start_fsb, end_fsb - start_fsb); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - if (error && !XFS_FORCED_SHUTDOWN(mp)) { xfs_alert(mp, "%s: unable to clean up ino %lld", __func__, ip->i_ino);