From patchwork Sun Jun 24 19:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10484805 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 DE3066019D for ; Sun, 24 Jun 2018 19:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C22ED286F3 for ; Sun, 24 Jun 2018 19:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4DE828643; Sun, 24 Jun 2018 19:24:18 +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, UNPARSEABLE_RELAY 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 B1B0B28643 for ; Sun, 24 Jun 2018 19:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeFXTXr (ORCPT ); Sun, 24 Jun 2018 15:23:47 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:43626 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbeFXTXp (ORCPT ); Sun, 24 Jun 2018 15:23:45 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5OJDx2G182745 for ; Sun, 24 Jun 2018 19:23:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=GuPRDtEP4c6VQgurw95nqsuThr3panAFqp0SrfP6I4I=; b=o2Y8PIMZt/LHTN5ISAxu+AhI30RRBxTaJRnIT5PccQdrOT9mzHaXs7bxo7ZHivdGYmkW JRJ/9wntPh+WRK7CSU76ERm2g+txKOycJRm2+cyPL6sxO8/9fkzipX6Wllbr260HaOci 9Pyij+5Ht3K7gdBKrNhVUeO1y+5PaQYQ4ao0PWSoPLtcofXbwieWexk3MVlYVTK3hdiM UaPkuE/YNv+18OJjdgO/oglmS1/5zfgUDTYcPle2Bi/2vjSZ1DLCoqkn6N+ZQYY6V9LJ k01SAIZHLrEbwHvuIcf1QrQGJmM3eaXRvoMp98e4k0eKjTdSB8C86FafHBhiBb++Wf/z 4Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2jt7narhf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 24 Jun 2018 19:23:44 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5OJNh3N019226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 24 Jun 2018 19:23:44 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5OJNhPq020352 for ; Sun, 24 Jun 2018 19:23:43 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 24 Jun 2018 12:23:43 -0700 Subject: [PATCH 02/21] xfs: add helper to decide if an inode has allocated cow blocks From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Sun, 24 Jun 2018 12:23:42 -0700 Message-ID: <152986822251.3155.14348466047540978889.stgit@magnolia> In-Reply-To: <152986820984.3155.16417868536016544528.stgit@magnolia> References: <152986820984.3155.16417868536016544528.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8934 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806240234 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 From: Darrick J. Wong Add a helper to decide if an inode has real or unwritten extents in the CoW fork. The upcoming repair freeze functionality will have to know if it's safe to iput an inode -- if the inode has incore any state that would require a transaction to unwind during iput, we'll have to defer the iput. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson --- fs/xfs/xfs_inode.c | 19 +++++++++++++++++++ fs/xfs/xfs_inode.h | 1 + 2 files changed, 20 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7a96c4e0ab5c..e6859dfc29af 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3689,3 +3689,22 @@ xfs_iflush_int( corrupt_out: return -EFSCORRUPTED; } + +/* Decide if there are real or unwritten extents in the CoW fork. */ +bool +xfs_inode_has_cow_blocks( + struct xfs_inode *ip) +{ + struct xfs_iext_cursor icur; + struct xfs_bmbt_irec irec; + struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); + + if (!ifp) + return false; + + for_each_xfs_iext(ifp, &icur, &irec) { + if (!isnullstartblock(irec.br_startblock)) + return true; + } + return false; +} diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 2ed63a49e890..735d0788bfdb 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -503,5 +503,6 @@ extern struct kmem_zone *xfs_inode_zone; #define XFS_DEFAULT_COWEXTSZ_HINT 32 bool xfs_inode_verify_forks(struct xfs_inode *ip); +bool xfs_inode_has_cow_blocks(struct xfs_inode *ip); #endif /* __XFS_INODE_H__ */