From patchwork Wed May 9 07:48:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10388397 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 0D52460170 for ; Wed, 9 May 2018 07:49:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 005B328E05 for ; Wed, 9 May 2018 07:49:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E919B28E2B; Wed, 9 May 2018 07:49:37 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8104728E05 for ; Wed, 9 May 2018 07:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5968E6B0359; Wed, 9 May 2018 03:49:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F44F6B035B; Wed, 9 May 2018 03:49:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BF246B035C; Wed, 9 May 2018 03:49:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id E239B6B0359 for ; Wed, 9 May 2018 03:49:32 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id bd7-v6so3308560plb.20 for ; Wed, 09 May 2018 00:49:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=JQVY3t8+5zjW9BkH0GuXp/joGrIkyF38Nmjoe+S4aQ0=; b=Cz8TG4Bh15dcjhbK3neN30+CjzYTwFGlnwkQ04JDqusfTCMmlRbqg6zelEmv7WC37N ELM4/kvp10JI3u6J5NlLIsdGQexcX5KbUB4wXCvL/MHjqLmbj4ea8zg8ld2yelYsPIL9 ihOogM/HzwPu5LpDY5hdwKsXp86bcIyFTfThv1A39S5/12O+5+Ja0PPhopOAS6trfzln 59YKTE0GTbOqDzNLOcfLYFscRologOnPGngqk41xk17Sb9zIA73YA6EHC3lVtIUGsZbt ryDlpMvRyibxVB57q/T3J5vR3CrCUMwwP+VfR0gOjz8PEj9MuUDZFMHGkJQ5aHt3IS9b s7Aw== X-Gm-Message-State: ALQs6tBxyxSJcKQZRifDzxu1MqN5HzHZ7zaeRAjQX9IxcKW1zTGcLaQ4 qjeD4oJPiuOwFTSdZPYzdz/fWTNGHfAgWExnREhWJOI0+RKiUsO4jJXTzq+UIBpDScLNNxkH1zB +1WoEiFxlOUVCBEyecap35GHxQI61IkjnakN/gt7nV+zBz8D73Y4QQ7yjJKWp2gs= X-Received: by 2002:a65:41cb:: with SMTP id b11-v6mr23250580pgq.260.1525852172601; Wed, 09 May 2018 00:49:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpOCF6bHUgozZZVrubRbqCKHe4U0pCQRC8tgZL8s2jb04biO692+3Nk63tve7wreFCUBSGO X-Received: by 2002:a65:41cb:: with SMTP id b11-v6mr23250557pgq.260.1525852171823; Wed, 09 May 2018 00:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525852171; cv=none; d=google.com; s=arc-20160816; b=FNMHU8DL5cbq8vnBXkXZQVMM6OeDNPI88EfTy1MU25c9S2TrlpZOebFaaJ5f5P+XHF RoV2pRmY10v9HS52T5GzljHv97RDBwTYHzyg6nbdwTQZIl/iVI8zXNbuYq7BZkCgZI3T YzY2R/VbQB7EvqvbutrFxkuoVWQbWIyfWBHXhZjDdhJwvgnTz91jlXZhJBku3ty7oIV6 0F6lh9594vOAv8hMd42JYzttiMqxzOHtuFx3jg876h5gJf7rumjB39Eqk4KKhLOa24Ah hvPWSJVgu+ZY66kaGj54ev/Tc4wHVTuGMLAX9yz00diJ1EznhGtoQIIHgOcLOg+tVUtO gh9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JQVY3t8+5zjW9BkH0GuXp/joGrIkyF38Nmjoe+S4aQ0=; b=vDAkeuiaub+kqLKjQpZgBz8vW6anFK4qqCOnRohw3XOTYOuxZRFgXBKhqmFkL8tKGu Zi7IiRlzzdAF7KsybgWb25xzhVc6rR5e+j9Js9mKWBFtUVJcoguul6TdzEqivDCQWFAp jFaiYH5lW75vMKsdy42Q3tVk8pnCPHk5RBSHbpc6VM4BOqsYEpXSLdKoSSfYMH7b/Btv Zc3HNE6KxrzKZql8iH3K4ytcbdWUrigHvYzrTflZXS2HJcQM+DlM6fq/h27h+z4GBnht Fxw8JDYgFoMVpbtzFZY0NiYPqP/qhYWb2Tb0oQ3+nGC1f8z3FLLhlZLuh1uYs05pDiJ/ m4ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=ksnLf/tY; spf=pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id g63-v6si16723452pgc.40.2018.05.09.00.49.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 00:49:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=ksnLf/tY; spf=pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org 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=JQVY3t8+5zjW9BkH0GuXp/joGrIkyF38Nmjoe+S4aQ0=; b=ksnLf/tYVQDURp52MZm3wGp6Z UYw2fy1Mvp5QMkcXPHWH9GHPMl+j1Cq8vuT97jWnbySGGmXJ7N8idjvpPotOcmOFbYycArf+R4tD6 Qwie88bu6bYdEzSm3+wocdDek2q8dkk7bouFsfHpLAYe2D00EIINEq2VDlhxN0nsfE9wbI8wSaXcS Fk6pv7XDqq3In+v2+/BpE2Q/hfHEvcG8iMsGkF0w2eTmZpQtCA7he0Yj0ODQtQnZbTtLti/BvabM7 CrMwKrFUDfkshCoABAJDfsZ1NKgN91i0zefNFgBf/NnrTNrg5xifYalkF+DHsSQuFzQMSMvTUYfQW CtY/MNsKA==; Received: from 213-225-15-246.nat.highway.a1.net ([213.225.15.246] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGJqs-0001cp-Q1; Wed, 09 May 2018 07:49:31 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 16/33] xfs: move locking into xfs_bmap_punch_delalloc_range Date: Wed, 9 May 2018 09:48:13 +0200 Message-Id: <20180509074830.16196-17-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509074830.16196-1-hch@lst.de> References: <20180509074830.16196-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Both callers want the same looking, so do it only once. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_aops.c | 2 -- fs/xfs/xfs_bmap_util.c | 7 ++++--- fs/xfs/xfs_iomap.c | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 313449ac0288..196c5daa6dce 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 7d2ba4cc8fba..82189ea97319 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -711,12 +711,11 @@ 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(ip, ifp, start_fsb, &icur, &got)) @@ -738,6 +737,8 @@ xfs_bmap_punch_delalloc_range( break; } while (xfs_iext_next_extent(ifp, &icur, &got)); +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 046469fcc1b8..407bbd978d1b 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1167,11 +1167,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);