From patchwork Fri Jun 7 19:28:21 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: 10982623 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 58BA713AD for ; Fri, 7 Jun 2019 19:28:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40FA328A8C for ; Fri, 7 Jun 2019 19:28:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334CE28B45; Fri, 7 Jun 2019 19:28:35 +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 CDC2A28A8C for ; Fri, 7 Jun 2019 19:28:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729763AbfFGT2d (ORCPT ); Fri, 7 Jun 2019 15:28:33 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43224 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfFGT2c (ORCPT ); Fri, 7 Jun 2019 15:28:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x57JSTc7078218; Fri, 7 Jun 2019 19:28:29 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=6tuCCO7tVKtHA9Pw9mc86/eMFdpUyIaJslWIDVrfoUk=; b=0biHHqhVcj/7CyJRakYgZnTwzTe30G4E8IOqJsLcnsIRwQ122RgEMf9Fuk2GsbPGnCO6 YJ/fRAWcoGomRAfNIJYxYM/3TsNGSK1qNMbWW9TcyGrn0nDIqvlJryJWBwEQBkXsVCmm SzkvW+e7zsE45FX9cEgpTtN7GGWjd/4LKNHfZ8JCtE4FqxSDDgjS1xpc2zDrWzsZHorv C3sivU7j+gVWbbfPn3elJVub4RNnOg8EXI1SygdfZ3pZXO5Fg4kdzfDNwGf3t9WkpwKj +lJIfwLDSMPrlYld0uOf3qnWh8unMMldmhzLme5yUZkDc0+Ci5dyBQ8dUhVi/kROUeNP vQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2sugsu05w6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:29 +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 x57JSG0t169022; Fri, 7 Jun 2019 19:28:25 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2swngn8a0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:24 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x57JSNoC014772; Fri, 7 Jun 2019 19:28:24 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:22 -0700 Subject: [PATCH 1/6] libfrog: refactor online geometry queries From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 07 Jun 2019 12:28:21 -0700 Message-ID: <155993570154.2343365.13903320635252036528.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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 | 1 + fsr/xfs_fsr.c | 26 ++++---------------------- growfs/xfs_growfs.c | 25 +++++++++---------------- include/xfrog.h | 22 ++++++++++++++++++++++ io/bmap.c | 3 ++- io/fsmap.c | 3 ++- io/open.c | 3 ++- io/stat.c | 5 +++-- libfrog/fsgeom.c | 18 ++++++++++++++++++ quota/free.c | 6 +++--- repair/xfs_repair.c | 5 +++-- rtcp/Makefile | 3 +++ rtcp/xfs_rtcp.c | 7 ++++--- scrub/phase1.c | 3 ++- spaceman/file.c | 3 ++- spaceman/info.c | 25 ++++++++----------------- 16 files changed, 88 insertions(+), 70 deletions(-) create mode 100644 include/xfrog.h diff --git a/Makefile b/Makefile index 9204bed8..0edc2700 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,7 @@ copy: libxlog mkfs: libxcmd spaceman: libxcmd scrub: libhandle libxcmd +rtcp: libfrog ifeq ($(HAVE_BUILDDEFS), yes) include $(BUILDRULES) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index fef6262c..0bfecf37 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -11,6 +11,7 @@ #include "xfs_bmap_btree.h" #include "xfs_attr_sf.h" #include "path.h" +#include "xfrog.h" #include #include @@ -83,9 +84,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 +102,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 +624,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) return -1; } - if (xfs_getgeom(fsfd, &fsgeom) < 0 ) { + if (xfrog_geometry(fsfd, &fsgeom) < 0 ) { fsrprintf(_("Skipping %s: could not get XFS geometry\n"), mntdir); close(fsfd); @@ -772,7 +766,7 @@ fsrfile(char *fname, xfs_ino_t ino) } /* Get the fs geometry */ - if (xfs_getgeom(fsfd, &fsgeom) < 0 ) { + if (xfrog_geometry(fsfd, &fsgeom) < 0 ) { fsrprintf(_("Unable to get geom on fs for: %s\n"), fname); goto out; } @@ -1612,18 +1606,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/xfs_growfs.c b/growfs/xfs_growfs.c index 20089d2b..28dd6d84 100644 --- a/growfs/xfs_growfs.c +++ b/growfs/xfs_growfs.c @@ -7,6 +7,7 @@ #include "libxfs.h" #include "path.h" #include "fsgeom.h" +#include "xfrog.h" static void usage(void) @@ -165,22 +166,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 (xfrog_geometry(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 +352,7 @@ main(int argc, char **argv) } } - if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY_V1, &ngeo) < 0) { + if (xfrog_geometry(ffd, &ngeo)) { fprintf(stderr, _("%s: XFS_IOC_FSGEOMETRY xfsctl failed: %s\n"), progname, strerror(errno)); exit(1); diff --git a/include/xfrog.h b/include/xfrog.h new file mode 100644 index 00000000..b683cf63 --- /dev/null +++ b/include/xfrog.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2000-2002 Silicon Graphics, Inc. + * All Rights Reserved. + */ +#ifndef __XFROG_H__ +#define __XFROG_H__ + +/* + * XFS Filesystem Runtime Online Gluecode + * ====================================== + * + * These support functions wrap the more complex xfs ioctls so that xfs + * utilities can take advantage of them without having to deal with graceful + * degradation in the face of new ioctls. They will also provide higher level + * abstractions when possible. + */ + +struct xfs_fsop_geom; +int xfrog_geometry(int fd, struct xfs_fsop_geom *fsgeo); + +#endif /* __XFROG_H__ */ diff --git a/io/bmap.c b/io/bmap.c index d408826a..5f0d12ca 100644 --- a/io/bmap.c +++ b/io/bmap.c @@ -9,6 +9,7 @@ #include "input.h" #include "init.h" #include "io.h" +#include "xfrog.h" static cmdinfo_t bmap_cmd; @@ -105,7 +106,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 = xfrog_geometry(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..d3ff7dea 100644 --- a/io/fsmap.c +++ b/io/fsmap.c @@ -9,6 +9,7 @@ #include "path.h" #include "io.h" #include "input.h" +#include "xfrog.h" static cmdinfo_t fsmap_cmd; static dev_t xfs_data_dev; @@ -447,7 +448,7 @@ fsmap_f( } if (vflag) { - c = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &fsgeo); + c = xfrog_geometry(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 c7f5248a..997df119 100644 --- a/io/open.c +++ b/io/open.c @@ -9,6 +9,7 @@ #include "init.h" #include "io.h" #include "libxfs.h" +#include "xfrog.h" #ifndef __O_TMPFILE #if defined __alpha__ @@ -118,7 +119,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 (xfrog_geometry(fd, geom)) { perror("XFS_IOC_FSGEOMETRY"); close(fd); return -1; diff --git a/io/stat.c b/io/stat.c index 37c0b2e8..26b4eb68 100644 --- a/io/stat.c +++ b/io/stat.c @@ -12,6 +12,7 @@ #include "io.h" #include "statx.h" #include "libxfs.h" +#include "xfrog.h" #include @@ -194,8 +195,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 (xfrog_geometry(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/libfrog/fsgeom.c b/libfrog/fsgeom.c index 8879d161..a6dab3a8 100644 --- a/libfrog/fsgeom.c +++ b/libfrog/fsgeom.c @@ -4,6 +4,7 @@ */ #include "libxfs.h" #include "fsgeom.h" +#include "xfrog.h" void xfs_report_geom( @@ -67,3 +68,20 @@ xfs_report_geom( geo->rtextsize * geo->blocksize, (unsigned long long)geo->rtblocks, (unsigned long long)geo->rtextents); } + +/* Try to obtain the xfs geometry. */ +int +xfrog_geometry( + 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/free.c b/quota/free.c index 1d13006e..f47001bf 100644 --- a/quota/free.c +++ b/quota/free.c @@ -8,6 +8,7 @@ #include "command.h" #include "init.h" #include "quota.h" +#include "xfrog.h" static cmdinfo_t free_cmd; @@ -67,9 +68,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 (xfrog_geometry(fd, &fsgeo)) { + perror("XFS_IOC_FSGEOMETRY"); close(fd); return 0; } diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 9657503f..e6717d3c 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -22,6 +22,7 @@ #include "dinode.h" #include "slab.h" #include "rmap.h" +#include "xfrog.h" /* * option tables for getsubopt calls @@ -636,11 +637,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 (xfrog_geometry(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..264b4f27 100644 --- a/rtcp/Makefile +++ b/rtcp/Makefile @@ -9,6 +9,9 @@ LTCOMMAND = xfs_rtcp CFILES = xfs_rtcp.c LLDFLAGS = -static +LLDLIBS = $(LIBFROG) +LTDEPENDENCIES = $(LIBFROG) + default: depend $(LTCOMMAND) include $(BUILDRULES) diff --git a/rtcp/xfs_rtcp.c b/rtcp/xfs_rtcp.c index f928a86a..0b37ee89 100644 --- a/rtcp/xfs_rtcp.c +++ b/rtcp/xfs_rtcp.c @@ -5,6 +5,7 @@ */ #include "libxfs.h" +#include "xfrog.h" int rtcp(char *, char *, int); int xfsrtextsize(char *path); @@ -368,8 +369,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 +378,7 @@ xfsrtextsize( char *path) progname, path, strerror(errno)); return -1; } - rval = xfsctl( path, fd, XFS_IOC_FSGEOMETRY_V1, &geo ); + rval = xfrog_geometry(fd, &geo); close(fd); if ( rval < 0 ) return -1; diff --git a/scrub/phase1.c b/scrub/phase1.c index 04a5f4a9..5ab2a4fe 100644 --- a/scrub/phase1.c +++ b/scrub/phase1.c @@ -26,6 +26,7 @@ #include "disk.h" #include "scrub.h" #include "repair.h" +#include "xfrog.h" /* Phase 1: Find filesystem geometry (and clean up after) */ @@ -129,7 +130,7 @@ _("Does not appear to be an XFS filesystem!")); } /* Retrieve XFS geometry. */ - error = ioctl(ctx->mnt_fd, XFS_IOC_FSGEOMETRY, &ctx->geo); + error = xfrog_geometry(ctx->mnt_fd, &ctx->geo); if (error) { str_errno(ctx, ctx->mntpoint); return false; diff --git a/spaceman/file.c b/spaceman/file.c index 7e33e07e..690dd760 100644 --- a/spaceman/file.c +++ b/spaceman/file.c @@ -12,6 +12,7 @@ #include "init.h" #include "path.h" #include "space.h" +#include "xfrog.h" static cmdinfo_t print_cmd; @@ -56,7 +57,7 @@ openfile( return -1; } - if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) { + if (xfrog_geometry(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..714d715c 100644 --- a/spaceman/info.c +++ b/spaceman/info.c @@ -9,6 +9,7 @@ #include "path.h" #include "space.h" #include "fsgeom.h" +#include "xfrog.h" static void info_help(void) @@ -37,24 +38,14 @@ info_f( } /* get the current filesystem size & geometry */ - error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo); + error = xfrog_geometry(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 Fri Jun 7 19:28:28 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: 10982655 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 2634692A for ; Fri, 7 Jun 2019 19:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16FDA26222 for ; Fri, 7 Jun 2019 19:30:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ADF7288BB; Fri, 7 Jun 2019 19:30:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 0F2A3287A8 for ; Fri, 7 Jun 2019 19:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729627AbfFGTaf (ORCPT ); Fri, 7 Jun 2019 15:30:35 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46764 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbfFGTae (ORCPT ); Fri, 7 Jun 2019 15:30:34 -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 x57JSr9X101216; Fri, 7 Jun 2019 19:30:30 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=qZePkjmk1QJqYb+4/eGecP7Wfg5S3HMrBzKGBGOgnyQ=; b=aRPJyXxcOY3XUALHOojgwwIzEKJPEXKLqVmOQ4TriR0RxjJfDc69NFpWrx4gAxqwjK+a Y1CXjY+eRw8LTtTFGSJeKeyK5d2jR2mklbqNiBD9w+PItKQu9FnhRgUZzQZwABBoasM+ bNnEgArLbOC7TXXYD/h+tIQFd+2TTrSCSmrCpzGyzRO66410rHS/UBixqBmXQcF0ZjQ3 xZ3M0DW+ttYcQz5adBg0mJB+UZZLxP62olrTWFYMFdG0CnD8S9EmSmjq/kllfI49kecp hlSKKlXgtYzPq8NsfwBnwnSNPA/Xudftxf55hjQUBbcSZ6kpKRyKReqVxjFQ2Tsyz9kh gQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 2sueve0ejj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:30:30 +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 x57JSG39169315; Fri, 7 Jun 2019 19:28:30 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2swngk6dfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:29 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x57JST6f030556; Fri, 7 Jun 2019 19:28:29 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:29 -0700 Subject: [PATCH 2/6] 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: Fri, 07 Jun 2019 12:28:28 -0700 Message-ID: <155993570815.2343365.14008441725903148335.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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 | 37 ++++------------------------- include/xfrog.h | 5 ++++ io/open.c | 66 ++++++++++++++++++++++++---------------------------- io/swapext.c | 18 ++------------ libfrog/Makefile | 1 + libfrog/bulkstat.c | 43 ++++++++++++++++++++++++++++++++++ quota/quot.c | 17 +++++-------- scrub/inodes.c | 28 ++++++---------------- 8 files changed, 101 insertions(+), 114 deletions(-) create mode 100644 libfrog/bulkstat.c diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 0bfecf37..f35ead90 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -102,31 +102,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) { @@ -600,7 +575,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; @@ -634,7 +609,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) tmp_init(mntdir); - while ((ret = xfs_bulkstat(fsfd, + while ((ret = xfrog_bulkstat(fsfd, &lastino, GRABSZ, &buf[0], &buflenout)) == 0) { xfs_bstat_t *p; xfs_bstat_t *endp; @@ -690,7 +665,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) } } if (ret < 0) - fsrprintf(_("%s: xfs_bulkstat: %s\n"), progname, strerror(errno)); + fsrprintf(_("%s: xfrog_bulkstat: %s\n"), progname, strerror(errno)); out0: tmp_close(mntdir); close(fsfd); @@ -752,7 +727,7 @@ fsrfile(char *fname, xfs_ino_t ino) goto out; } - if ((xfs_bulkstat_single(fsfd, &ino, &statbuf)) < 0) { + if ((xfrog_bulkstat_single(fsfd, ino, &statbuf)) < 0) { fsrprintf(_("unable to get bstat on %s: %s\n"), fname, strerror(errno)); goto out; @@ -981,7 +956,6 @@ fsr_setup_attr_fork( i = 0; do { xfs_bstat_t tbstat; - xfs_ino_t ino; char name[64]; /* @@ -989,8 +963,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 ((xfrog_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/xfrog.h b/include/xfrog.h index b683cf63..4b4e0adc 100644 --- a/include/xfrog.h +++ b/include/xfrog.h @@ -19,4 +19,9 @@ struct xfs_fsop_geom; int xfrog_geometry(int fd, struct xfs_fsop_geom *fsgeo); +struct xfs_bstat; +int xfrog_bulkstat_single(int fd, uint64_t ino, struct xfs_bstat *ubuffer); +int xfrog_bulkstat(int fd, uint64_t *lastino, uint32_t icount, + struct xfs_bstat *ubuffer, uint32_t *ocount); + #endif /* __XFROG_H__ */ diff --git a/io/open.c b/io/open.c index 997df119..d97903e9 100644 --- a/io/open.c +++ b/io/open.c @@ -713,19 +713,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) { @@ -767,35 +766,32 @@ inode_f( exitcode = 1; return 0; } + } else if (ret_next) { + /* get next inode */ + ret = xfrog_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 = xfrog_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..f5e6532f 100644 --- a/io/swapext.c +++ b/io/swapext.c @@ -8,6 +8,7 @@ #include "input.h" #include "init.h" #include "io.h" +#include "xfrog.h" static cmdinfo_t swapext_cmd; @@ -20,21 +21,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 +46,7 @@ swapext_f( goto out; } - error = xfs_bulkstat_single(file->fd, &stat.st_ino, &sx.sx_stat); + error = xfrog_bulkstat_single(file->fd, stat.st_ino, &sx.sx_stat); if (error) { perror("bulkstat"); goto out; diff --git a/libfrog/Makefile b/libfrog/Makefile index f5a0539b..05c6f701 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -13,6 +13,7 @@ LT_AGE = 0 CFILES = \ avl64.c \ bitmap.c \ +bulkstat.c \ convert.c \ crc32.c \ fsgeom.c \ diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c new file mode 100644 index 00000000..c0d3b627 --- /dev/null +++ b/libfrog/bulkstat.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "xfs.h" + +/* Bulkstat a single inode. */ +int +xfrog_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 +xfrog_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..4639dc5d 100644 --- a/quota/quot.c +++ b/quota/quot.c @@ -11,6 +11,7 @@ #include #include "init.h" #include "quota.h" +#include "xfrog.h" typedef struct du { struct du *next; @@ -124,12 +125,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 +158,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 = xfrog_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..7950208d 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -17,6 +17,7 @@ #include "xfs_scrub.h" #include "common.h" #include "inodes.h" +#include "xfrog.h" /* * Iterate a range of inodes. @@ -50,17 +51,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 +64,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 = xfrog_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 +91,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 +98,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 +108,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 +125,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 = xfrog_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 Fri Jun 7 19:28:34 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: 10982625 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 A803B92A for ; Fri, 7 Jun 2019 19:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99D0528B44 for ; Fri, 7 Jun 2019 19:28:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E78428B49; Fri, 7 Jun 2019 19:28:42 +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 E3B0428B44 for ; Fri, 7 Jun 2019 19:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729848AbfFGT2l (ORCPT ); Fri, 7 Jun 2019 15:28:41 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54400 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfFGT2l (ORCPT ); Fri, 7 Jun 2019 15:28:41 -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 x57JSdXZ086504; Fri, 7 Jun 2019 19:28:39 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=R7WmN4bKop7gYYSDgdKOUS+w5eFelt9bwWT6dSyZ6iA=; b=E447eSpOlVZTRLiBU67h8m3w7r9PHID8T327Ts3FiasyEDYSR9fFine0xIwp86hAQymC BLRl5AlTsOMH9oKOKzZvetKRv+sTNQZcjQaePzFwxfHUpVT8SHL9JXCRtPxkgvMz2Twa Biuarn+aX21indUFkcsSvv4dhb2QE7mRzvtng1BQzfZnYB8G795FOdwyFwBlkuQ4CwYc 6Uf9pYTSjfvU5hJBjVgX1WlpWv1eY4+s4XYAOHtr8qDJfzWHryEvgZjFraWPhFZTVVzg qp8vWdc1pyiA75wk9aO+dbUsxBq2sKfMnRKxuCVupj2rnw6/RDxTtVdyWsMlN9+t7jfE 0w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2suj0r02w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:39 +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 x57JSdXd053829; Fri, 7 Jun 2019 19:28:39 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2swnhbgcfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:38 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x57JSZem004729; Fri, 7 Jun 2019 19:28:35 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:35 -0700 Subject: [PATCH 3/6] 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: Fri, 07 Jun 2019 12:28:34 -0700 Message-ID: <155993571460.2343365.17053963096831775316.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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/xfrog.h | 4 ++++ io/imap.c | 31 ++++++++++++++----------------- io/open.c | 19 +++++++------------ libfrog/bulkstat.c | 19 +++++++++++++++++++ scrub/fscounters.c | 18 +++++++----------- scrub/inodes.c | 21 +++++++-------------- 6 files changed, 58 insertions(+), 54 deletions(-) diff --git a/include/xfrog.h b/include/xfrog.h index 4b4e0adc..8456d55e 100644 --- a/include/xfrog.h +++ b/include/xfrog.h @@ -24,4 +24,8 @@ int xfrog_bulkstat_single(int fd, uint64_t ino, struct xfs_bstat *ubuffer); int xfrog_bulkstat(int fd, uint64_t *lastino, uint32_t icount, struct xfs_bstat *ubuffer, uint32_t *ocount); +struct xfs_inogrp; +int xfrog_inumbers(int fd, uint64_t *lastino, uint32_t icount, + struct xfs_inogrp *ubuffer, uint32_t *ocount); + #endif /* __XFROG_H__ */ diff --git a/io/imap.c b/io/imap.c index fbc8e9e1..69027693 100644 --- a/io/imap.c +++ b/io/imap.c @@ -8,18 +8,19 @@ #include "input.h" #include "init.h" #include "io.h" +#include "xfrog.h" 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 +31,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 = xfrog_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 +40,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 d97903e9..7bc5a2f3 100644 --- a/io/open.c +++ b/io/open.c @@ -669,24 +669,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 (xfrog_inumbers(file->fd, &lastip, IGROUP_NR, igroup, + &ocount)) { perror("XFS_IOC_FSINUMBERS"); return 0; } diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c index c0d3b627..1b08bbbd 100644 --- a/libfrog/bulkstat.c +++ b/libfrog/bulkstat.c @@ -41,3 +41,22 @@ xfrog_bulkstat( return ioctl(fd, XFS_IOC_FSBULKSTAT, &bulkreq); } + +/* Query inode allocation bitmask information. */ +int +xfrog_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..492a06c7 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -15,6 +15,7 @@ #include "xfs_scrub.h" #include "common.h" #include "fscounters.h" +#include "xfrog.h" /* * Filesystem counter collection routines. We can count the number of @@ -41,26 +42,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 = xfrog_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 7950208d..0db16916 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -90,17 +90,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; @@ -109,11 +108,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); @@ -121,8 +115,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 = xfrog_inumbers(ctx->mnt_fd, &igrp_ino, 1, &inogrp, + &igrplen)) == 0 && + igrplen > 0) { /* Load the inodes. */ ino = inogrp.xi_startino - 1; @@ -131,7 +126,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 = xfrog_bulkstat(ctx->mnt_fd, &ino, inogrp.xi_alloccount, bstat, &bulklen); if (error) @@ -155,7 +150,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); @@ -177,8 +172,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 Fri Jun 7 19:28:40 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: 10982627 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 195E013AD for ; Fri, 7 Jun 2019 19:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D40728A8C for ; Fri, 7 Jun 2019 19:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 017D028B45; Fri, 7 Jun 2019 19:28:51 +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 8EBC828A8C for ; Fri, 7 Jun 2019 19:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729941AbfFGT2v (ORCPT ); Fri, 7 Jun 2019 15:28:51 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54544 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfFGT2u (ORCPT ); Fri, 7 Jun 2019 15:28:50 -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 x57JSdGt086514; Fri, 7 Jun 2019 19:28:48 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=+n6QKfpHBCCm1uFXimUIDVdGNUiG7PUFB9nzTOc6o7I=; b=osstoNVrfPo9tZT755lxp/7Ry0wyKtpbREiCEEM2t/KZftW/BE9u1XriIexYc0jEY21T pNj2aooGBbWLtHDEL4jCy1/JrGj1qwoSmpGgJF2R5LgARIT7lzPC3h7200mtHUyxVzQ6 UbDCCS/KILC9sjDmuruBJUXb7W1CHSvE9rhSTTi7E4//9PYztneFcqUapWmWiOS+atSV VXffPPxhoni/cKw+1U59XlftEjdQ+lI/RKqpPmYxIXUPnLAxWTiyNFjJqfa1cDJQYxA9 DHwwHHUWhYSJ5281XXRxwdXiyh4cJ5fpBR6fLo/190+fANrgkPdqd1aUiZvesMxQL9xZ kA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2suj0r02wf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:48 +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 x57JSG9T169294; Fri, 7 Jun 2019 19:28:48 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2swngk6djb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:47 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x57JSkor015114; Fri, 7 Jun 2019 19:28:46 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:46 -0700 Subject: [PATCH 4/6] 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: Fri, 07 Jun 2019 12:28:40 -0700 Message-ID: <155993572084.2343365.4641516689067243354.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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 ddb25ecc..468b8fde 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3033,15 +3033,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 overlaps the next AG's metadata, fail. */ + 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 Fri Jun 7 19:28:51 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: 10982629 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 4C08E13AD for ; Fri, 7 Jun 2019 19:28:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F82228A8C for ; Fri, 7 Jun 2019 19:28:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33DBA28B58; Fri, 7 Jun 2019 19:28:58 +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 D8BAE28A8C for ; Fri, 7 Jun 2019 19:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730212AbfFGT25 (ORCPT ); Fri, 7 Jun 2019 15:28:57 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45142 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfFGT25 (ORCPT ); Fri, 7 Jun 2019 15:28:57 -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 x57JSqQx101191; Fri, 7 Jun 2019 19:28:54 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=1FcslxisFxBOaiidtuYlqyFtIGtX9q7PywYIx7GRbXQ=; b=KwBo+SPQ0YGc0pgwuQ4omcGYlRfUedCZaDSSjeKggu2UeSfsfQvINhUaO9RZewbMifQz PYHkUBKAaYx/jIyUn2+PCewH7xbJkH3F68k7tA9Vq0BxpxeEPWDuNmZYlHk6JYB6QIzu ToX8UAWZPvaOAUMps35vePoJ2/6Ye0WgrmudjFuAb7u4TiDcTOG8qYCry7UQ6OYI/4vr xk0ojmcKwavsSpFhgWwtg9XXIt+eBUSlypN2Du3/ekkL/vRkHXsbexpbDj5CYkW1f6dl 7v/FRaqTnOOtMlclllYlwYBKCwjUAM1OcLUIw9ChkDKN/WnqZwnwGhsir+vJ6P51vT6O HA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2sueve0eby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:54 +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 x57JSGR5169014; Fri, 7 Jun 2019 19:28:54 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2swngn8a43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:53 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x57JSrED005022; Fri, 7 Jun 2019 19:28:53 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:52 -0700 Subject: [PATCH 5/6] xfs_io: repair_f should use its own name From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 07 Jun 2019 12:28:51 -0700 Message-ID: <155993573179.2343365.6485890004354925274.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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 If the repair command fails, it should tag the error message with its own name ("repair"). Signed-off-by: Darrick J. Wong --- io/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/scrub.c b/io/scrub.c index 2ff1a6af..052497be 100644 --- a/io/scrub.c +++ b/io/scrub.c @@ -293,7 +293,7 @@ repair_ioctl( error = ioctl(fd, XFS_IOC_SCRUB_METADATA, &meta); if (error) - perror("scrub"); + perror("repair"); if (meta.sm_flags & XFS_SCRUB_OFLAG_CORRUPT) printf(_("Corruption remains.\n")); if (meta.sm_flags & XFS_SCRUB_OFLAG_PREEN) From patchwork Fri Jun 7 19:28:58 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: 10982631 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 D059992A for ; Fri, 7 Jun 2019 19:29:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C497228A8C for ; Fri, 7 Jun 2019 19:29:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8E2B28B49; Fri, 7 Jun 2019 19:29:03 +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 A9D9028A8C for ; Fri, 7 Jun 2019 19:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730155AbfFGT3C (ORCPT ); Fri, 7 Jun 2019 15:29:02 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45270 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfFGT3C (ORCPT ); Fri, 7 Jun 2019 15:29:02 -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 x57JShGD101131; Fri, 7 Jun 2019 19:29:00 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=a4Ae/ui4mUzj5LTuy5Kzv3nR5vwNUiZsRpdH/6w0om4=; b=hDp/qs/T8Z1ZVRoTMxO2U2aTQCD99AEztNVOjgXTC5XLaiqqdYhEelmXfbTlKUsIvV4v 4hVGVToo4II7LtVM/GS/IXndZWL9i3673bMgMvTGIe6sUUdpQhynscBFTjUKrXHnj08q scJ1Pl/BNO+wdR7pnSqpXhkR6wwMZFWNogDb8CFk1xaekIQdoXMGCIk0jSrVOQG6ny6a i21jrS3J9eNq4KIa+EX5UpSq4JMdI7uI6tQIq93AKUmwqlTro00fIV+J2R9JbAB1a3Tc WYznaviKKIv0WN4WLXysRQlmVSN/q/Vxbi2CQatN4k8EpnbAJs4KUTC5tVL/Lu62aoGu gg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 2sueve0ecq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:29:00 +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 x57JSxIS129578; Fri, 7 Jun 2019 19:28:59 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2swnhde792-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 Jun 2019 19:28:59 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x57JSxji030886; Fri, 7 Jun 2019 19:28:59 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 Jun 2019 12:28:59 -0700 Subject: [PATCH 6/6] libxfs-diff: try harder to find the kernel equivalent libxfs files From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 07 Jun 2019 12:28:58 -0700 Message-ID: <155993573805.2343365.14121664229730887571.stgit@magnolia> In-Reply-To: <155993569512.2343365.15510991248022865602.stgit@magnolia> References: <155993569512.2343365.15510991248022865602.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9281 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-1906070130 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're syncing userspace libxfs/ files with kernel fs/xfs/ files, teach the diff tool to try fs/xfs/xfs_foo.c if fs/xfs/libxfs/xfs_foo.c doesn't exist. Signed-off-by: Darrick J. Wong --- tools/libxfs-diff | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/libxfs-diff b/tools/libxfs-diff index fa57c004..c18ad487 100755 --- a/tools/libxfs-diff +++ b/tools/libxfs-diff @@ -22,5 +22,6 @@ dir="$(readlink -m "${dir}/..")" for i in libxfs/xfs*.[ch]; do kfile="${dir}/$i" + test -f "${kfile}" || kfile="$(echo "${kfile}" | sed -e 's|libxfs/||g')" diff -Naurpw --label "$i" <(sed -e '/#include/d' "$i") --label "${kfile}" <(sed -e '/#include/d' "${kfile}") done