From patchwork Mon Aug 26 21:27: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: 11115619 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8C6514DE for ; Mon, 26 Aug 2019 21:28:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 927A52186A for ; Mon, 26 Aug 2019 21:28:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hbr3V0VD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbfHZV2F (ORCPT ); Mon, 26 Aug 2019 17:28:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59380 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728112AbfHZV2F (ORCPT ); Mon, 26 Aug 2019 17:28:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7QLDmf1000868; Mon, 26 Aug 2019 21:28: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-2019-08-05; bh=lXl/EZt+NlB4kvOJl5Wv/QVDLh5QNXE/AArW5ColAIM=; b=hbr3V0VDYpLg3zEfbYllWBjNrSdTyuHwvQs21UQkPX2sk9vMFXzbbVSr3mRsMRwjtUHX kKgLpcCymFDL5ao+j8yEK3KpPP0Iv3cCqEHUbhbMqqdIdVTCXak3g1Gpux49InxEIBHD i3RF/oHnGgNrzgWPXCRtnUkf/75tJi48Sf8IjKG2F6N2zrk+bZ+GeHyYQW7L4obWJ0uD xmoeRYTzI05GpKfViMP5srgCwColkYewKw59eS24Ik+RAkKmoD3h1pQ/BaGzmziVCh66 vnmWMlPKPYmHK+c/iOsPEfkjKk1zPOXAc499iDE9WQx3I1Q2+q30C1bHCBBN+/hAoXF4 7Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2umpxx0556-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:27:59 +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 x7QLIRKR025044; Mon, 26 Aug 2019 21:27:59 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2umj1tk3yg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:27:58 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLRvdf005357; Mon, 26 Aug 2019 21:27:57 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:27:55 -0700 Subject: [PATCH 1/4] xfs_io: add a bulkstat command From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Aug 2019 14:27:54 -0700 Message-ID: <156685487465.2841421.358121830253489458.stgit@magnolia> In-Reply-To: <156685486843.2841421.7117771040713668517.stgit@magnolia> References: <156685486843.2841421.7117771040713668517.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Add a bulkstat command to xfs_io so that we can test our new xfrog code. Signed-off-by: Darrick J. Wong --- include/xfrog.h | 3 io/Makefile | 9 - io/bulkstat.c | 525 ++++++++++++++++++++++++++++++++++++++++++++++++++++ io/init.c | 1 io/io.h | 1 libfrog/bulkstat.c | 20 ++ man/man8/xfs_io.8 | 68 +++++++ 7 files changed, 623 insertions(+), 4 deletions(-) create mode 100644 io/bulkstat.c diff --git a/include/xfrog.h b/include/xfrog.h index 0dcee510..df7cfdf6 100644 --- a/include/xfrog.h +++ b/include/xfrog.h @@ -188,11 +188,14 @@ void xfrog_bulkstat_to_bstat(struct xfs_fd *xfd, struct xfs_bstat *bs1, void xfrog_bstat_to_bulkstat(struct xfs_fd *xfd, struct xfs_bulkstat *bstat, const struct xfs_bstat *bs1); +void xfrog_bulkstat_set_ag(struct xfs_bulkstat_req *req, uint32_t agno); + struct xfs_inogrp; int xfrog_inumbers(struct xfs_fd *xfd, struct xfs_inumbers_req *req); struct xfs_inumbers_req *xfrog_inumbers_alloc_req(uint32_t nr, uint64_t startino); +void xfrog_inumbers_set_ag(struct xfs_inumbers_req *req, uint32_t agno); void xfrog_inumbers_to_inogrp(struct xfs_inogrp *ig1, const struct xfs_inumbers *ig); void xfrog_inogrp_to_inumbers(struct xfs_inumbers *ig, diff --git a/io/Makefile b/io/Makefile index 484e2b5a..1112605e 100644 --- a/io/Makefile +++ b/io/Makefile @@ -9,10 +9,11 @@ LTCOMMAND = xfs_io LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh HFILES = init.h io.h CFILES = init.c \ - attr.c bmap.c crc32cselftest.c cowextsize.c encrypt.c file.c freeze.c \ - fsync.c getrusage.c imap.c inject.c label.c link.c mmap.c open.c \ - parent.c pread.c prealloc.c pwrite.c reflink.c resblks.c scrub.c \ - seek.c shutdown.c stat.c swapext.c sync.c truncate.c utimes.c + attr.c bmap.c bulkstat.c crc32cselftest.c cowextsize.c encrypt.c \ + file.c freeze.c fsync.c getrusage.c imap.c inject.c label.c link.c \ + mmap.c open.c parent.c pread.c prealloc.c pwrite.c reflink.c \ + resblks.c scrub.c seek.c shutdown.c stat.c swapext.c sync.c \ + truncate.c utimes.c LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) diff --git a/io/bulkstat.c b/io/bulkstat.c new file mode 100644 index 00000000..7944a0fa --- /dev/null +++ b/io/bulkstat.c @@ -0,0 +1,525 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Oracle. All Rights Reserved. + * Author: Darrick J. Wong + */ +#include "platform_defs.h" +#include "command.h" +#include "init.h" +#include "path.h" +#include "io.h" +#include "input.h" +#include "xfrog.h" + +static bool debug; + +static void +dump_bulkstat_time( + const char *tag, + uint64_t sec, + uint32_t nsec) +{ + printf("\t%s = %"PRIu64".%"PRIu32"\n", tag, sec, nsec); +} + +static void +dump_bulkstat( + struct xfs_bulkstat *bstat) +{ + printf("bs_ino = %"PRIu64"\n", bstat->bs_ino); + printf("\tbs_size = %"PRIu64"\n", bstat->bs_size); + + printf("\tbs_blocks = %"PRIu64"\n", bstat->bs_blocks); + printf("\tbs_xflags = 0x%"PRIx64"\n", bstat->bs_xflags); + + dump_bulkstat_time("bs_atime", bstat->bs_atime, bstat->bs_atime_nsec); + dump_bulkstat_time("bs_ctime", bstat->bs_ctime, bstat->bs_ctime_nsec); + dump_bulkstat_time("bs_mtime", bstat->bs_mtime, bstat->bs_mtime_nsec); + dump_bulkstat_time("bs_btime", bstat->bs_btime, bstat->bs_btime_nsec); + + printf("\tbs_gen = 0x%"PRIx32"\n", bstat->bs_gen); + printf("\tbs_uid = %"PRIu32"\n", bstat->bs_uid); + printf("\tbs_gid = %"PRIu32"\n", bstat->bs_gid); + printf("\tbs_projectid = %"PRIu32"\n", bstat->bs_projectid); + + printf("\tbs_blksize = %"PRIu32"\n", bstat->bs_blksize); + printf("\tbs_rdev = %"PRIu32"\n", bstat->bs_rdev); + printf("\tbs_cowextsize_blks = %"PRIu32"\n", bstat->bs_cowextsize_blks); + printf("\tbs_extsize_blks = %"PRIu32"\n", bstat->bs_extsize_blks); + + printf("\tbs_nlink = %"PRIu32"\n", bstat->bs_nlink); + printf("\tbs_extents = %"PRIu32"\n", bstat->bs_extents); + printf("\tbs_aextents = %"PRIu32"\n", bstat->bs_aextents); + printf("\tbs_version = %"PRIu16"\n", bstat->bs_version); + printf("\tbs_forkoff = %"PRIu16"\n", bstat->bs_forkoff); + + printf("\tbs_sick = 0x%"PRIx16"\n", bstat->bs_sick); + printf("\tbs_checked = 0x%"PRIx16"\n", bstat->bs_checked); + printf("\tbs_mode = 0%"PRIo16"\n", bstat->bs_mode); +}; + +static void +bulkstat_help(void) +{ + printf(_( +"Bulk-queries the filesystem for inode stat information and prints it.\n" +"\n" +" -a Only iterate this AG.\n" +" -d Print debugging output.\n" +" -e Stop after this inode.\n" +" -n Ask for this many results at once.\n" +" -s Inode to start with.\n" +" -v Use this version of the ioctl (1 or 5).\n")); +} + +static int +bulkstat_f( + int argc, + char **argv) +{ + struct xfs_fd xfd = XFS_FD_INIT(file->fd); + struct xfs_bulkstat_req *breq; + unsigned long long startino = 0; + unsigned long long endino = -1ULL; + unsigned long batch_size = 4096; + unsigned long agno = 0; + unsigned long ver = 0; + bool has_agno = false; + unsigned int i; + int c; + int error; + + while ((c = getopt(argc, argv, "a:cde:n:qs:v:")) != -1) { + switch (c) { + case 'a': + errno = 0; + agno = strtoul(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + has_agno = true; + break; + case 'd': + debug = true; + break; + case 'e': + errno = 0; + endino = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 'n': + errno = 0; + batch_size = strtoul(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 's': + errno = 0; + startino = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 'v': + errno = 0; + ver = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + if (ver != 1 && ver != 5) { + fprintf(stderr, "version must be 1 or 5.\n"); + return 1; + } + break; + default: + bulkstat_help(); + return 0; + } + } + if (optind != argc) { + bulkstat_help(); + return 0; + } + + error = xfrog_prepare_geometry(&xfd); + if (error) { + perror("xfrog_prepare_geometry"); + exitcode = 1; + return 0; + } + + breq = xfrog_bulkstat_alloc_req(batch_size, startino); + if (!breq) { + perror("alloc bulkreq"); + exitcode = 1; + return 0; + } + + if (has_agno) + xfrog_bulkstat_set_ag(breq, agno); + + switch (ver) { + case 1: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V1; + break; + case 5: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V5; + break; + default: + break; + } + + while ((error = xfrog_bulkstat(&xfd, breq)) == 0) { + if (debug) + printf( +_("bulkstat: startino=%lld flags=0x%x agno=%u ret=%d icount=%u ocount=%u\n"), + (long long)breq->hdr.ino, + (unsigned int)breq->hdr.flags, + (unsigned int)breq->hdr.agno, + error, + (unsigned int)breq->hdr.icount, + (unsigned int)breq->hdr.ocount); + if (breq->hdr.ocount == 0) + break; + + for (i = 0; i < breq->hdr.ocount; i++) { + if (breq->bulkstat[i].bs_ino > endino) + break; + dump_bulkstat(&breq->bulkstat[i]); + } + } + if (error) { + perror("xfrog_bulkstat"); + exitcode = 1; + return 0; + } + + free(breq); + return 0; +} + +static void +bulkstat_single_help(void) +{ + printf(_( +"Queries the filesystem for a single inode's stat information and prints it.\n" +"\n" +" -v Use this version of the ioctl (1 or 5).\n" +"\n" +"Pass in inode numbers or a special inode name:\n" +" root Root directory.\n")); +} + +struct single_map { + const char *tag; + uint64_t code; +}; + +struct single_map tags[] = { + {"root", XFS_BULK_IREQ_SPECIAL_ROOT}, + {NULL, 0}, +}; + +static int +bulkstat_single_f( + int argc, + char **argv) +{ + struct xfs_fd xfd = XFS_FD_INIT(file->fd); + struct xfs_bulkstat bulkstat; + unsigned long ver = 0; + unsigned int i; + int c; + int error; + + while ((c = getopt(argc, argv, "v:")) != -1) { + switch (c) { + case 'v': + errno = 0; + ver = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + if (ver != 1 && ver != 5) { + fprintf(stderr, "version must be 1 or 5.\n"); + return 1; + } + break; + default: + bulkstat_single_help(); + return 0; + } + } + + error = xfrog_prepare_geometry(&xfd); + if (error) { + perror("xfrog_prepare_geometry"); + exitcode = 1; + return 0; + } + + switch (ver) { + case 1: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V1; + break; + case 5: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V5; + break; + default: + break; + } + + for (i = optind; i < argc; i++) { + struct single_map *sm = tags; + uint64_t ino; + unsigned int flags = 0; + + /* Try to look up our tag... */ + for (sm = tags; sm->tag; sm++) { + if (!strcmp(argv[i], sm->tag)) { + ino = sm->code; + flags |= XFS_BULK_IREQ_SPECIAL; + break; + } + } + + /* ...or else it's an inode number. */ + if (sm->tag == NULL) { + errno = 0; + ino = strtoull(argv[i], NULL, 10); + if (errno) { + perror(argv[i]); + exitcode = 1; + return 0; + } + } + + error = xfrog_bulkstat_single(&xfd, ino, flags, &bulkstat); + if (error) { + perror("xfrog_bulkstat_single"); + continue; + } + + if (debug) + printf( +_("bulkstat_single: startino=%"PRIu64" flags=0x%"PRIx32" ret=%d\n"), + ino, flags, error); + + dump_bulkstat(&bulkstat); + } + + return 0; +} + +static void +dump_inumbers( + struct xfs_inumbers *inumbers) +{ + printf("xi_startino = %"PRIu64"\n", inumbers->xi_startino); + printf("\txi_allocmask = 0x%"PRIx64"\n", inumbers->xi_allocmask); + printf("\txi_alloccount = %"PRIu8"\n", inumbers->xi_alloccount); + printf("\txi_version = %"PRIu8"\n", inumbers->xi_version); +} + +static void +inumbers_help(void) +{ + printf(_( +"Queries the filesystem for inode group information and prints it.\n" +"\n" +" -a Only iterate this AG.\n" +" -d Print debugging output.\n" +" -e Stop after this inode.\n" +" -n Ask for this many results at once.\n" +" -s Inode to start with.\n" +" -v Use this version of the ioctl (1 or 5).\n")); +} + +static int +inumbers_f( + int argc, + char **argv) +{ + struct xfs_fd xfd = XFS_FD_INIT(file->fd); + struct xfs_inumbers_req *ireq; + unsigned long long startino = 0; + unsigned long long endino = -1ULL; + unsigned long batch_size = 4096; + unsigned long agno = 0; + unsigned long ver = 0; + bool has_agno = false; + unsigned int i; + int c; + int error; + + while ((c = getopt(argc, argv, "a:cde:n:qs:v:")) != -1) { + switch (c) { + case 'a': + errno = 0; + agno = strtoul(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + has_agno = true; + break; + case 'd': + debug = true; + break; + case 'e': + errno = 0; + endino = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 'n': + errno = 0; + batch_size = strtoul(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 's': + errno = 0; + startino = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + break; + case 'v': + errno = 0; + ver = strtoull(optarg, NULL, 10); + if (errno) { + perror(optarg); + return 1; + } + if (ver != 1 && ver != 5) { + fprintf(stderr, "version must be 1 or 5.\n"); + return 1; + } + break; + default: + bulkstat_help(); + return 0; + } + } + if (optind != argc) { + bulkstat_help(); + return 0; + } + + error = xfrog_prepare_geometry(&xfd); + if (error) { + perror("xfrog_prepare_geometry"); + exitcode = 1; + return 0; + } + + ireq = xfrog_inumbers_alloc_req(batch_size, startino); + if (!ireq) { + perror("alloc inumbersreq"); + exitcode = 1; + return 0; + } + + if (has_agno) + xfrog_inumbers_set_ag(ireq, agno); + + switch (ver) { + case 1: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V1; + break; + case 5: + xfd.flags |= XFROG_FLAG_BULKSTAT_FORCE_V5; + break; + default: + break; + } + + while ((error = xfrog_inumbers(&xfd, ireq)) == 0) { + if (debug) + printf( +_("bulkstat: startino=%"PRIu64" flags=0x%"PRIx32" agno=%"PRIu32" ret=%d icount=%"PRIu32" ocount=%"PRIu32"\n"), + ireq->hdr.ino, + ireq->hdr.flags, + ireq->hdr.agno, + error, + ireq->hdr.icount, + ireq->hdr.ocount); + if (ireq->hdr.ocount == 0) + break; + + for (i = 0; i < ireq->hdr.ocount; i++) { + if (ireq->inumbers[i].xi_startino > endino) + break; + dump_inumbers(&ireq->inumbers[i]); + } + } + if (error) { + perror("xfrog_inumbers"); + exitcode = 1; + return 0; + } + + free(ireq); + return 0; +} + +static cmdinfo_t bulkstat_cmd = { + .name = "bulkstat", + .cfunc = bulkstat_f, + .argmin = 0, + .argmax = -1, + .flags = CMD_NOMAP_OK, + .help = bulkstat_help, +}; + +static cmdinfo_t bulkstat_single_cmd = { + .name = "bulkstat_single", + .cfunc = bulkstat_single_f, + .argmin = 0, + .argmax = -1, + .flags = CMD_NOMAP_OK, + .help = bulkstat_single_help, +}; + +static cmdinfo_t inumbers_cmd = { + .name = "inumbers", + .cfunc = inumbers_f, + .argmin = 0, + .argmax = -1, + .flags = CMD_NOMAP_OK, + .help = inumbers_help, +}; + +void +bulkstat_init(void) +{ + bulkstat_cmd.args = + _("[-a agno] [-d] [-e endino] [-n batchsize] [-s startino]"); + bulkstat_cmd.oneline = _("Bulk stat of inodes in a filesystem"); + + bulkstat_single_cmd.args = _("inum..."); + bulkstat_single_cmd.oneline = _("Stat one inode in a filesystem"); + + inumbers_cmd.args = + _("[-a agno] [-d] [-e endino] [-n batchsize] [-s startino]"); + inumbers_cmd.oneline = _("Query inode groups in a filesystem"); + + add_command(&bulkstat_cmd); + add_command(&bulkstat_single_cmd); + add_command(&inumbers_cmd); +} diff --git a/io/init.c b/io/init.c index 7025aea5..033ed67d 100644 --- a/io/init.c +++ b/io/init.c @@ -46,6 +46,7 @@ init_commands(void) { attr_init(); bmap_init(); + bulkstat_init(); copy_range_init(); cowextsize_init(); encrypt_init(); diff --git a/io/io.h b/io/io.h index 0848ab98..5b21b0ca 100644 --- a/io/io.h +++ b/io/io.h @@ -183,3 +183,4 @@ extern void log_writes_init(void); extern void scrub_init(void); extern void repair_init(void); extern void crc32cselftest_init(void); +extern void bulkstat_init(void); diff --git a/libfrog/bulkstat.c b/libfrog/bulkstat.c index 26db9af2..00100491 100644 --- a/libfrog/bulkstat.c +++ b/libfrog/bulkstat.c @@ -384,6 +384,16 @@ xfrog_bulkstat_alloc_req( return breq; } +/* Set a bulkstat cursor to iterate only a particular AG. */ +void +xfrog_bulkstat_set_ag( + struct xfs_bulkstat_req *req, + uint32_t agno) +{ + req->hdr.agno = agno; + req->hdr.flags |= XFS_BULK_IREQ_AGNO; +} + /* Convert an inumbers (v5) struct to a inogrp (v1) struct. */ void xfrog_inumbers_to_inogrp( @@ -501,3 +511,13 @@ xfrog_inumbers_alloc_req( return ireq; } + +/* Set an inumbers cursor to iterate only a particular AG. */ +void +xfrog_inumbers_set_ag( + struct xfs_inumbers_req *req, + uint32_t agno) +{ + req->hdr.agno = agno; + req->hdr.flags |= XFS_BULK_IREQ_AGNO; +} diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8 index 6e064bdd..8fd3ffbe 100644 --- a/man/man8/xfs_io.8 +++ b/man/man8/xfs_io.8 @@ -996,6 +996,45 @@ for the current memory mapping. .SH FILESYSTEM COMMANDS .TP +.BI "bulkstat [ \-a " agno " ] [ \-d ] [ \-e " endino " ] [ \-n " batchsize " ] [ \-s " startino " ] +Display raw stat information about a bunch of inodes in an XFS filesystem. +Options are as follows: +.RS 1.0i +.PD 0 +.TP +.BI \-a " agno" +Display only results from the given allocation group. +Defaults to zero. +.TP +.BI \-d +Print debugging information about call results. +.TP +.BI \-e " endino" +Stop displaying records when this inode number is reached. +Defaults to stopping when the system call stops returning results. +.TP +.BI \-n " batchsize" +Retrieve at most this many records per call. +.TP +.BI \-s " startino" +Display inode allocation records starting with this inode. +Defaults to zero. +If this value is zero, then display starts with the allocation group +given above. +.RE +.PD +.TP +.BI "bulkstat_single [ " inum... " | " special... " ] +Display raw stat information about individual inodes in an XFS filesystem. +Arguments must be inode numbers or any of the special values: +.RS 1.0i +.PD 0 +.TP +.B root +Display information about the root directory inode. +.RE +.PD +.TP .B freeze Suspend all write I/O requests to the filesystem of the current file. Only available in expert mode and requires privileges. @@ -1067,6 +1106,35 @@ was specified on the command line, the maximum possible inode number in the system will be printed along with its size. .PD .TP +.BI "inumbers [ \-a " agno " ] [ \-d ] [ \-e " endino " ] [ \-n " batchsize " ] [ \-s " startino " ] +Prints allocation information about groups of inodes in an XFS filesystem. +Callers can use this information to figure out which inodes are allocated. +Options are as follows: +.RS 1.0i +.PD 0 +.TP +.BI \-a " agno" +Display only results from the given allocation group. +Defaults to zero. +.TP +.BI \-d +Print debugging information about call results. +.TP +.BI \-e " endino" +Stop displaying records when this inode number is reached. +Defaults to stopping when the system call stops returning results. +.TP +.BI \-n " batchsize" +Retrieve at most this many records per call. +.TP +.BI \-s " startino" +Display inode allocation records starting with this inode. +Defaults to zero. +If this value is zero, then display starts with the allocation group +given above. +.RE +.PD +.TP .BI "scrub " type " [ " agnumber " | " "ino" " " "gen" " ]" Scrub internal XFS filesystem metadata. The .BI type From patchwork Mon Aug 26 21:28:02 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: 11115621 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2B5514DE for ; Mon, 26 Aug 2019 21:28:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 916F021872 for ; Mon, 26 Aug 2019 21:28:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="h3ycq5Fg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbfHZV2H (ORCPT ); Mon, 26 Aug 2019 17:28:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59470 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728112AbfHZV2H (ORCPT ); Mon, 26 Aug 2019 17:28:07 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7QLDlYV000849; Mon, 26 Aug 2019 21:28: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-2019-08-05; bh=6GcM6GFqTlK2NYMqB8Mysdgv7/cyTxcb+KqVwCc9xzw=; b=h3ycq5Fgqxh8uEMXFvI2wFVvhks6bJM980AAOL+fYXTwJ9xro3Ur8DCZyVfvoBxkq8bt 7jZamuzFfn/z+TejhTxWM9yWRkDYDC6JK9fZqAWZLWw2SGMwuMi2k1uKWU2ZEyi+U7C5 r7wvpQIMxQN4zK01IieQHiUUb1HHA4JOYExMTDr/HEdjpN4AaIvghqJUEHgBAbO8cnej 72yhVD7aiafd41KXtEsTt+Ipflcm7yPqWy3OJ6atOTCj9Qm0nKOjPlw20Thj/tWyC2e5 W/43rt8mUD6OKQldzQnOO+hit0E5rrjTj/5jKhVjOkEHXfDhrMC+m63QjBregdIIO+s8 kQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2umpxx055q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:04 +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 x7QLIdJw169670; Mon, 26 Aug 2019 21:28:04 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2umhu7wxv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:04 +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 x7QLS4UJ005406; Mon, 26 Aug 2019 21:28:04 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:28:04 -0700 Subject: [PATCH 2/4] xfs_spaceman: remove open-coded per-ag bulkstat From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Aug 2019 14:28:02 -0700 Message-ID: <156685488294.2841421.13810601288995238059.stgit@magnolia> In-Reply-To: <156685486843.2841421.7117771040713668517.stgit@magnolia> References: <156685486843.2841421.7117771040713668517.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Now that xfrog_bulkstat supports per-AG bulkstat, we can get rid of the open coded one in spaceman. Signed-off-by: Darrick J. Wong --- spaceman/health.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/spaceman/health.c b/spaceman/health.c index ff03d074..43b99044 100644 --- a/spaceman/health.c +++ b/spaceman/health.c @@ -265,28 +265,22 @@ report_bulkstat_health( { struct xfs_bulkstat_req *breq; char descr[256]; - uint64_t startino = 0; - uint64_t lastino = -1ULL; uint32_t i; int error; - if (agno != NULLAGNUMBER) { - startino = xfrog_agino_to_ino(&file->xfd, agno, 0); - lastino = xfrog_agino_to_ino(&file->xfd, agno + 1, 0) - 1; - } - - breq = xfrog_bulkstat_alloc_req(128, startino); + breq = xfrog_bulkstat_alloc_req(128, 0); if (!breq) { perror("bulk alloc req"); exitcode = 1; return 1; } + if (agno != NULLAGNUMBER) + xfrog_bulkstat_set_ag(breq, agno); + while ((error = xfrog_bulkstat(&file->xfd, breq) == 0) && breq->hdr.ocount > 0) { for (i = 0; i < breq->hdr.ocount; i++) { - if (breq->bulkstat[i].bs_ino > lastino) - goto out; snprintf(descr, sizeof(descr) - 1, _("inode %"PRIu64), breq->bulkstat[i].bs_ino); report_sick(descr, inode_flags, @@ -294,7 +288,7 @@ report_bulkstat_health( breq->bulkstat[i].bs_checked); } } -out: + free(breq); return error; } From patchwork Mon Aug 26 21:28:09 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: 11115623 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BED5A14E5 for ; Mon, 26 Aug 2019 21:28:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9297121872 for ; Mon, 26 Aug 2019 21:28:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dZ8PuXuS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728402AbfHZV2P (ORCPT ); Mon, 26 Aug 2019 17:28:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47624 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728112AbfHZV2P (ORCPT ); Mon, 26 Aug 2019 17:28:15 -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 x7QLFIu0162223; Mon, 26 Aug 2019 21:28:12 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-2019-08-05; bh=yZUVfoBSfpGRbLZug5wtfLE/WtdyQfQKvcoGxtk7qkg=; b=dZ8PuXuSPjAB2+sQpdLE23k+OBdHLerrfgVdnFZuTUd89T9jNb0lvlBmTNk0XggPay90 IKby/kRG+fUOnTlEVcXUNbMYdsoSq0N++zcArn5lbwFE53CiJv2q0siGJnba78dPlDHC PEhyNEC0+CJBqPc9RMRIbefKGr9Kgz9hXg+dS+2IwsOwSPpdYy4pu7H4NrNQ57jZTAKo jSWI8ErMSNWxk24WL/ScvyQJgxdX9KIhnEPhM5kdF2/IMY4hbrpKN3bYw70koQhuaOpG MBnBdZc+DW5aqRHDa+mjgy1HCjUFMdBa2fexRzzESG26jce52rMCHE8zY7JLzde+iAh4 Ow== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2umq5t81x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:12 +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 x7QLIt3p185073; Mon, 26 Aug 2019 21:28:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2umj2xvw3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:11 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLSAu7027938; Mon, 26 Aug 2019 21:28:10 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:28:10 -0700 Subject: [PATCH 3/4] xfs_scrub: convert to per-ag inode bulkstat operations From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Aug 2019 14:28:09 -0700 Message-ID: <156685488926.2841421.6064707653494434162.stgit@magnolia> In-Reply-To: <156685486843.2841421.7117771040713668517.stgit@magnolia> References: <156685486843.2841421.7117771040713668517.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Now that we're done reworking the xfrog bulkstat wrapper functions, we can adapt xfs_scrub to use the per-ag iteration functionality. Signed-off-by: Darrick J. Wong --- scrub/fscounters.c | 22 ++++++---------------- scrub/inodes.c | 20 ++++++-------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/scrub/fscounters.c b/scrub/fscounters.c index d95418ba..91487ebc 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -35,29 +35,25 @@ struct xfs_count_inodes { * exist in the filesystem, assuming we've already scrubbed that. */ static bool -xfs_count_inodes_range( +xfs_count_inodes_ag( struct scrub_ctx *ctx, const char *descr, - uint64_t first_ino, - uint64_t last_ino, + uint32_t agno, uint64_t *count) { struct xfs_inumbers_req *ireq; uint64_t nr = 0; int error; - ASSERT(!(first_ino & (XFS_INODES_PER_CHUNK - 1))); - ASSERT((last_ino & (XFS_INODES_PER_CHUNK - 1))); - - ireq = xfrog_inumbers_alloc_req(1, first_ino); + ireq = xfrog_inumbers_alloc_req(1, 0); if (!ireq) { str_info(ctx, descr, _("Insufficient memory; giving up.")); return false; } + xfrog_inumbers_set_ag(ireq, agno); while (!(error = xfrog_inumbers(&ctx->mnt, ireq))) { - if (ireq->hdr.ocount == 0 || - ireq->inumbers[0].xi_startino >= last_ino) + if (ireq->hdr.ocount == 0) break; nr += ireq->inumbers[0].xi_alloccount; } @@ -83,8 +79,6 @@ xfs_count_ag_inodes( struct xfs_count_inodes *ci = arg; struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx; char descr[DESCR_BUFSZ]; - uint64_t ag_ino; - uint64_t next_ag_ino; bool moveon; snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u inodes"), @@ -92,11 +86,7 @@ xfs_count_ag_inodes( minor(ctx->fsinfo.fs_datadev), agno); - ag_ino = xfrog_agino_to_ino(&ctx->mnt, agno, 0); - next_ag_ino = xfrog_agino_to_ino(&ctx->mnt, agno + 1, 0); - - moveon = xfs_count_inodes_range(ctx, descr, ag_ino, next_ag_ino - 1, - &ci->counters[agno]); + moveon = xfs_count_inodes_ag(ctx, descr, agno, &ci->counters[agno]); if (!moveon) ci->moveon = false; } diff --git a/scrub/inodes.c b/scrub/inodes.c index bcdc60b9..ae59d7ef 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -81,12 +81,11 @@ xfs_iterate_inodes_range_check( * but we also can detect iget failures. */ static bool -xfs_iterate_inodes_range( +xfs_iterate_inodes_ag( struct scrub_ctx *ctx, const char *descr, void *fshandle, - uint64_t first_ino, - uint64_t last_ino, + uint32_t agno, xfs_inode_iter_fn fn, void *arg) { @@ -113,13 +112,14 @@ xfs_iterate_inodes_range( return false; } - ireq = xfrog_inumbers_alloc_req(1, first_ino); + ireq = xfrog_inumbers_alloc_req(1, 0); if (!ireq) { str_info(ctx, descr, _("Insufficient memory; giving up.")); free(breq); return false; } inogrp = &ireq->inumbers[0]; + xfrog_inumbers_set_ag(ireq, agno); /* Find the inode chunk & alloc mask */ error = xfrog_inumbers(&ctx->mnt, ireq); @@ -144,9 +144,6 @@ xfs_iterate_inodes_range( for (i = 0, bs = breq->bulkstat; i < inogrp->xi_alloccount; i++, bs++) { - if (bs->bs_ino > last_ino) - goto out; - handle.ha_fid.fid_ino = bs->bs_ino; handle.ha_fid.fid_gen = bs->bs_gen; error = fn(ctx, &handle, bs, arg); @@ -211,8 +208,6 @@ xfs_scan_ag_inodes( struct xfs_scan_inodes *si = arg; struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx; char descr[DESCR_BUFSZ]; - uint64_t ag_ino; - uint64_t next_ag_ino; bool moveon; snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u inodes"), @@ -220,11 +215,8 @@ xfs_scan_ag_inodes( minor(ctx->fsinfo.fs_datadev), agno); - ag_ino = xfrog_agino_to_ino(&ctx->mnt, agno, 0); - next_ag_ino = xfrog_agino_to_ino(&ctx->mnt, agno + 1, 0); - - moveon = xfs_iterate_inodes_range(ctx, descr, ctx->fshandle, ag_ino, - next_ag_ino - 1, si->fn, si->arg); + moveon = xfs_iterate_inodes_ag(ctx, descr, ctx->fshandle, agno, + si->fn, si->arg); if (!moveon) si->moveon = false; } From patchwork Mon Aug 26 21:28:15 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: 11115625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EEC014E5 for ; Mon, 26 Aug 2019 21:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DE8D21881 for ; Mon, 26 Aug 2019 21:28:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="PKfy6TSn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbfHZV2U (ORCPT ); Mon, 26 Aug 2019 17:28:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:49724 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbfHZV2T (ORCPT ); Mon, 26 Aug 2019 17:28:19 -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 x7QLQwiP003384; Mon, 26 Aug 2019 21:28:18 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-2019-08-05; bh=43jIuszhxPag7Psx0A0SSz19qWl2pEv1GC6O2qrQx40=; b=PKfy6TSn9Sj/yATQrrR2wX21yPgeXqZr6SHupgSjYVoOI4D3DNG75Ssnc4LWKC/g4pX+ Xs67L5ZQOEr/Bv4cUUzKmOyfUjIjeXsbxFXe/uofB/osRgxrfj2VviEqkPl7KAWRmNyd e9i5o0T3EQS3QtFxrdt+DybXoZGC3OJESkySSCFROcBhFsqB1EkVLT5+AQpL8ryVo0m3 RoivQxWvsSIGGybmyWHlyuHUPY/ZyhHthuPFc85dBLCVLqyZ6VTTl7K6PJvq+ueRdkcu 4Zxh7x9Mq/5fqBocWjYMXOpTQLSt0mzIqvm1N4smnev7aGFGqApq2P6q3lKe9PPSa2Cs vw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2umqbe806v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:17 +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 x7QLIsDh184971; Mon, 26 Aug 2019 21:28:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2umj2xvw54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:28:16 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLSGkn005663; Mon, 26 Aug 2019 21:28:16 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:28:16 -0700 Subject: [PATCH 4/4] xfs_scrub: batch inumbers calls during fscounters calculation From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 26 Aug 2019 14:28:15 -0700 Message-ID: <156685489550.2841421.9905052854315806096.stgit@magnolia> In-Reply-To: <156685486843.2841421.7117771040713668517.stgit@magnolia> References: <156685486843.2841421.7117771040713668517.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 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-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Improve the efficiency of the phase 7 inode counts by batching requests, now that we have per-AG inumbers wrappers. Signed-off-by: Darrick J. Wong --- scrub/fscounters.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scrub/fscounters.c b/scrub/fscounters.c index 91487ebc..c90143c0 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -43,9 +43,10 @@ xfs_count_inodes_ag( { struct xfs_inumbers_req *ireq; uint64_t nr = 0; + unsigned int i; int error; - ireq = xfrog_inumbers_alloc_req(1, 0); + ireq = xfrog_inumbers_alloc_req(64, 0); if (!ireq) { str_info(ctx, descr, _("Insufficient memory; giving up.")); return false; @@ -55,7 +56,8 @@ xfs_count_inodes_ag( while (!(error = xfrog_inumbers(&ctx->mnt, ireq))) { if (ireq->hdr.ocount == 0) break; - nr += ireq->inumbers[0].xi_alloccount; + for (i = 0; i < ireq->hdr.ocount; i++) + nr += ireq->inumbers[i].xi_alloccount; } free(ireq);