From patchwork Mon May 20 23:16:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5070112C for ; Mon, 20 May 2019 23:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 923B02015F for ; Mon, 20 May 2019 23:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 861F728896; Mon, 20 May 2019 23:16:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 21C512015F for ; Mon, 20 May 2019 23:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbfETXQw (ORCPT ); Mon, 20 May 2019 19:16:52 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37968 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXQw (ORCPT ); Mon, 20 May 2019 19:16:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDdj9148845; Mon, 20 May 2019 23:16:50 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-2018-07-02; bh=I7bBs7Pp4CXb4u2L0b2cYmvy0TI1U5RivE+qjJbLuSM=; b=g7w50XqQOPobxjlZC+WIYyipkPNNCxaYr8759TTyRGV4zqgyzToZDyQFvx/XH4N9vGat ixydRHvx5N+e26jbUucJGfkS6qJE6lrUahoiIVDd8ZmQbpYdfMmNomjezNfxckM6O+lG 0alClmxL9VWZV+IOZCg0W1MCPEBYmeqGrsK2xnmBx/ZvkKzoX7PzBi9g7tap5W4rPxlZ JNAgBdBsh1hsZGnZnQJ0GHrQBrh8uBB9ABBICf+1IdOVDlpnXXCgLNgFHydGdOjYz/dx qWvPfwHyWa6PityqxUW8O7XO7wZHrgsTTmRTBi4CjxsVEpAlikEJKI7PzTH4NyH+hhf7 hA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2sjapq9u8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:16:50 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNFUsM118772; Mon, 20 May 2019 23:16:49 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2sks1xv84j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:16:49 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNGmNU015206; Mon, 20 May 2019 23:16:48 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:16:48 +0000 Subject: [PATCH 01/12] libxfs: fix attr include mess From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:16:47 -0700 Message-ID: <155839420721.68606.5873005194118073203.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Remove all the userspace xfs_attr shim cruft so that we have one definition of ATTR_* macros so that we can actually use xfs_attr.c routines and include xfs_attr.h without problems. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- include/libxfs.h | 10 +--------- libxfs/libxfs_api_defs.h | 5 +++++ libxfs/libxfs_priv.h | 8 -------- libxfs/xfs_attr.c | 1 + libxfs/xfs_attr_leaf.c | 1 + 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 230bc3e8..dd5fe542 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -211,14 +211,6 @@ libxfs_bmbt_disk_get_all( int libxfs_rtfree_extent(struct xfs_trans *, xfs_rtblock_t, xfs_extlen_t); bool libxfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); -/* XXX: need parts of xfs_attr.h in userspace */ -#define LIBXFS_ATTR_ROOT 0x0002 /* use attrs in root namespace */ -#define LIBXFS_ATTR_SECURE 0x0008 /* use attrs in security namespace */ -#define LIBXFS_ATTR_CREATE 0x0010 /* create, but fail if attr exists */ -#define LIBXFS_ATTR_REPLACE 0x0020 /* set, but fail if attr not exists */ - -int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags); -int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name, - unsigned char *value, int valuelen, int flags); +#include "xfs_attr.h" #endif /* __LIBXFS_H__ */ diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 1150ec93..34bb552d 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -144,4 +144,9 @@ #define xfs_fs_geometry libxfs_fs_geometry #define xfs_init_local_fork libxfs_init_local_fork +#define LIBXFS_ATTR_ROOT ATTR_ROOT +#define LIBXFS_ATTR_SECURE ATTR_SECURE +#define LIBXFS_ATTR_CREATE ATTR_CREATE +#define LIBXFS_ATTR_REPLACE ATTR_REPLACE + #endif /* __LIBXFS_API_DEFS_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index d668a157..f60bff06 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -104,14 +104,6 @@ extern char *progname; */ #define PTR_FMT "%p" -/* XXX: need to push these out to make LIBXFS_ATTR defines */ -#define ATTR_ROOT 0x0002 -#define ATTR_SECURE 0x0008 -#define ATTR_CREATE 0x0010 -#define ATTR_REPLACE 0x0020 -#define ATTR_KERNOTIME 0 -#define ATTR_KERNOVAL 0 - #define XFS_IGET_CREATE 0x1 #define XFS_IGET_UNTRUSTED 0x2 diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b8838302..170e64cf 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -20,6 +20,7 @@ #include "xfs_trans.h" #include "xfs_bmap.h" #include "xfs_bmap_btree.h" +#include "xfs_attr.h" #include "xfs_attr_leaf.h" #include "xfs_attr_remote.h" #include "xfs_trans_space.h" diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index 679c7d0d..1027ca01 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -21,6 +21,7 @@ #include "xfs_bmap.h" #include "xfs_attr_sf.h" #include "xfs_attr_remote.h" +#include "xfs_attr.h" #include "xfs_attr_leaf.h" #include "xfs_trace.h" #include "xfs_cksum.h" From patchwork Mon May 20 23:16:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19C531390 for ; Mon, 20 May 2019 23:17:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 089012015F for ; Mon, 20 May 2019 23:17:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F11A128896; Mon, 20 May 2019 23:16:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 A86D62015F for ; Mon, 20 May 2019 23:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbfETXQ7 (ORCPT ); Mon, 20 May 2019 19:16:59 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:36684 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXQ7 (ORCPT ); Mon, 20 May 2019 19:16:59 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDd3l149416; Mon, 20 May 2019 23:16:56 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-2018-07-02; bh=U6aZPRA1tcsHj/SJco3N1TpoUoLMGsBC0uwqQ1AWdH4=; b=3/nFtTDiDX/r2tyAvA5TTFCoq5DMEq02yYflYIG2I+rb8HLp8dBt+XrIX+FISTQD0MQd iiulcql4TdaaldLx9bV5D1P6YH/CFo58lXWwI7CNG79GrFmkOi2Em382lK8JC+gdn1Wd SQyTj7WZRxcEuxa3o0Ct3M3ikuPWEsmxZ/fk7HN2H7f3TO7jiUZUlsKQZgT1P9Vbf7qg XQqTkQ7XDYBKDOSJaZ+NSJMKRLrGc/WBxRqEAJ+zh8kXnsqjwlGakMcaCclJGb2NOxMM mkU4IEcw39PMohxpZdV/XEoRs0iui/Svaq4NaxWZVQAIQAP0PjAtqA5OAh2GLuRXooDn 1w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:16:56 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNFSqc118605; Mon, 20 May 2019 23:16:56 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2sks1xv86g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:16:56 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4KNGtk6021844; Mon, 20 May 2019 23:16:55 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:16:54 +0000 Subject: [PATCH 02/12] libxfs: set m_finobt_nores when initializing library From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:16:53 -0700 Message-ID: <155839421389.68606.12844536360638603273.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 We don't generally set up per-ag reservations in userspace, so set this flag to true to force transactions to set up block reservations. This isn't necessary for userspace (since we never touch the finobt) but we shouldn't leave a logic bomb. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- libxfs/init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libxfs/init.c b/libxfs/init.c index 2f6decc8..1baccb31 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -640,6 +640,7 @@ libxfs_mount( libxfs_buftarg_init(mp, dev, logdev, rtdev); + mp->m_finobt_nores = true; mp->m_flags = (LIBXFS_MOUNT_32BITINODES|LIBXFS_MOUNT_32BITINOOPT); mp->m_sb = *sb; INIT_RADIX_TREE(&mp->m_perag_tree, GFP_KERNEL); From patchwork Mon May 20 23:17:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A25E1390 for ; Mon, 20 May 2019 23:17:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37D412015F for ; Mon, 20 May 2019 23:17:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C6A8288A7; Mon, 20 May 2019 23:17:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 13F442015F for ; Mon, 20 May 2019 23:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbfETXRH (ORCPT ); Mon, 20 May 2019 19:17:07 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:36766 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRH (ORCPT ); Mon, 20 May 2019 19:17:07 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNE1fu150118; Mon, 20 May 2019 23:17:03 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-2018-07-02; bh=YFq9GM3B2H1//oumm8c4bhbgej2jn5cSOh/Xuc2h0zQ=; b=cWkWrioadfBuZ2GJVXbtWP9dzVKMoFv+Dtx26S6s7NH7+jgY9fyWwijZWM3Zf4tMUwTs Bx9/Ra6QXTeqnuUWAXrq9hIkw/izTOdxMM9rMNlqV5JqIoU80qjObsWD/wCpuLuQIYnw H7lvI0od+7pCv+ouHuPZyjx8WBHHs/eL2Ktqxoph+7Pmtmv6i682Irx99VTez5JWbWDR jqQRnr8GAdzhrLTTu01eySG001H/o7XZZpshYaACzQnnMkHKuYqy+l5UkMSO2I7dHQhy 0hFHvb55gGbkpV6yTRdq4j7HaoCdIwa5fFPPAZhgd/Vo5Coh6J18YynG6Jzjy8I6wZPN aQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:03 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNFe1g060710; Mon, 20 May 2019 23:17:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2sks1j48kj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:02 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNH1jY015359; Mon, 20 May 2019 23:17:01 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:00 +0000 Subject: [PATCH 03/12] libxfs: refactor online geometry queries From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:00 -0700 Message-ID: <155839422001.68606.12869125311562128404.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Refactor all the open-coded XFS_IOC_FSGEOMETRY queries into a single helper that we can use to standardize behaviors across mixed xfslibs versions. This is the prelude to introducing a new FSGEOMETRY version in 5.2 and needing to fix the (relatively few) client programs. Signed-off-by: Darrick J. Wong --- Makefile | 9 +++++---- fsr/xfs_fsr.c | 25 +++---------------------- growfs/Makefile | 5 +++-- growfs/xfs_growfs.c | 24 ++++++++---------------- include/linux.h | 5 +++++ io/bmap.c | 2 +- io/fsmap.c | 2 +- io/open.c | 2 +- io/stat.c | 4 ++-- libhandle/Makefile | 2 +- libhandle/ioctl.c | 26 ++++++++++++++++++++++++++ quota/Makefile | 4 ++-- quota/free.c | 5 ++--- repair/Makefile | 6 +++--- repair/xfs_repair.c | 4 ++-- rtcp/Makefile | 3 +++ rtcp/xfs_rtcp.c | 6 +++--- scrub/phase1.c | 2 +- spaceman/Makefile | 4 ++-- spaceman/file.c | 2 +- spaceman/info.c | 24 +++++++----------------- 21 files changed, 82 insertions(+), 84 deletions(-) create mode 100644 libhandle/ioctl.c diff --git a/Makefile b/Makefile index 9204bed8..b72a9209 100644 --- a/Makefile +++ b/Makefile @@ -99,14 +99,15 @@ $(LIB_SUBDIRS) $(TOOL_SUBDIRS): include libfrog $(DLIB_SUBDIRS) $(TOOL_SUBDIRS): libxfs db logprint: libxlog fsr: libhandle -growfs: libxcmd +growfs: libxcmd libhandle io: libxcmd libhandle -quota: libxcmd -repair: libxlog libxcmd +quota: libxcmd libhandle +repair: libxlog libxcmd libhandle copy: libxlog mkfs: libxcmd -spaceman: libxcmd +spaceman: libxcmd libhandle scrub: libhandle libxcmd +rtcp: libhandle ifeq ($(HAVE_BUILDDEFS), yes) include $(BUILDRULES) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index fef6262c..968d133c 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -83,9 +83,8 @@ int cmp(const void *, const void *); static void tmp_init(char *mnt); static char * tmp_next(char *mnt); static void tmp_close(char *mnt); -int xfs_getgeom(int , xfs_fsop_geom_v1_t * ); -static xfs_fsop_geom_v1_t fsgeom; /* geometry of active mounted system */ +static struct xfs_fsop_geom fsgeom; /* geometry of active mounted system */ #define NMOUNT 64 static int numfs; @@ -102,12 +101,6 @@ static int nfrags = 0; /* Debug option: Coerse into specific number * of extents */ static int openopts = O_CREAT|O_EXCL|O_RDWR|O_DIRECT; -static int -xfs_fsgeometry(int fd, xfs_fsop_geom_v1_t *geom) -{ - return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, geom); -} - static int xfs_bulkstat_single(int fd, xfs_ino_t *lastip, xfs_bstat_t *ubuffer) { @@ -630,7 +623,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) return -1; } - if (xfs_getgeom(fsfd, &fsgeom) < 0 ) { + if (xfs_fsgeometry(fsfd, &fsgeom) < 0 ) { fsrprintf(_("Skipping %s: could not get XFS geometry\n"), mntdir); close(fsfd); @@ -772,7 +765,7 @@ fsrfile(char *fname, xfs_ino_t ino) } /* Get the fs geometry */ - if (xfs_getgeom(fsfd, &fsgeom) < 0 ) { + if (xfs_fsgeometry(fsfd, &fsgeom) < 0 ) { fsrprintf(_("Unable to get geom on fs for: %s\n"), fname); goto out; } @@ -1612,18 +1605,6 @@ getnextents(int fd) return(nextents); } -/* - * Get the fs geometry - */ -int -xfs_getgeom(int fd, xfs_fsop_geom_v1_t * fsgeom) -{ - if (xfs_fsgeometry(fd, fsgeom) < 0) { - return -1; - } - return 0; -} - /* * Get xfs realtime space information */ diff --git a/growfs/Makefile b/growfs/Makefile index 4104cc0d..e0964587 100644 --- a/growfs/Makefile +++ b/growfs/Makefile @@ -9,7 +9,8 @@ LTCOMMAND = xfs_growfs CFILES = xfs_growfs.c -LLDLIBS = $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) +LLDLIBS = $(LIBHANDLE) $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) \ + $(LIBPTHREAD) ifeq ($(ENABLE_READLINE),yes) LLDLIBS += $(LIBREADLINE) $(LIBTERMCAP) endif @@ -18,7 +19,7 @@ ifeq ($(ENABLE_EDITLINE),yes) LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP) endif -LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBHANDLE) $(LIBXFS) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND) diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c index 2af7e5ba..392e4a00 100644 --- a/growfs/xfs_growfs.c +++ b/growfs/xfs_growfs.c @@ -165,22 +165,14 @@ main(int argc, char **argv) } /* get the current filesystem size & geometry */ - if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY, &geo) < 0) { - /* - * OK, new xfsctl barfed - back off and try earlier version - * as we're probably running an older kernel version. - * Only field added in the v2 geometry xfsctl is "logsunit" - * so we'll zero that out for later display (as zero). - */ - geo.logsunit = 0; - if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY_V1, &geo) < 0) { - fprintf(stderr, _( - "%s: cannot determine geometry of filesystem" - " mounted at %s: %s\n"), - progname, fname, strerror(errno)); - exit(1); - } + if (xfs_fsgeometry(ffd, &geo)) { + fprintf(stderr, _( + "%s: cannot determine geometry of filesystem" + " mounted at %s: %s\n"), + progname, fname, strerror(errno)); + exit(1); } + isint = geo.logstart > 0; /* @@ -359,7 +351,7 @@ main(int argc, char **argv) } } - if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY_V1, &ngeo) < 0) { + if (xfs_fsgeometry(ffd, &ngeo)) { fprintf(stderr, _("%s: XFS_IOC_FSGEOMETRY xfsctl failed: %s\n"), progname, strerror(errno)); exit(1); diff --git a/include/linux.h b/include/linux.h index 8f3c32b0..5fe33117 100644 --- a/include/linux.h +++ b/include/linux.h @@ -323,4 +323,9 @@ fsmap_advance( #include #endif /* HAVE_MAP_SYNC */ +/* ioctl wrappers */ + +struct xfs_fsop_geom; +int xfs_fsgeometry(int fd, struct xfs_fsop_geom *fsgeo); + #endif /* __XFS_LINUX_H__ */ diff --git a/io/bmap.c b/io/bmap.c index d408826a..9103fe72 100644 --- a/io/bmap.c +++ b/io/bmap.c @@ -105,7 +105,7 @@ bmap_f( bmv_iflags &= ~(BMV_IF_PREALLOC|BMV_IF_NO_DMAPI_READ); if (vflag) { - c = xfsctl(file->name, file->fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo); + c = xfs_fsgeometry(file->fd, &fsgeo); if (c < 0) { fprintf(stderr, _("%s: can't get geometry [\"%s\"]: %s\n"), diff --git a/io/fsmap.c b/io/fsmap.c index 477c36fc..9c310bd8 100644 --- a/io/fsmap.c +++ b/io/fsmap.c @@ -447,7 +447,7 @@ fsmap_f( } if (vflag) { - c = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &fsgeo); + c = xfs_fsgeometry(file->fd, &fsgeo); if (c < 0) { fprintf(stderr, _("%s: can't get geometry [\"%s\"]: %s\n"), diff --git a/io/open.c b/io/open.c index a406ea54..b6aacb83 100644 --- a/io/open.c +++ b/io/open.c @@ -118,7 +118,7 @@ openfile( if (flags & IO_PATH) { /* Can't call ioctl() on O_PATH fds */ memset(geom, 0, sizeof(*geom)); - } else if (xfsctl(path, fd, XFS_IOC_FSGEOMETRY, geom) < 0) { + } else if (xfs_fsgeometry(fd, geom)) { perror("XFS_IOC_FSGEOMETRY"); close(fd); return -1; diff --git a/io/stat.c b/io/stat.c index 37c0b2e8..5399ed4f 100644 --- a/io/stat.c +++ b/io/stat.c @@ -194,8 +194,8 @@ statfs_f( } if (file->flags & IO_FOREIGN) return 0; - if ((xfsctl(file->name, file->fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo)) < 0) { - perror("XFS_IOC_FSGEOMETRY_V1"); + if (xfs_fsgeometry(file->fd, &fsgeo)) { + perror("XFS_IOC_FSGEOMETRY"); } else { printf(_("geom.bsize = %u\n"), fsgeo.blocksize); printf(_("geom.agcount = %u\n"), fsgeo.agcount); diff --git a/libhandle/Makefile b/libhandle/Makefile index f297a59e..a358549c 100644 --- a/libhandle/Makefile +++ b/libhandle/Makefile @@ -12,7 +12,7 @@ LT_AGE = 0 LTLDFLAGS += -Wl,--version-script,libhandle.sym -CFILES = handle.c jdm.c +CFILES = handle.c ioctl.c jdm.c LSRCFILES = libhandle.sym default: ltdepend $(LTLIBRARY) diff --git a/libhandle/ioctl.c b/libhandle/ioctl.c new file mode 100644 index 00000000..5c954bd0 --- /dev/null +++ b/libhandle/ioctl.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: LGPL-2.1 +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "xfs.h" +#include + +/* Wrappers for Linux ioctls. */ + +/* Try to obtain the xfs geometry. */ +int +xfs_fsgeometry( + int fd, + struct xfs_fsop_geom *fsgeo) +{ + int ret; + + memset(fsgeo, 0, sizeof(*fsgeo)); + + ret = ioctl(fd, XFS_IOC_FSGEOMETRY, fsgeo); + if (!ret) + return 0; + + return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, fsgeo); +} diff --git a/quota/Makefile b/quota/Makefile index 384f023a..db6174b9 100644 --- a/quota/Makefile +++ b/quota/Makefile @@ -10,8 +10,8 @@ HFILES = init.h quota.h CFILES = init.c util.c \ edit.c free.c linux.c path.c project.c quot.c quota.c report.c state.c -LLDLIBS = $(LIBXCMD) $(LIBFROG) -LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) +LLDLIBS = $(LIBHANDLE) $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBHANDLE) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes) diff --git a/quota/free.c b/quota/free.c index 1d13006e..e95af8eb 100644 --- a/quota/free.c +++ b/quota/free.c @@ -67,9 +67,8 @@ mount_free_space_data( } if (!(mount->fs_flags & FS_FOREIGN)) { - if ((xfsctl(mount->fs_dir, fd, XFS_IOC_FSGEOMETRY_V1, - &fsgeo)) < 0) { - perror("XFS_IOC_FSGEOMETRY_V1"); + if (xfs_fsgeometry(fd, &fsgeo)) { + perror("XFS_IOC_FSGEOMETRY"); close(fd); return 0; } diff --git a/repair/Makefile b/repair/Makefile index 0964499a..a5cab8f1 100644 --- a/repair/Makefile +++ b/repair/Makefile @@ -20,9 +20,9 @@ CFILES = agheader.c attr_repair.c avl.c bmap.c btree.c \ progress.c prefetch.c rmap.c rt.c sb.c scan.c slab.c threads.c \ versions.c xfs_repair.c -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) \ - $(LIBPTHREAD) $(LIBBLKID) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) +LLDLIBS = $(LIBHANDLE) $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) $(LIBUUID) \ + $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) +LTDEPENDENCIES = $(LIBHANDLE) $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 9657503f..a569b958 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -636,11 +636,11 @@ check_fs_vs_host_sectsize( { int fd; long old_flags; - struct xfs_fsop_geom_v1 geom = { 0 }; + struct xfs_fsop_geom geom = { 0 }; fd = libxfs_device_to_fd(x.ddev); - if (ioctl(fd, XFS_IOC_FSGEOMETRY_V1, &geom) < 0) { + if (xfs_fsgeometry(fd, &geom)) { do_log(_("Cannot get host filesystem geometry.\n" "Repair may fail if there is a sector size mismatch between\n" "the image and the host filesystem.\n")); diff --git a/rtcp/Makefile b/rtcp/Makefile index 808b5378..e51ba165 100644 --- a/rtcp/Makefile +++ b/rtcp/Makefile @@ -9,6 +9,9 @@ LTCOMMAND = xfs_rtcp CFILES = xfs_rtcp.c LLDFLAGS = -static +LLDLIBS = $(LIBHANDLE) +LTDEPENDENCIES = $(LIBHANDLE) + default: depend $(LTCOMMAND) include $(BUILDRULES) diff --git a/rtcp/xfs_rtcp.c b/rtcp/xfs_rtcp.c index f928a86a..3a9e9a2f 100644 --- a/rtcp/xfs_rtcp.c +++ b/rtcp/xfs_rtcp.c @@ -368,8 +368,8 @@ rtcp( char *source, char *target, int fextsize) int xfsrtextsize( char *path) { - int fd, rval, rtextsize; - xfs_fsop_geom_v1_t geo; + struct xfs_fsop_geom geo; + int fd, rval, rtextsize; fd = open( path, O_RDONLY ); if ( fd < 0 ) { @@ -377,7 +377,7 @@ xfsrtextsize( char *path) progname, path, strerror(errno)); return -1; } - rval = xfsctl( path, fd, XFS_IOC_FSGEOMETRY_V1, &geo ); + rval = xfs_fsgeometry(fd, &geo); close(fd); if ( rval < 0 ) return -1; diff --git a/scrub/phase1.c b/scrub/phase1.c index 04a5f4a9..a4e9c9af 100644 --- a/scrub/phase1.c +++ b/scrub/phase1.c @@ -129,7 +129,7 @@ _("Does not appear to be an XFS filesystem!")); } /* Retrieve XFS geometry. */ - error = ioctl(ctx->mnt_fd, XFS_IOC_FSGEOMETRY, &ctx->geo); + error = xfs_fsgeometry(ctx->mnt_fd, &ctx->geo); if (error) { str_errno(ctx, ctx->mntpoint); return false; diff --git a/spaceman/Makefile b/spaceman/Makefile index b1c1b16d..69c70531 100644 --- a/spaceman/Makefile +++ b/spaceman/Makefile @@ -10,8 +10,8 @@ HFILES = init.h space.h CFILES = info.c init.c file.c prealloc.c trim.c LSRCFILES = xfs_info.sh -LLDLIBS = $(LIBXCMD) $(LIBFROG) -LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) +LLDLIBS = $(LIBHANDLE) $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBHANDLE) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes) diff --git a/spaceman/file.c b/spaceman/file.c index 98549517..d2acf5db 100644 --- a/spaceman/file.c +++ b/spaceman/file.c @@ -56,7 +56,7 @@ openfile( return -1; } - if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) { + if (xfs_fsgeometry(fd, geom)) { if (errno == ENOTTY) fprintf(stderr, _("%s: Not on a mounted XFS filesystem.\n"), diff --git a/spaceman/info.c b/spaceman/info.c index 01d0744a..bcefdcb8 100644 --- a/spaceman/info.c +++ b/spaceman/info.c @@ -37,24 +37,14 @@ info_f( } /* get the current filesystem size & geometry */ - error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo); + error = xfs_fsgeometry(file->fd, &geo); if (error) { - /* - * OK, new xfsctl barfed - back off and try earlier version - * as we're probably running an older kernel version. - * Only field added in the v2 geometry xfsctl is "logsunit" - * so we'll zero that out for later display (as zero). - */ - geo.logsunit = 0; - error = ioctl(file->fd, XFS_IOC_FSGEOMETRY_V1, &geo); - if (error) { - fprintf(stderr, _( - "%s: cannot determine geometry of filesystem" - " mounted at %s: %s\n"), - progname, file->name, strerror(errno)); - exitcode = 1; - return 0; - } + fprintf(stderr, _( + "%s: cannot determine geometry of filesystem" + " mounted at %s: %s\n"), + progname, file->name, strerror(errno)); + exitcode = 1; + return 0; } xfs_report_geom(&geo, file->fs_path.fs_name, file->fs_path.fs_log, From patchwork Mon May 20 23:17:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 816CD1390 for ; Mon, 20 May 2019 23:17:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CEB02015F for ; Mon, 20 May 2019 23:17:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6138C28896; Mon, 20 May 2019 23:17: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 96F802015F for ; Mon, 20 May 2019 23:17:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbfETXRN (ORCPT ); Mon, 20 May 2019 19:17:13 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:36868 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRN (ORCPT ); Mon, 20 May 2019 19:17:13 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDaih149364; Mon, 20 May 2019 23:17:10 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-2018-07-02; bh=ZzSmHWDMVU++D7Y96AFrL2rVNp05z2ym72pp1WK3NNM=; b=aeUfePQ9ORrpFqst0paOMWl/zSg0PtYx3QDh1aLoK43hpkIALtDuIgkZXawJxkaHvSMQ jKtF6I7LUKXyWvrtv9JyOtLCN/fk8UfQAk0wNykANyppArOjJt96Et1de2FjgZw10oRd isQuGM0aOChg1HyBJa+C1luE0KA3QVSflJaPSgJFpU3vBziIRwWwZO2UrAddt+q52xTk 9lRSkHh8aRCfWtqbXS0MNEImoJP74G+W2pnzHDH/VnFUFoLHosM6O+3+CZvjYCIQOGML 8wAN2Oy2VXaHxlw0apWmOGNs/op8xRJSm6JaZdRs1cTAtKiHNwneUx6+nNp9BM15Sf83 Qw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:09 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNFeBZ060653; Mon, 20 May 2019 23:17:09 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2sks1j48n6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:08 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4KNH7uF029002; Mon, 20 May 2019 23:17:07 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:07 +0000 Subject: [PATCH 04/12] libxfs: refactor open-coded bulkstat calls From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:06 -0700 Message-ID: <155839422634.68606.5333502357929240836.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Refactor the BULKSTAT_SINGLE and BULKSTAT ioctl callsites into helper functions. Signed-off-by: Darrick J. Wong --- fsr/xfs_fsr.c | 33 ++------------------------- include/linux.h | 5 ++++ io/open.c | 66 +++++++++++++++++++++++++---------------------------- io/swapext.c | 17 +------------- libhandle/ioctl.c | 38 +++++++++++++++++++++++++++++++ quota/quot.c | 16 ++++--------- scrub/inodes.c | 27 ++++++---------------- 7 files changed, 90 insertions(+), 112 deletions(-) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 968d133c..bc5cf9ed 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -101,31 +101,6 @@ static int nfrags = 0; /* Debug option: Coerse into specific number * of extents */ static int openopts = O_CREAT|O_EXCL|O_RDWR|O_DIRECT; -static int -xfs_bulkstat_single(int fd, xfs_ino_t *lastip, xfs_bstat_t *ubuffer) -{ - xfs_fsop_bulkreq_t bulkreq; - - bulkreq.lastip = (__u64 *)lastip; - bulkreq.icount = 1; - bulkreq.ubuffer = ubuffer; - bulkreq.ocount = NULL; - return ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bulkreq); -} - -static int -xfs_bulkstat(int fd, xfs_ino_t *lastip, int icount, - xfs_bstat_t *ubuffer, __s32 *ocount) -{ - xfs_fsop_bulkreq_t bulkreq; - - bulkreq.lastip = (__u64 *)lastip; - bulkreq.icount = icount; - bulkreq.ubuffer = ubuffer; - bulkreq.ocount = ocount; - return ioctl(fd, XFS_IOC_FSBULKSTAT, &bulkreq); -} - static int xfs_swapext(int fd, xfs_swapext_t *sx) { @@ -599,7 +574,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) int fsfd, fd; int count = 0; int ret; - __s32 buflenout; + uint32_t buflenout; xfs_bstat_t buf[GRABSZ]; char fname[64]; char *tname; @@ -751,7 +726,7 @@ fsrfile(char *fname, xfs_ino_t ino) goto out; } - if ((xfs_bulkstat_single(fsfd, &ino, &statbuf)) < 0) { + if ((xfs_bulkstat_single(fsfd, ino, &statbuf)) < 0) { fsrprintf(_("unable to get bstat on %s: %s\n"), fname, strerror(errno)); goto out; @@ -980,7 +955,6 @@ fsr_setup_attr_fork( i = 0; do { xfs_bstat_t tbstat; - xfs_ino_t ino; char name[64]; /* @@ -988,8 +962,7 @@ fsr_setup_attr_fork( * this to compare against the target and determine what we * need to do. */ - ino = tstatbuf.st_ino; - if ((xfs_bulkstat_single(tfd, &ino, &tbstat)) < 0) { + if ((xfs_bulkstat_single(tfd, tstatbuf.st_ino, &tbstat)) < 0) { fsrprintf(_("unable to get bstat on temp file: %s\n"), strerror(errno)); return -1; diff --git a/include/linux.h b/include/linux.h index 5fe33117..98750e18 100644 --- a/include/linux.h +++ b/include/linux.h @@ -328,4 +328,9 @@ fsmap_advance( struct xfs_fsop_geom; int xfs_fsgeometry(int fd, struct xfs_fsop_geom *fsgeo); +struct xfs_bstat; +int xfs_bulkstat_single(int fd, uint64_t ino, struct xfs_bstat *ubuffer); +int xfs_bulkstat(int fd, uint64_t *lastino, uint32_t icount, + struct xfs_bstat *ubuffer, uint32_t *ocount); + #endif /* __XFS_LINUX_H__ */ diff --git a/io/open.c b/io/open.c index b6aacb83..6ceff18d 100644 --- a/io/open.c +++ b/io/open.c @@ -712,19 +712,18 @@ get_last_inode(void) static int inode_f( - int argc, - char **argv) + int argc, + char **argv) { - __s32 count = 0; - __u64 result_ino = 0; - __u64 userino = NULLFSINO; + struct xfs_bstat bstat; + uint32_t count = 0; + uint64_t result_ino = 0; + uint64_t userino = NULLFSINO; char *p; int c; int verbose = 0; int ret_next = 0; - int cmd = 0; - struct xfs_fsop_bulkreq bulkreq; - struct xfs_bstat bstat; + int ret; while ((c = getopt(argc, argv, "nv")) != EOF) { switch (c) { @@ -766,35 +765,32 @@ inode_f( exitcode = 1; return 0; } + } else if (ret_next) { + /* get next inode */ + ret = xfs_bulkstat(file->fd, &userino, 1, &bstat, &count); + if (ret) { + perror("xfsctl"); + exitcode = 1; + return 0; + } + + /* The next inode in use, or 0 if none */ + if (count) + result_ino = bstat.bs_ino; + else + result_ino = 0; } else { - if (ret_next) /* get next inode */ - cmd = XFS_IOC_FSBULKSTAT; - else /* get this inode */ - cmd = XFS_IOC_FSBULKSTAT_SINGLE; - - bulkreq.lastip = &userino; - bulkreq.icount = 1; - bulkreq.ubuffer = &bstat; - bulkreq.ocount = &count; - - if (xfsctl(file->name, file->fd, cmd, &bulkreq)) { - if (!ret_next && errno == EINVAL) { - /* Not in use */ - result_ino = 0; - } else { - perror("xfsctl"); - exitcode = 1; - return 0; - } - } else if (ret_next) { - /* The next inode in use, or 0 if none */ - if (*bulkreq.ocount) - result_ino = bstat.bs_ino; - else - result_ino = 0; + /* get this inode */ + ret = xfs_bulkstat_single(file->fd, userino, &bstat); + if (ret && errno == EINVAL) { + /* Not in use */ + result_ino = 0; + } else if (ret) { + perror("bulkstat_single"); + exitcode = 1; + return 0; } else { - /* The inode we asked about */ - result_ino = userino; + result_ino = bstat.bs_ino; } } diff --git a/io/swapext.c b/io/swapext.c index d360c221..8b1b1b18 100644 --- a/io/swapext.c +++ b/io/swapext.c @@ -20,21 +20,6 @@ swapext_help(void) "\n")); } -static int -xfs_bulkstat_single( - int fd, - xfs_ino_t *lastip, - struct xfs_bstat *ubuffer) -{ - struct xfs_fsop_bulkreq bulkreq; - - bulkreq.lastip = (__u64 *)lastip; - bulkreq.icount = 1; - bulkreq.ubuffer = ubuffer; - bulkreq.ocount = NULL; - return ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bulkreq); -} - static int swapext_f( int argc, @@ -60,7 +45,7 @@ swapext_f( goto out; } - error = xfs_bulkstat_single(file->fd, &stat.st_ino, &sx.sx_stat); + error = xfs_bulkstat_single(file->fd, stat.st_ino, &sx.sx_stat); if (error) { perror("bulkstat"); goto out; diff --git a/libhandle/ioctl.c b/libhandle/ioctl.c index 5c954bd0..a4676fea 100644 --- a/libhandle/ioctl.c +++ b/libhandle/ioctl.c @@ -24,3 +24,41 @@ xfs_fsgeometry( return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, fsgeo); } + +/* Bulkstat a single inode. */ +int +xfs_bulkstat_single( + int fd, + uint64_t ino, + struct xfs_bstat *ubuffer) +{ + __u64 i = ino; + struct xfs_fsop_bulkreq bulkreq = { + .lastip = &i, + .icount = 1, + .ubuffer = ubuffer, + .ocount = NULL, + }; + + return ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bulkreq); +} + +/* Bulkstat a bunch of inodes. */ +int +xfs_bulkstat( + int fd, + uint64_t *lastino, + uint32_t icount, + struct xfs_bstat *ubuffer, + uint32_t *ocount) +{ + struct xfs_fsop_bulkreq bulkreq = { + .lastip = (__u64 *)lastino, + .icount = icount, + .ubuffer = ubuffer, + .ocount = (__s32 *)ocount, + }; + + return ioctl(fd, XFS_IOC_FSBULKSTAT, &bulkreq); +} + diff --git a/quota/quot.c b/quota/quot.c index d60cf4a8..789e4b40 100644 --- a/quota/quot.c +++ b/quota/quot.c @@ -124,12 +124,11 @@ quot_bulkstat_add( static void quot_bulkstat_mount( char *fsdir, - uint flags) + unsigned int flags) { - xfs_fsop_bulkreq_t bulkreq; - xfs_bstat_t *buf; - __u64 last = 0; - __s32 count; + struct xfs_bstat *buf; + uint64_t last = 0; + uint32_t count; int i, sts, fsfd; du_t **dp; @@ -158,12 +157,7 @@ quot_bulkstat_mount( return; } - bulkreq.lastip = &last; - bulkreq.icount = NBSTAT; - bulkreq.ubuffer = buf; - bulkreq.ocount = &count; - - while ((sts = xfsctl(fsdir, fsfd, XFS_IOC_FSBULKSTAT, &bulkreq)) == 0) { + while ((sts = xfs_bulkstat(fsfd, &last, NBSTAT, buf, &count)) == 0) { if (count == 0) break; for (i = 0; i < count; i++) diff --git a/scrub/inodes.c b/scrub/inodes.c index 442a5978..702b7d50 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -50,17 +50,10 @@ xfs_iterate_inodes_range_check( struct xfs_inogrp *inogrp, struct xfs_bstat *bstat) { - struct xfs_fsop_bulkreq onereq = {NULL}; struct xfs_bstat *bs; - __u64 oneino; - __s32 onelen = 0; int i; int error; - onereq.lastip = &oneino; - onereq.icount = 1; - onereq.ocount = &onelen; - for (i = 0, bs = bstat; i < XFS_INODES_PER_CHUNK; i++) { if (!(inogrp->xi_allocmask & (1ULL << i))) continue; @@ -70,10 +63,8 @@ xfs_iterate_inodes_range_check( } /* Load the one inode. */ - oneino = inogrp->xi_startino + i; - onereq.ubuffer = bs; - error = ioctl(ctx->mnt_fd, XFS_IOC_FSBULKSTAT_SINGLE, - &onereq); + error = xfs_bulkstat_single(ctx->mnt_fd, + inogrp->xi_startino + i, bs); if (error || bs->bs_ino != inogrp->xi_startino + i) { memset(bs, 0, sizeof(struct xfs_bstat)); bs->bs_ino = inogrp->xi_startino + i; @@ -99,7 +90,6 @@ xfs_iterate_inodes_range( void *arg) { struct xfs_fsop_bulkreq igrpreq = {NULL}; - struct xfs_fsop_bulkreq bulkreq = {NULL}; struct xfs_handle handle; struct xfs_inogrp inogrp; struct xfs_bstat bstat[XFS_INODES_PER_CHUNK]; @@ -107,8 +97,8 @@ xfs_iterate_inodes_range( char buf[DESCR_BUFSZ]; struct xfs_bstat *bs; __u64 igrp_ino; - __u64 ino; - __s32 bulklen = 0; + uint64_t ino; + uint32_t bulklen = 0; __s32 igrplen = 0; bool moveon = true; int i; @@ -117,10 +107,6 @@ xfs_iterate_inodes_range( memset(bstat, 0, XFS_INODES_PER_CHUNK * sizeof(struct xfs_bstat)); - bulkreq.lastip = &ino; - bulkreq.icount = XFS_INODES_PER_CHUNK; - bulkreq.ubuffer = &bstat; - bulkreq.ocount = &bulklen; igrpreq.lastip = &igrp_ino; igrpreq.icount = 1; @@ -138,14 +124,15 @@ xfs_iterate_inodes_range( while (!error && igrplen) { /* Load the inodes. */ ino = inogrp.xi_startino - 1; - bulkreq.icount = inogrp.xi_alloccount; + /* * We can have totally empty inode chunks on filesystems where * there are more than 64 inodes per block. Skip these. */ if (inogrp.xi_alloccount == 0) goto igrp_retry; - error = ioctl(ctx->mnt_fd, XFS_IOC_FSBULKSTAT, &bulkreq); + error = xfs_bulkstat(ctx->mnt_fd, &ino, inogrp.xi_alloccount, + bstat, &bulklen); if (error) str_info(ctx, descr, "%s", strerror_r(errno, buf, DESCR_BUFSZ)); From patchwork Mon May 20 23:17:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFF9A112C for ; Mon, 20 May 2019 23:17:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DBB52015F for ; Mon, 20 May 2019 23:17:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91FD5288A7; Mon, 20 May 2019 23:17:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 ED6AD2015F for ; Mon, 20 May 2019 23:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbfETXRS (ORCPT ); Mon, 20 May 2019 19:17:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38342 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRS (ORCPT ); Mon, 20 May 2019 19:17:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDs4N149704; Mon, 20 May 2019 23:17:16 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-2018-07-02; bh=8yKakjfK3gWAxPuYmT3iJtyk3tBiuslykGrzqoF6Xd0=; b=yk98uq9dmZrva9kf8pUq0KgSmdFBOysmpttnlxziNW7vzIOme//NjjO5hXz3mmXQZips AcIc7YaMq6GKtJHUJ9cXninviD++FljaPv/CVf3OcDBfdTofAbLJDmU/GtY2eyWCmpZi E/KF3pmCzxSfnBAxN+ql8jAImxniniS7NB17HFHfEVv0bgwUJaY/g62nldR3mRHfGw9H jUDXnNXjW92T0H+3y7SfrNw/4HUyxIQvT+Z1i7u2PmyCI1syV+HzChJ9V0ZAq8Jz1LJ2 lkQKy5mfP5a0YqaVtWUJ8TN3av6UTse0Wb0l45cHEo1Vp1MrQvobL/g/0+T6hPuyuiGR pw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2sjapq9uab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNFTFX118663; Mon, 20 May 2019 23:17:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2sks1xv8e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:15 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNHExt007855; Mon, 20 May 2019 23:17:14 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:13 +0000 Subject: [PATCH 05/12] libxfs: refactor open-coded INUMBERS calls From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:12 -0700 Message-ID: <155839423260.68606.10599769594679056156.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Refactor all the INUMBERS ioctl callsites into helper functions. Signed-off-by: Darrick J. Wong --- include/linux.h | 4 ++++ io/imap.c | 30 +++++++++++++----------------- io/open.c | 19 +++++++------------ libhandle/ioctl.c | 18 ++++++++++++++++++ scrub/fscounters.c | 17 ++++++----------- scrub/inodes.c | 21 +++++++-------------- 6 files changed, 55 insertions(+), 54 deletions(-) diff --git a/include/linux.h b/include/linux.h index 98750e18..39190e11 100644 --- a/include/linux.h +++ b/include/linux.h @@ -333,4 +333,8 @@ int xfs_bulkstat_single(int fd, uint64_t ino, struct xfs_bstat *ubuffer); int xfs_bulkstat(int fd, uint64_t *lastino, uint32_t icount, struct xfs_bstat *ubuffer, uint32_t *ocount); +struct xfs_inogrp; +int xfs_inumbers(int fd, uint64_t *lastino, uint32_t icount, + struct xfs_inogrp *ubuffer, uint32_t *ocount); + #endif /* __XFS_LINUX_H__ */ diff --git a/io/imap.c b/io/imap.c index fbc8e9e1..49917545 100644 --- a/io/imap.c +++ b/io/imap.c @@ -14,12 +14,12 @@ static cmdinfo_t imap_cmd; static int imap_f(int argc, char **argv) { - int count; - int nent; - int i; - __u64 last = 0; - xfs_inogrp_t *t; - xfs_fsop_bulkreq_t bulkreq; + struct xfs_inogrp *t; + uint64_t last = 0; + uint32_t count; + uint32_t nent; + int i; + int error; if (argc != 2) nent = 1; @@ -30,14 +30,8 @@ imap_f(int argc, char **argv) if (!t) return 0; - bulkreq.lastip = &last; - bulkreq.icount = nent; - bulkreq.ubuffer = (void *)t; - bulkreq.ocount = &count; - - while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) { - if (count == 0) - goto out_free; + while ((error = xfs_inumbers(file->fd, &last, nent, t, &count)) == 0 && + count > 0) { for (i = 0; i < count; i++) { printf(_("ino %10llu count %2d mask %016llx\n"), (unsigned long long)t[i].xi_startino, @@ -45,9 +39,11 @@ imap_f(int argc, char **argv) (unsigned long long)t[i].xi_allocmask); } } - perror("xfsctl(XFS_IOC_FSINUMBERS)"); - exitcode = 1; -out_free: + + if (error) { + perror("xfsctl(XFS_IOC_FSINUMBERS)"); + exitcode = 1; + } free(t); return 0; } diff --git a/io/open.c b/io/open.c index 6ceff18d..11805cd7 100644 --- a/io/open.c +++ b/io/open.c @@ -668,24 +668,19 @@ inode_help(void) "\n")); } +#define IGROUP_NR (1024) static __u64 get_last_inode(void) { - __u64 lastip = 0; - __u64 lastgrp = 0; - __s32 ocount = 0; + uint64_t lastip = 0; + uint32_t lastgrp = 0; + uint32_t ocount = 0; __u64 last_ino; - struct xfs_inogrp igroup[1024]; - struct xfs_fsop_bulkreq bulkreq; - - bulkreq.lastip = &lastip; - bulkreq.ubuffer = &igroup; - bulkreq.icount = sizeof(igroup) / sizeof(struct xfs_inogrp); - bulkreq.ocount = &ocount; + struct xfs_inogrp igroup[IGROUP_NR]; for (;;) { - if (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, - &bulkreq)) { + if (xfs_inumbers(file->fd, &lastip, IGROUP_NR, igroup, + &ocount)) { perror("XFS_IOC_FSINUMBERS"); return 0; } diff --git a/libhandle/ioctl.c b/libhandle/ioctl.c index a4676fea..599fdf3e 100644 --- a/libhandle/ioctl.c +++ b/libhandle/ioctl.c @@ -62,3 +62,21 @@ xfs_bulkstat( return ioctl(fd, XFS_IOC_FSBULKSTAT, &bulkreq); } +/* Query inode allocation bitmask information. */ +int +xfs_inumbers( + int fd, + uint64_t *lastino, + uint32_t icount, + struct xfs_inogrp *ubuffer, + uint32_t *ocount) +{ + struct xfs_fsop_bulkreq bulkreq = { + .lastip = (__u64 *)lastino, + .icount = icount, + .ubuffer = ubuffer, + .ocount = (__s32 *)ocount, + }; + + return ioctl(fd, XFS_IOC_FSINUMBERS, &bulkreq); +} diff --git a/scrub/fscounters.c b/scrub/fscounters.c index 9e93e2a6..13f46e17 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -41,26 +41,21 @@ xfs_count_inodes_range( uint64_t last_ino, uint64_t *count) { - struct xfs_fsop_bulkreq igrpreq = {NULL}; struct xfs_inogrp inogrp; - __u64 igrp_ino; + uint64_t igrp_ino; uint64_t nr = 0; - __s32 igrplen = 0; + uint32_t igrplen = 0; int error; ASSERT(!(first_ino & (XFS_INODES_PER_CHUNK - 1))); ASSERT((last_ino & (XFS_INODES_PER_CHUNK - 1))); - igrpreq.lastip = &igrp_ino; - igrpreq.icount = 1; - igrpreq.ubuffer = &inogrp; - igrpreq.ocount = &igrplen; - igrp_ino = first_ino; - error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq); - while (!error && igrplen && inogrp.xi_startino < last_ino) { + while ((error = xfs_inumbers(ctx->mnt_fd, &igrp_ino, 1, &inogrp, + &igrplen)) == 0 && + igrplen > 0 && + inogrp.xi_startino < last_ino) { nr += inogrp.xi_alloccount; - error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq); } if (error) { diff --git a/scrub/inodes.c b/scrub/inodes.c index 702b7d50..b27edef7 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -89,17 +89,16 @@ xfs_iterate_inodes_range( xfs_inode_iter_fn fn, void *arg) { - struct xfs_fsop_bulkreq igrpreq = {NULL}; struct xfs_handle handle; struct xfs_inogrp inogrp; struct xfs_bstat bstat[XFS_INODES_PER_CHUNK]; char idescr[DESCR_BUFSZ]; char buf[DESCR_BUFSZ]; struct xfs_bstat *bs; - __u64 igrp_ino; + uint64_t igrp_ino; uint64_t ino; uint32_t bulklen = 0; - __s32 igrplen = 0; + uint32_t igrplen = 0; bool moveon = true; int i; int error; @@ -108,11 +107,6 @@ xfs_iterate_inodes_range( memset(bstat, 0, XFS_INODES_PER_CHUNK * sizeof(struct xfs_bstat)); - igrpreq.lastip = &igrp_ino; - igrpreq.icount = 1; - igrpreq.ubuffer = &inogrp; - igrpreq.ocount = &igrplen; - memcpy(&handle.ha_fsid, fshandle, sizeof(handle.ha_fsid)); handle.ha_fid.fid_len = sizeof(xfs_fid_t) - sizeof(handle.ha_fid.fid_len); @@ -120,8 +114,9 @@ xfs_iterate_inodes_range( /* Find the inode chunk & alloc mask */ igrp_ino = first_ino; - error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq); - while (!error && igrplen) { + while ((error = xfs_inumbers(ctx->mnt_fd, &igrp_ino, 1, &inogrp, + &igrplen)) == 0 && + igrplen > 0) { /* Load the inodes. */ ino = inogrp.xi_startino - 1; @@ -130,7 +125,7 @@ xfs_iterate_inodes_range( * there are more than 64 inodes per block. Skip these. */ if (inogrp.xi_alloccount == 0) - goto igrp_retry; + continue; error = xfs_bulkstat(ctx->mnt_fd, &ino, inogrp.xi_alloccount, bstat, &bulklen); if (error) @@ -154,7 +149,7 @@ xfs_iterate_inodes_range( stale_count++; if (stale_count < 30) { igrp_ino = inogrp.xi_startino; - goto igrp_retry; + continue; } snprintf(idescr, DESCR_BUFSZ, "inode %"PRIu64, (uint64_t)bs->bs_ino); @@ -176,8 +171,6 @@ _("Changed too many times during scan; giving up.")); } stale_count = 0; -igrp_retry: - error = ioctl(ctx->mnt_fd, XFS_IOC_FSINUMBERS, &igrpreq); } err: From patchwork Mon May 20 23:17:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73B54112C for ; Mon, 20 May 2019 23:17:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60AB12015F for ; Mon, 20 May 2019 23:17:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5505B288A7; Mon, 20 May 2019 23:17:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 C01822015F for ; Mon, 20 May 2019 23:17:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727077AbfETXRY (ORCPT ); Mon, 20 May 2019 19:17:24 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37032 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRY (ORCPT ); Mon, 20 May 2019 19:17:24 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDnr5149858; Mon, 20 May 2019 23:17:21 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-2018-07-02; bh=1KJ2CefLVeKw/GhgCrQDcVYG7w3gjRxusiQzFTtjv7Y=; b=Q+JVig2kFXSRIaZuJpygQeMhFcSESIJTVkyDOZJdzodsX2ywxUir01/QYEmPwANA4wUa PZBBHyJD6a0BVzlxXE7akrgYSmSmN1y5dbPs/tPQbyTN7MxNIdPEfVuMN6VXn6XEhTsK 4mj2PzDPp6hPIolYSmFwZ6R0VPx0CBf1HZZ467CfZyRTMDHqvayoTwsSqYXDsibV3WsU 6g/gvL+ORQ5VANfgiVoiBTueq+RjdYMZdqIowe0sRUlH2Zdc4CnGwkZr6Y14MqZ0pwCl z21HhzZHaWN7D77lhaKQg9xQ61oQWSMKav0jhspIyUTGBmPXgXE4rFUwbY12d0sODoq+ Qw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5kg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:21 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNGopW074313; Mon, 20 May 2019 23:17:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2skudb28fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:20 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4KNHKLU022060; Mon, 20 May 2019 23:17:20 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:19 +0000 Subject: [PATCH 06/12] misc: remove all use of xfs_fsop_geom_t From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:19 -0700 Message-ID: <155839423901.68606.18360420363137361199.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Remove all the uses of the old xfs_fsop_geom_t typedef. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- growfs/xfs_growfs.c | 4 ++-- io/init.c | 2 +- io/io.h | 6 +++--- io/open.c | 6 +++--- man/man3/xfsctl.3 | 2 +- spaceman/file.c | 4 ++-- spaceman/init.c | 2 +- spaceman/space.h | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c index 392e4a00..ffd82f95 100644 --- a/growfs/xfs_growfs.c +++ b/growfs/xfs_growfs.c @@ -44,7 +44,7 @@ main(int argc, char **argv) int error; /* we have hit an error */ long esize; /* new rt extent size */ int ffd; /* mount point file descriptor */ - xfs_fsop_geom_t geo; /* current fs geometry */ + struct xfs_fsop_geom geo; /* current fs geometry */ int iflag; /* -i flag */ int isint; /* log is currently internal */ int lflag; /* -l flag */ @@ -52,7 +52,7 @@ main(int argc, char **argv) int maxpct; /* -m flag value */ int mflag; /* -m flag */ int nflag; /* -n flag */ - xfs_fsop_geom_t ngeo; /* new fs geometry */ + struct xfs_fsop_geom ngeo; /* new fs geometry */ int rflag; /* -r flag */ long long rsize; /* new rt size in fs blocks */ int xflag; /* -x flag */ diff --git a/io/init.c b/io/init.c index 83f08f2d..7025aea5 100644 --- a/io/init.c +++ b/io/init.c @@ -133,7 +133,7 @@ init( int c, flags = 0; char *sp; mode_t mode = 0600; - xfs_fsop_geom_t geometry = { 0 }; + struct xfs_fsop_geom geometry = { 0 }; struct fs_path fsp; progname = basename(argv[0]); diff --git a/io/io.h b/io/io.h index 6469179e..0848ab98 100644 --- a/io/io.h +++ b/io/io.h @@ -38,7 +38,7 @@ typedef struct fileio { int fd; /* open file descriptor */ int flags; /* flags describing file state */ char *name; /* file name at time of open */ - xfs_fsop_geom_t geom; /* XFS filesystem geometry */ + struct xfs_fsop_geom geom; /* XFS filesystem geometry */ struct fs_path fs_path; /* XFS path information */ } fileio_t; @@ -70,9 +70,9 @@ extern void *check_mapping_range(mmap_region_t *, off64_t, size_t, int); */ extern off64_t filesize(void); -extern int openfile(char *, xfs_fsop_geom_t *, int, mode_t, +extern int openfile(char *, struct xfs_fsop_geom *, int, mode_t, struct fs_path *); -extern int addfile(char *, int , xfs_fsop_geom_t *, int, +extern int addfile(char *, int , struct xfs_fsop_geom *, int, struct fs_path *); extern void printxattr(uint, int, int, const char *, int, int); diff --git a/io/open.c b/io/open.c index 11805cd7..ce7a5362 100644 --- a/io/open.c +++ b/io/open.c @@ -51,7 +51,7 @@ static long extsize; int openfile( char *path, - xfs_fsop_geom_t *geom, + struct xfs_fsop_geom *geom, int flags, mode_t mode, struct fs_path *fs_path) @@ -156,7 +156,7 @@ int addfile( char *name, int fd, - xfs_fsop_geom_t *geometry, + struct xfs_fsop_geom *geometry, int flags, struct fs_path *fs_path) { @@ -229,7 +229,7 @@ open_f( int c, fd, flags = 0; char *sp; mode_t mode = 0600; - xfs_fsop_geom_t geometry = { 0 }; + struct xfs_fsop_geom geometry = { 0 }; struct fs_path fsp; if (argc == 1) { diff --git a/man/man3/xfsctl.3 b/man/man3/xfsctl.3 index 6e5027c4..462ccbd8 100644 --- a/man/man3/xfsctl.3 +++ b/man/man3/xfsctl.3 @@ -640,7 +640,7 @@ operations on XFS filesystems. For .B XFS_IOC_FSGEOMETRY (get filesystem mkfs time information), the output structure is of type -.BR xfs_fsop_geom_t . +.BR struct xfs_fsop_geom . For .B XFS_FS_COUNTS (get filesystem dynamic global information), the output structure is of type diff --git a/spaceman/file.c b/spaceman/file.c index d2acf5db..a9b8461f 100644 --- a/spaceman/file.c +++ b/spaceman/file.c @@ -44,7 +44,7 @@ print_f( int openfile( char *path, - xfs_fsop_geom_t *geom, + struct xfs_fsop_geom *geom, struct fs_path *fs_path) { struct fs_path *fsp; @@ -84,7 +84,7 @@ int addfile( char *name, int fd, - xfs_fsop_geom_t *geometry, + struct xfs_fsop_geom *geometry, struct fs_path *fs_path) { char *filename; diff --git a/spaceman/init.c b/spaceman/init.c index 181a3446..c845f920 100644 --- a/spaceman/init.c +++ b/spaceman/init.c @@ -60,7 +60,7 @@ init( char **argv) { int c; - xfs_fsop_geom_t geometry = { 0 }; + struct xfs_fsop_geom geometry = { 0 }; struct fs_path fsp; progname = basename(argv[0]); diff --git a/spaceman/space.h b/spaceman/space.h index bf9cc2bf..b246f602 100644 --- a/spaceman/space.h +++ b/spaceman/space.h @@ -7,7 +7,7 @@ #define XFS_SPACEMAN_SPACE_H_ typedef struct fileio { - xfs_fsop_geom_t geom; /* XFS filesystem geometry */ + struct xfs_fsop_geom geom; /* XFS filesystem geometry */ struct fs_path fs_path; /* XFS path information */ char *name; /* file name at time of open */ int fd; /* open file descriptor */ @@ -17,8 +17,8 @@ extern fileio_t *filetable; /* open file table */ extern int filecount; /* number of open files */ extern fileio_t *file; /* active file in file table */ -extern int openfile(char *, xfs_fsop_geom_t *, struct fs_path *); -extern int addfile(char *, int , xfs_fsop_geom_t *, struct fs_path *); +extern int openfile(char *, struct xfs_fsop_geom *, struct fs_path *); +extern int addfile(char *, int , struct xfs_fsop_geom *, struct fs_path *); extern void print_init(void); extern void help_init(void); From patchwork Mon May 20 23:17:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7204D1390 for ; Mon, 20 May 2019 23:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F7A42015F for ; Mon, 20 May 2019 23:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53E90288A7; Mon, 20 May 2019 23:17:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 A375A2015F for ; Mon, 20 May 2019 23:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbfETXR3 (ORCPT ); Mon, 20 May 2019 19:17:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38504 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXR3 (ORCPT ); Mon, 20 May 2019 19:17:29 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDX8b148806; Mon, 20 May 2019 23:17:27 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-2018-07-02; bh=RE0UWsd4CGApxv3/8Y0/vntT8CCMxx5DTQNzrIegokg=; b=M54yOtnyxo5daK0lCO4V33RkIt4XycZ6okqlsPZK3udFu46WBoy+02RVeo6RUwl339UC GGrmY2WeLUirp7Z07IhbaFjdCjw2cXPlPOkyHXIDz2WR8miooe+8h5Kek5Dz0gYWBUtY HN/hcjEZX/6HZv9ToGPIqzZn/5nG5DnnA0Ej1FFeh3JKsgRN16u6gRl6/jRStx1EeBIW hjbguJ5fk6DQvZgcvhoUwfsO7wVEPB3ou8MRfFByI2krpydRnOYgNfIU2xmCXU49gRfK 1onb5madw4/+WuKacZ+IkL89tWYyQFJLezFwHVlhLA9dbIyIbVEMnyNz4p5XimOzYnrp LQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2sjapq9ub8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNGoOu074188; Mon, 20 May 2019 23:17:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2skudb28hp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:26 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNHQhQ007982; Mon, 20 May 2019 23:17:26 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:26 +0000 Subject: [PATCH 07/12] libfrog: fix bitmap return values From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:25 -0700 Message-ID: <155839424514.68606.14562327454853103352.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Fix the return types of non-predicate bitmap functions to return the usual negative error codes instead of the "moveon" boolean. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- include/bitmap.h | 8 +++-- libfrog/bitmap.c | 86 ++++++++++++++++++++++++++---------------------------- repair/rmap.c | 18 ++++++++--- scrub/phase6.c | 18 ++++------- 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/include/bitmap.h b/include/bitmap.h index e29a4335..99a2fb23 100644 --- a/include/bitmap.h +++ b/include/bitmap.h @@ -11,11 +11,11 @@ struct bitmap { struct avl64tree_desc *bt_tree; }; -bool bitmap_init(struct bitmap **bmap); +int bitmap_init(struct bitmap **bmap); void bitmap_free(struct bitmap **bmap); -bool bitmap_set(struct bitmap *bmap, uint64_t start, uint64_t length); -bool bitmap_iterate(struct bitmap *bmap, - bool (*fn)(uint64_t, uint64_t, void *), void *arg); +int bitmap_set(struct bitmap *bmap, uint64_t start, uint64_t length); +int bitmap_iterate(struct bitmap *bmap, int (*fn)(uint64_t, uint64_t, void *), + void *arg); bool bitmap_test(struct bitmap *bmap, uint64_t start, uint64_t len); bool bitmap_empty(struct bitmap *bmap); diff --git a/libfrog/bitmap.c b/libfrog/bitmap.c index 450ebe0a..4dafc4c9 100644 --- a/libfrog/bitmap.c +++ b/libfrog/bitmap.c @@ -66,7 +66,7 @@ static struct avl64ops bitmap_ops = { }; /* Initialize a bitmap. */ -bool +int bitmap_init( struct bitmap **bmapp) { @@ -74,18 +74,18 @@ bitmap_init( bmap = calloc(1, sizeof(struct bitmap)); if (!bmap) - return false; + return -ENOMEM; bmap->bt_tree = malloc(sizeof(struct avl64tree_desc)); if (!bmap->bt_tree) { free(bmap); - return false; + return -ENOMEM; } pthread_mutex_init(&bmap->bt_lock, NULL); avl64_init_tree(bmap->bt_tree, &bitmap_ops); *bmapp = bmap; - return true; + return 0; } /* Free a bitmap. */ @@ -127,8 +127,31 @@ bitmap_node_init( return ext; } +/* Create a new bitmap node and insert it. */ +static inline int +__bitmap_insert( + struct bitmap *bmap, + uint64_t start, + uint64_t length) +{ + struct bitmap_node *ext; + struct avl64node *node; + + ext = bitmap_node_init(start, length); + if (!ext) + return -ENOMEM; + + node = avl64_insert(bmap->bt_tree, &ext->btn_node); + if (node == NULL) { + free(ext); + return -EEXIST; + } + + return 0; +} + /* Set a region of bits (locked). */ -static bool +static int __bitmap_set( struct bitmap *bmap, uint64_t start, @@ -142,28 +165,14 @@ __bitmap_set( struct bitmap_node *ext; uint64_t new_start; uint64_t new_length; - struct avl64node *node; - bool res = true; /* Find any existing nodes adjacent or within that range. */ avl64_findranges(bmap->bt_tree, start - 1, start + length + 1, &firstn, &lastn); /* Nothing, just insert a new extent. */ - if (firstn == NULL && lastn == NULL) { - ext = bitmap_node_init(start, length); - if (!ext) - return false; - - node = avl64_insert(bmap->bt_tree, &ext->btn_node); - if (node == NULL) { - free(ext); - errno = EEXIST; - return false; - } - - return true; - } + if (firstn == NULL && lastn == NULL) + return __bitmap_insert(bmap, start, length); assert(firstn != NULL && lastn != NULL); new_start = start; @@ -175,7 +184,7 @@ __bitmap_set( /* Bail if the new extent is contained within an old one. */ if (ext->btn_start <= start && ext->btn_start + ext->btn_length >= start + length) - return res; + return 0; /* Check for overlapping and adjacent extents. */ if (ext->btn_start + ext->btn_length >= start || @@ -195,28 +204,17 @@ __bitmap_set( } } - ext = bitmap_node_init(new_start, new_length); - if (!ext) - return false; - - node = avl64_insert(bmap->bt_tree, &ext->btn_node); - if (node == NULL) { - free(ext); - errno = EEXIST; - return false; - } - - return res; + return __bitmap_insert(bmap, new_start, new_length); } /* Set a region of bits. */ -bool +int bitmap_set( struct bitmap *bmap, uint64_t start, uint64_t length) { - bool res; + int res; pthread_mutex_lock(&bmap->bt_lock); res = __bitmap_set(bmap, start, length); @@ -308,26 +306,26 @@ bitmap_clear( #ifdef DEBUG /* Iterate the set regions of this bitmap. */ -bool +int bitmap_iterate( struct bitmap *bmap, - bool (*fn)(uint64_t, uint64_t, void *), + int (*fn)(uint64_t, uint64_t, void *), void *arg) { struct avl64node *node; struct bitmap_node *ext; - bool moveon = true; + int error = 0; pthread_mutex_lock(&bmap->bt_lock); avl_for_each(bmap->bt_tree, node) { ext = container_of(node, struct bitmap_node, btn_node); - moveon = fn(ext->btn_start, ext->btn_length, arg); - if (!moveon) + error = fn(ext->btn_start, ext->btn_length, arg); + if (error) break; } pthread_mutex_unlock(&bmap->bt_lock); - return moveon; + return error; } #endif @@ -372,14 +370,14 @@ bitmap_empty( } #ifdef DEBUG -static bool +static int bitmap_dump_fn( uint64_t startblock, uint64_t blockcount, void *arg) { printf("%"PRIu64":%"PRIu64"\n", startblock, blockcount); - return true; + return 0; } /* Dump bitmap. */ diff --git a/repair/rmap.c b/repair/rmap.c index 19cceca3..47828a06 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -490,16 +490,22 @@ rmap_store_ag_btree_rec( error = init_slab_cursor(ag_rmap->ar_raw_rmaps, rmap_compare, &rm_cur); if (error) goto err; - if (!bitmap_init(&own_ag_bitmap)) { - error = -ENOMEM; + error = -bitmap_init(&own_ag_bitmap); + if (error) goto err_slab; - } while ((rm_rec = pop_slab_cursor(rm_cur)) != NULL) { if (rm_rec->rm_owner != XFS_RMAP_OWN_AG) continue; - if (!bitmap_set(own_ag_bitmap, rm_rec->rm_startblock, - rm_rec->rm_blockcount)) { - error = EFSCORRUPTED; + error = -bitmap_set(own_ag_bitmap, rm_rec->rm_startblock, + rm_rec->rm_blockcount); + if (error) { + /* + * If this range is already set, then the incore rmap + * records for the AG free space btrees overlap and + * we're toast because that is not allowed. + */ + if (error == EEXIST) + error = EFSCORRUPTED; goto err_slab; } } diff --git a/scrub/phase6.c b/scrub/phase6.c index 4b25f3bb..66e6451c 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -341,7 +341,6 @@ xfs_check_rmap_ioerr( struct media_verify_state *vs = arg; struct bitmap *tree; dev_t dev; - bool moveon; dev = xfs_disk_to_dev(ctx, disk); @@ -356,8 +355,8 @@ xfs_check_rmap_ioerr( else tree = NULL; if (tree) { - moveon = bitmap_set(tree, start, length); - if (!moveon) + errno = -bitmap_set(tree, start, length); + if (errno) str_errno(ctx, ctx->mntpoint); } @@ -454,16 +453,16 @@ xfs_scan_blocks( struct scrub_ctx *ctx) { struct media_verify_state vs = { NULL }; - bool moveon; + bool moveon = false; - moveon = bitmap_init(&vs.d_bad); - if (!moveon) { + errno = -bitmap_init(&vs.d_bad); + if (errno) { str_errno(ctx, ctx->mntpoint); goto out; } - moveon = bitmap_init(&vs.r_bad); - if (!moveon) { + errno = -bitmap_init(&vs.r_bad); + if (errno) { str_errno(ctx, ctx->mntpoint); goto out_dbad; } @@ -472,7 +471,6 @@ xfs_scan_blocks( ctx->geo.blocksize, xfs_check_rmap_ioerr, scrub_nproc(ctx)); if (!vs.rvp_data) { - moveon = false; str_info(ctx, ctx->mntpoint, _("Could not create data device media verifier.")); goto out_rbad; @@ -482,7 +480,6 @@ _("Could not create data device media verifier.")); ctx->geo.blocksize, xfs_check_rmap_ioerr, scrub_nproc(ctx)); if (!vs.rvp_log) { - moveon = false; str_info(ctx, ctx->mntpoint, _("Could not create log device media verifier.")); goto out_datapool; @@ -493,7 +490,6 @@ _("Could not create data device media verifier.")); ctx->geo.blocksize, xfs_check_rmap_ioerr, scrub_nproc(ctx)); if (!vs.rvp_realtime) { - moveon = false; str_info(ctx, ctx->mntpoint, _("Could not create realtime device media verifier.")); goto out_logpool; From patchwork Mon May 20 23:17:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 241901390 for ; Mon, 20 May 2019 23:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E39F2015F for ; Mon, 20 May 2019 23:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02543288A7; Mon, 20 May 2019 23:17:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 6B4E62015F for ; Mon, 20 May 2019 23:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbfETXRg (ORCPT ); Mon, 20 May 2019 19:17:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38600 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRf (ORCPT ); Mon, 20 May 2019 19:17:35 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDX5D148824; Mon, 20 May 2019 23:17:33 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-2018-07-02; bh=Okru09u4Z/UKpPNO29JaL1W7hlb5tppeuFV5VIcp7/g=; b=teajE8wsq57m0Q1is1fQGhAIFieMoEQQnq804VU/SvGAtut3RrtlvIAr4QFxwOtJXN0a kYrT68OS4MuljUOr/4ykkd+sjLPGo0Cfj8c/jx10VepEuCfRNz4h2SL8jvym2R+Wdm2b 2ChNx2NRmzWPs/LxWiSsI9AbjD7hswN5TgyIc7rMpud9V8dmSWoH5HdqCZyYQySGo/L/ PBng04D9PrhtUrC5Rv7hGmMYQDp177IKWNAJq0wgppI0G3DRWZUrVHc5S8W362yqr88p 5jAdS4WPIMBdqDqCAEVRxGuwY+pcCNwN5UGae5blXUuLkHgpJ/jT7mzknuPddiUKiKuZ oA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2sjapq9ubr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:33 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNHT6v123684; Mon, 20 May 2019 23:17:32 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2sks1xv8kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:32 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNHWNk015672; Mon, 20 May 2019 23:17:32 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:32 +0000 Subject: [PATCH 08/12] xfs_repair: refactor namecheck functions From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:31 -0700 Message-ID: <155839425128.68606.14448412166622032502.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200142 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Now that we have name check functions in libxfs, use them instead of our custom versions. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- libxfs/libxfs_api_defs.h | 2 ++ repair/attr_repair.c | 32 +++++++++++++------------------- repair/da_util.c | 27 --------------------------- repair/da_util.h | 6 ------ repair/dir2.c | 12 ++---------- 5 files changed, 17 insertions(+), 62 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 34bb552d..71a7ef53 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -143,6 +143,8 @@ #define xfs_default_ifork_ops libxfs_default_ifork_ops #define xfs_fs_geometry libxfs_fs_geometry #define xfs_init_local_fork libxfs_init_local_fork +#define xfs_dir2_namecheck libxfs_dir2_namecheck +#define xfs_attr_namecheck libxfs_attr_namecheck #define LIBXFS_ATTR_ROOT ATTR_ROOT #define LIBXFS_ATTR_SECURE ATTR_SECURE diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 5ad81c09..9a44f610 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -122,14 +122,6 @@ set_da_freemap(xfs_mount_t *mp, da_freemap_t *map, int start, int stop) * fork being emptied and put in shortform format. */ -static int -attr_namecheck( - uint8_t *name, - int length) -{ - return namecheck((char *)name, length, false); -} - /* * This routine just checks what security needs are for attribute values * only called when root flag is set, otherwise these names could exist in @@ -301,8 +293,8 @@ process_shortform_attr( } /* namecheck checks for null chars in attr names. */ - if (attr_namecheck(currententry->nameval, - currententry->namelen)) { + if (!libxfs_attr_namecheck(currententry->nameval, + currententry->namelen)) { do_warn( _("entry contains illegal character in shortform attribute name\n")); junkit = 1; @@ -464,8 +456,9 @@ process_leaf_attr_local( xfs_attr_leaf_name_local_t *local; local = xfs_attr3_leaf_name_local(leaf, i); - if (local->namelen == 0 || attr_namecheck(local->nameval, - local->namelen)) { + if (local->namelen == 0 || + !libxfs_attr_namecheck(local->nameval, + local->namelen)) { do_warn( _("attribute entry %d in attr block %u, inode %" PRIu64 " has bad name (namelen = %d)\n"), i, da_bno, ino, local->namelen); @@ -519,13 +512,14 @@ process_leaf_attr_remote( remotep = xfs_attr3_leaf_name_remote(leaf, i); - if (remotep->namelen == 0 || attr_namecheck(remotep->name, - remotep->namelen) || - be32_to_cpu(entry->hashval) != - libxfs_da_hashname((unsigned char *)&remotep->name[0], - remotep->namelen) || - be32_to_cpu(entry->hashval) < last_hashval || - be32_to_cpu(remotep->valueblk) == 0) { + if (remotep->namelen == 0 || + !libxfs_attr_namecheck(remotep->name, + remotep->namelen) || + be32_to_cpu(entry->hashval) != + libxfs_da_hashname((unsigned char *)&remotep->name[0], + remotep->namelen) || + be32_to_cpu(entry->hashval) < last_hashval || + be32_to_cpu(remotep->valueblk) == 0) { do_warn( _("inconsistent remote attribute entry %d in attr block %u, ino %" PRIu64 "\n"), i, da_bno, ino); return -1; diff --git a/repair/da_util.c b/repair/da_util.c index 4a258e58..8c818ea1 100644 --- a/repair/da_util.c +++ b/repair/da_util.c @@ -12,33 +12,6 @@ #include "bmap.h" #include "da_util.h" -/* - * Takes a name and length (name need not be null-terminated) and whether - * we are checking a dir (as opposed to an attr). - * Returns 1 if the name contains a NUL or if a directory entry contains a '/'. - * Returns 0 if the name checks out. - */ -int -namecheck( - char *name, - int length, - bool isadir) -{ - char *c; - int i; - - ASSERT(length < MAXNAMELEN); - - for (c = name, i = 0; i < length; i++, c++) { - if (isadir && *c == '/') - return 1; - if (*c == '\0') - return 1; - } - - return 0; -} - /* * the cursor gets passed up and down the da btree processing * routines. The interior block processing routines use the diff --git a/repair/da_util.h b/repair/da_util.h index 041dff74..90fec00c 100644 --- a/repair/da_util.h +++ b/repair/da_util.h @@ -24,12 +24,6 @@ typedef struct da_bt_cursor { struct blkmap *blkmap; } da_bt_cursor_t; -int -namecheck( - char *name, - int length, - bool isadir); - struct xfs_buf * da_read_buf( xfs_mount_t *mp, diff --git a/repair/dir2.c b/repair/dir2.c index 094ecb3d..4ac0084e 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -44,14 +44,6 @@ _("malloc failed (%zu bytes) dir2_add_badlist:ino %" PRIu64 "\n"), l->ino = ino; } -static int -dir_namecheck( - uint8_t *name, - int length) -{ - return namecheck((char *)name, length, true); -} - int dir2_is_badino( xfs_ino_t ino) @@ -318,7 +310,7 @@ _("entry #%d %s in shortform dir %" PRIu64), * the length value is stored in a byte * so it can't be too big, it can only wrap */ - if (dir_namecheck(sfep->name, namelen)) { + if (!libxfs_dir2_namecheck(sfep->name, namelen)) { /* * junk entry */ @@ -789,7 +781,7 @@ _("\twould clear inode number in entry at offset %" PRIdPTR "...\n"), * during phase 4. */ junkit = dep->name[0] == '/'; - nm_illegal = dir_namecheck(dep->name, dep->namelen); + nm_illegal = !libxfs_dir2_namecheck(dep->name, dep->namelen); if (ino_discovery && nm_illegal) { do_warn( _("entry at block %u offset %" PRIdPTR " in directory inode %" PRIu64 " has illegal name \"%*.*s\": "), From patchwork Mon May 20 23:17:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D950B112C for ; Mon, 20 May 2019 23:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C88122015F for ; Mon, 20 May 2019 23:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA0EF288A7; Mon, 20 May 2019 23:17:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 6586B2015F for ; Mon, 20 May 2019 23:17:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbfETXRr (ORCPT ); Mon, 20 May 2019 19:17:47 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38744 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRq (ORCPT ); Mon, 20 May 2019 19:17:46 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNER6H149957; Mon, 20 May 2019 23:17: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-2018-07-02; bh=suHoFf87nkSELQARrszGrrHCfAPho90ddWTyD+qVcic=; b=Cmtkd+9JD4kddiYidk37HA/M3ybfs8f4ybM/y5HxciMem4a0jsL/fePr9VtCON9GSJe4 +LwLftodPmFgnK7nJ0wpbJhys7S6BYlLXmv4DKxzbAjnq0stunY4FSTb+bLqFQLOq6v0 iaql5H+f7C4jG1tGQlDUoknVLAzQwMRM7CStyWCiB5VfC6kaHzYSEng93q2zm9VCSWdz mfcXniUpIgnTTBLWd8FNvmFQZkIwQXmm6KlfD34QnY0in7cuFxuzUj+j/MUMzlXeWBrm Jx4BnoiyUW6HZGR1t2oQUnq9F11yzeGVT44xtVX9uA6I2EIp/+6mZwMl/bp+l2MJVb+h eg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2sjapq9uc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNHfbO077783; Mon, 20 May 2019 23:17:44 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2skudb28ph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:44 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNHhwT008149; Mon, 20 May 2019 23:17:43 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:43 +0000 Subject: [PATCH 09/12] xfs_scrub: fix background-mode sleep throttling From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:37 -0700 Message-ID: <155839425742.68606.18377767804648563349.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=991 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200143 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 The comment preceding background_sleep() is wrong -- the function sleeps 100us, not 100ms, for every '-b' passed in after the first one. This is really not obvious from the magic numbers, so fix the comment and use symbolic constants for easier reading. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- scrub/common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scrub/common.c b/scrub/common.c index c877c7c8..1cd2b7ba 100644 --- a/scrub/common.c +++ b/scrub/common.c @@ -253,21 +253,23 @@ scrub_nproc_workqueue( } /* - * Sleep for 100ms * however many -b we got past the initial one. + * Sleep for 100us * however many -b we got past the initial one. * This is an (albeit clumsy) way to throttle scrub activity. */ +#define NSEC_PER_SEC 1000000000ULL +#define NSEC_PER_USEC 1000ULL void background_sleep(void) { - unsigned long long time; + unsigned long long time_ns; struct timespec tv; if (bg_mode < 2) return; - time = 100000ULL * (bg_mode - 1); - tv.tv_sec = time / 1000000; - tv.tv_nsec = time % 1000000; + time_ns = 100 * NSEC_PER_USEC * (bg_mode - 1); + tv.tv_sec = time_ns / NSEC_PER_SEC; + tv.tv_nsec = time_ns % NSEC_PER_SEC; nanosleep(&tv, NULL); } From patchwork Mon May 20 23:17:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F417C1390 for ; Mon, 20 May 2019 23:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35382015F for ; Mon, 20 May 2019 23:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7ADA288A7; Mon, 20 May 2019 23:17:54 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 7963F28306 for ; Mon, 20 May 2019 23:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727153AbfETXRy (ORCPT ); Mon, 20 May 2019 19:17:54 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38854 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbfETXRx (ORCPT ); Mon, 20 May 2019 19:17:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDs4O149704; Mon, 20 May 2019 23:17:51 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-2018-07-02; bh=W2eV/p3+JkXU5iHGKxvMeErqARlJQ7pOSoa1377pOSc=; b=nfn+oBmdU0HpT7kxfFPQknoQhACLx7ZU4mc0UYKrV3iMcPrB9RlOUlTmN8o2shetMgnx vKkPvcv0GRFn5nCAUadxOhQKN41Yl2seSY7SDBEpMK0oa8hG8UDZZccXkqmCRcaFkJ5i jX5mfBn0AltqRObshnpKVvcKMpSLTs52ExsHr7WXEhudzUUIBMKBV06xHnxpyg7rRTcT 4FAunM51KNpnUCMCMN3Bwa/B6MiF85WhPmRFQjbsy7XbjdMmScNbzptayD6GHQPlEqwD KVoyP8b7P7XlIlOU+b9GI+bNcPxgrzjtRyLWaUBzeaJ7aEHjQfU308RwYhBDpjv/rGEW TQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2sjapq9ucm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:51 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNHpM7153438; Mon, 20 May 2019 23:17:51 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2sm046n4aj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:50 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4KNHnbe022361; Mon, 20 May 2019 23:17:49 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:49 +0000 Subject: [PATCH 10/12] mkfs: allow setting dax flag on root directory From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:48 -0700 Message-ID: <155839426866.68606.8424427245250373556.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200143 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Teach mkfs to set the DAX flag on the root directory so that all new files can be created in dax mode. This is a complement to removing the mount option. Signed-off-by: Darrick J. Wong --- man/man8/mkfs.xfs.8 | 11 +++++++++++ mkfs/xfs_mkfs.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8 index 4b8c78c3..0137f164 100644 --- a/man/man8/mkfs.xfs.8 +++ b/man/man8/mkfs.xfs.8 @@ -391,6 +391,17 @@ All inodes created by will have this extent size hint applied. The value must be provided in units of filesystem blocks. Directories will pass on this hint to newly created children. +.TP +.BI dax= value +All inodes created by +.B mkfs.xfs +will have the DAX flag set. +This means that directories will pass the flag on to newly created files +and files will use the DAX IO paths when possible. +This value is either 1 to enable the use or 0 to disable. +By default, +.B mkfs.xfs +will not enable DAX mode. .RE .TP .B \-f diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 09106648..5b66074d 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -59,6 +59,7 @@ enum { D_PROJINHERIT, D_EXTSZINHERIT, D_COWEXTSIZE, + D_DAX, D_MAX_OPTS, }; @@ -253,6 +254,7 @@ static struct opt_params dopts = { [D_PROJINHERIT] = "projinherit", [D_EXTSZINHERIT] = "extszinherit", [D_COWEXTSIZE] = "cowextsize", + [D_DAX] = "dax", }, .subopt_params = { { .index = D_AGCOUNT, @@ -368,6 +370,12 @@ static struct opt_params dopts = { .maxval = UINT_MAX, .defaultval = SUBOPT_NEEDS_VAL, }, + { .index = D_DAX, + .conflicts = { { NULL, LAST_CONFLICT } }, + .minval = 0, + .maxval = 1, + .defaultval = 1, + }, }, }; @@ -1465,6 +1473,9 @@ data_opts_parser( cli->fsx.fsx_cowextsize = getnum(value, opts, subopt); cli->fsx.fsx_xflags |= FS_XFLAG_COWEXTSIZE; break; + case D_DAX: + cli->fsx.fsx_xflags |= FS_XFLAG_DAX; + break; default: return -EINVAL; } From patchwork Mon May 20 23:17:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C471B1390 for ; Mon, 20 May 2019 23:18:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B28352015F for ; Mon, 20 May 2019 23:18:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FC8288A7; Mon, 20 May 2019 23:18:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 565BA2015F for ; Mon, 20 May 2019 23:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbfETXSA (ORCPT ); Mon, 20 May 2019 19:18:00 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37596 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfETXR7 (ORCPT ); Mon, 20 May 2019 19:17:59 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDmfY149853; Mon, 20 May 2019 23:17:57 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-2018-07-02; bh=E0JnMRcL6jKfFc2GtoIlInDciJGciFZEt05yi6zS0B4=; b=QjxiuLdbiKz8gaWm10wnuJaLgheJkybrDW/eMMz8sdHIgk2y+p0kwuczHiouCl7SQkhe 80Wnii9qXZfQY0XAfWAh8p4MgvTgSE435A/Bf4tArOkmGWX6qyjisjney0YdZZJYv9RS GtLfcZuadCNGh9oQtOOkXX/MPGhEZ2ADLzX0RE+ADARkt7Y9cKrQB84lAV+zfp7GXP/7 mQ8R99+D52kqBQDGIccVwyARwUjtN0ogsn0poZV2sh5ODBF9i9B9i72okdyK915y4Ljy nq09gYfXKqKW+yqx5Uhi6MYIk8mfLkDBvcEATSO3AdQaEjYiNCRU1nsugMg+zeCnlpDK cQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:57 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNHfbS077783; Mon, 20 May 2019 23:17:56 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2skudb28t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:17:56 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4KNHtCs008239; Mon, 20 May 2019 23:17:55 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:17:55 +0000 Subject: [PATCH 11/12] mkfs: validate start and end of aligned logs From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:17:54 -0700 Message-ID: <155839427473.68606.3900005341580158051.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1905200143 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Validate that the start and end of the log stay within a single AG if we adjust either end to align to stripe units. Signed-off-by: Darrick J. Wong --- mkfs/xfs_mkfs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 5b66074d..8f84536e 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3044,15 +3044,28 @@ align_internal_log( struct xfs_mount *mp, int sunit) { + uint64_t logend; + /* round up log start if necessary */ if ((cfg->logstart % sunit) != 0) cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit; + /* if our log start rounds into the next AG we're done */ + if (!xfs_verify_fsbno(mp, cfg->logstart)) { + fprintf(stderr, +_("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n" + "within an allocation group.\n"), + (long long) cfg->logstart); + usage(); + } + /* round up/down the log size now */ align_log_size(cfg, sunit); /* check the aligned log still fits in an AG. */ - if (cfg->logblocks > cfg->agsize - XFS_FSB_TO_AGBNO(mp, cfg->logstart)) { + logend = cfg->logstart + cfg->logblocks - 1; + if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) || + !xfs_verify_fsbno(mp, logend)) { fprintf(stderr, _("Due to stripe alignment, the internal log size (%lld) is too large.\n" "Must fit within an allocation group.\n"), From patchwork Mon May 20 23:18:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10952575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B17AE112C for ; Mon, 20 May 2019 23:18:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF4A2015F for ; Mon, 20 May 2019 23:18:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9486C288A7; Mon, 20 May 2019 23:18:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 3C2D12015F for ; Mon, 20 May 2019 23:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfETXSH (ORCPT ); Mon, 20 May 2019 19:18:07 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:37692 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfETXSH (ORCPT ); Mon, 20 May 2019 19:18:07 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNDb22149372; Mon, 20 May 2019 23:18:05 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-2018-07-02; bh=fSsafg5B6X8PioS+zyWRWryY6XtT/BzF7ejne+2Hjv8=; b=MUYrEdxh/1A4Lju1iCn0ZA45Z2/6IhbOuZiNY6m0jgFjhQr8zDuJuZEDVa5uUWp0C7Z/ 5t2v8CKxyZGOIwN1r0BYxfC/MNgWq/x9fPpOeCPPJsL8PGI1/OrNHYibazo+gTL1c+11 9FfNJjcWzyYxsBlNd2TuFABK7Ni19GTXx27U95oTPi6/s65gRhGbrRMs/zzfUGRT431d OA2wukFvP34pzHA9hU8sXqeKQ0lGnHQc2GAGoY0bYW36xIwPhfx9fofCOy0jTFPncHSB awjZmzoLX9RzkHovyWMxbqLzRqBPwu+Wpsxo2/IDMMpYJrdU8Wj20xWrxzrv3s0fgdJM qA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 2sj7jdj5p4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:18:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4KNHgr6065599; Mon, 20 May 2019 23:18:04 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2sks1j496c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 May 2019 23:18:04 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4KNI3Cu022507; Mon, 20 May 2019 23:18:03 GMT Received: from localhost (/10.159.247.197) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 May 2019 23:18:03 +0000 Subject: [PATCH 12/12] mkfs: enable reflink by default From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 20 May 2019 16:18:00 -0700 Message-ID: <155839428076.68606.9379127257564633311.stgit@magnolia> In-Reply-To: <155839420081.68606.4573219764134939943.stgit@magnolia> References: <155839420081.68606.4573219764134939943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=946 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200143 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9263 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=978 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200142 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 Data block sharing (a.k.a. reflink) has been stable for a while, so turn it on by default. Signed-off-by: Darrick J. Wong --- mkfs/xfs_mkfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 8f84536e..afed46d0 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2015,7 +2015,7 @@ _("rmapbt not supported without CRC support\n")); } cli->sb_feat.rmapbt = false; - if (cli->sb_feat.reflink) { + if (cli->sb_feat.reflink && cli_opt_set(&mopts, M_REFLINK)) { fprintf(stderr, _("reflink not supported without CRC support\n")); usage(); @@ -3900,7 +3900,7 @@ main( .finobt = true, .spinodes = true, .rmapbt = false, - .reflink = false, + .reflink = true, .parent_pointers = false, .nodalign = false, .nortalign = false,