From patchwork Fri Sep 6 03:39:01 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: 11134387 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 885FB76 for ; Fri, 6 Sep 2019 03:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 742D220842 for ; Fri, 6 Sep 2019 03:39:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Fb0LTGNX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392158AbfIFDjG (ORCPT ); Thu, 5 Sep 2019 23:39:06 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45374 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392154AbfIFDjF (ORCPT ); Thu, 5 Sep 2019 23:39: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 x863d4vc077747; Fri, 6 Sep 2019 03:39:04 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=Njd0ftoNv38gIoKmW2LyCLGzULIXQsrB+GmMX/fTR1U=; b=Fb0LTGNXOQ6OfMPa1xtKfUwOrIUthU4m+l8gRN1nvEix9TkzB53Dd7EzeAq/yJzYg/xQ v4MVpP3JA/lYd1wDgJ0KhI/bjjMEcZbBBoGUUcJ7YtfP7xBnGOt00vzlhW60twCYy4w1 19dquceTFz8Iu4fJH1LGlISQ2JUMNNf9lV+UGOociRg1EYRMNlp6E7SCwwgss0zUql/K X6veqczo1nHn9kghXCyb73U9ETvB7Bv7JDQfBOGXDRzeoew6D5LaEx2JH4V+zPfzzF/q 2qxqkjiid/UQmJJSCwWFidtJmDA4bMz4QAc09vakWqOS1x2LOYsfpkVtRVg0UxqBcrcX Sw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2uuf51g3ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:03 +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 x863cTTq096009; Fri, 6 Sep 2019 03:39:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2uu1b99t2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:02 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x863d2Ll020779; Fri, 6 Sep 2019 03:39:02 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:02 -0700 Subject: [PATCH 01/11] xfs_scrub: separate media error reporting for attribute forks From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:01 -0700 Message-ID: <156774114171.2645432.6574806722604616019.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Use different functions to warn about media errors that were detected underlying xattr data because logical offsets for attribute fork extents have no meaning to users. Signed-off-by: Darrick J. Wong --- scrub/phase6.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/scrub/phase6.c b/scrub/phase6.c index 4554af9a..1edd98af 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -113,7 +113,7 @@ xfs_decode_special_owner( /* Report if this extent overlaps a bad region. */ static bool -xfs_report_verify_inode_bmap( +report_data_loss( struct scrub_ctx *ctx, const char *descr, int fd, @@ -142,6 +142,40 @@ _("offset %llu failed read verification."), bmap->bm_offset); return true; } +/* Report if the extended attribute data overlaps a bad region. */ +static bool +report_attr_loss( + struct scrub_ctx *ctx, + const char *descr, + int fd, + int whichfork, + struct fsxattr *fsx, + struct xfs_bmap *bmap, + void *arg) +{ + struct media_verify_state *vs = arg; + struct bitmap *bmp = vs->d_bad; + + /* Complain about attr fork extents that don't look right. */ + if (bmap->bm_flags & (BMV_OF_PREALLOC | BMV_OF_DELALLOC)) { + str_info(ctx, descr, +_("found unexpected unwritten/delalloc attr fork extent.")); + return true; + } + + if (fsx->fsx_xflags & FS_XFLAG_REALTIME) { + str_info(ctx, descr, +_("found unexpected realtime attr fork extent.")); + return true; + } + + if (bitmap_test(bmp, bmap->bm_physical, bmap->bm_length)) + str_error(ctx, descr, +_("media error in extended attribute data.")); + + return true; +} + /* Iterate the extent mappings of a file to report errors. */ static bool xfs_report_verify_fd( @@ -155,16 +189,13 @@ xfs_report_verify_fd( /* data fork */ moveon = xfs_iterate_filemaps(ctx, descr, fd, XFS_DATA_FORK, &key, - xfs_report_verify_inode_bmap, arg); + report_data_loss, arg); if (!moveon) return false; /* attr fork */ - moveon = xfs_iterate_filemaps(ctx, descr, fd, XFS_ATTR_FORK, &key, - xfs_report_verify_inode_bmap, arg); - if (!moveon) - return false; - return true; + return xfs_iterate_filemaps(ctx, descr, fd, XFS_ATTR_FORK, &key, + report_attr_loss, arg); } /* Report read verify errors in unlinked (but still open) files. */ From patchwork Fri Sep 6 03:39:07 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: 11134437 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 73D8276 for ; Fri, 6 Sep 2019 03:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56422206BB for ; Fri, 6 Sep 2019 03:41:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oclSEsN2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392169AbfIFDl4 (ORCPT ); Thu, 5 Sep 2019 23:41:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55260 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388647AbfIFDl4 (ORCPT ); Thu, 5 Sep 2019 23:41:56 -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 x863deKM113413; Fri, 6 Sep 2019 03:41: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-2019-08-05; bh=fTt3AFdsXhsz5eVqL8Yq5V+EOtXxrOs0JsXcnXEXDQY=; b=oclSEsN2UNdxmsycKLdjAOqBy4b7r9voovO2o3jEYA/BrAxYAezDH7w5v4WMZf8mczdX x2UjDzwZkvyxz67lroLMipoIZXtN1QXSwZXtfkzL8zKhPwvHMmXKkT3cH7sYJQMHf/78 z9bhk7+uEDatSDN0jLwO3OmWySPn5HqcGcw6JPc/CBJzsgQ7WFCh7tVpNam7dVo0WJGf /tBtll9W12KvMXYz7MoThMG7UlgkX07d3BbwnbP3vodiM2ij6Fsif9Quhhc5qwHbWj3Z v3abAYXa+V6XTYmOjDG+DoHsWtMUIbcAKzKI0Dx7eitPcXjHvtnvdFgu8gPmFqVQhSGt gA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2uufr0809c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:41:53 +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 x863cPM6077902; Fri, 6 Sep 2019 03:39:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2utvr4jyk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:09 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x863d8x2020045; Fri, 6 Sep 2019 03:39:08 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:08 -0700 Subject: [PATCH 02/11] xfs_scrub: improve reporting of file data media errors From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:07 -0700 Message-ID: <156774114796.2645432.17610189994769183920.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong When we report media errors, we should tell the administrator the file offset and length of the bad region, not just the offset of the entire file extent record that overlaps a bad region. Signed-off-by: Darrick J. Wong --- libfrog/bitmap.c | 37 +++++++++++++++++++++++++++++++++++++ libfrog/bitmap.h | 2 ++ scrub/phase6.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 86 insertions(+), 5 deletions(-) diff --git a/libfrog/bitmap.c b/libfrog/bitmap.c index a75d085a..6a88ef48 100644 --- a/libfrog/bitmap.c +++ b/libfrog/bitmap.c @@ -339,6 +339,43 @@ bitmap_iterate( } #endif +/* Iterate the set regions of part of this bitmap. */ +int +bitmap_iterate_range( + struct bitmap *bmap, + uint64_t start, + uint64_t length, + int (*fn)(uint64_t, uint64_t, void *), + void *arg) +{ + struct avl64node *firstn; + struct avl64node *lastn; + struct avl64node *pos; + struct avl64node *n; + struct avl64node *l; + struct bitmap_node *ext; + int ret = 0; + + pthread_mutex_lock(&bmap->bt_lock); + + avl64_findranges(bmap->bt_tree, start, start + length, &firstn, + &lastn); + + if (firstn == NULL && lastn == NULL) + goto out; + + avl_for_each_range_safe(pos, n, l, firstn, lastn) { + ext = container_of(pos, struct bitmap_node, btn_node); + ret = fn(ext->btn_start, ext->btn_length, arg); + if (ret) + break; + } + +out: + pthread_mutex_unlock(&bmap->bt_lock); + return ret; +} + /* Do any bitmap extents overlap the given one? (locked) */ static bool __bitmap_test( diff --git a/libfrog/bitmap.h b/libfrog/bitmap.h index 759386a8..043b77ee 100644 --- a/libfrog/bitmap.h +++ b/libfrog/bitmap.h @@ -16,6 +16,8 @@ void bitmap_free(struct bitmap **bmap); int bitmap_set(struct bitmap *bmap, uint64_t start, uint64_t length); int bitmap_iterate(struct bitmap *bmap, int (*fn)(uint64_t, uint64_t, void *), void *arg); +int bitmap_iterate_range(struct bitmap *bmap, uint64_t start, uint64_t length, + int (*fn)(uint64_t, uint64_t, void *), void *arg); bool bitmap_test(struct bitmap *bmap, uint64_t start, uint64_t len); bool bitmap_empty(struct bitmap *bmap); diff --git a/scrub/phase6.c b/scrub/phase6.c index 1edd98af..a16ad114 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -111,6 +111,41 @@ xfs_decode_special_owner( /* Routines to translate bad physical extents into file paths and offsets. */ +struct badfile_report { + struct scrub_ctx *ctx; + const char *descr; + struct xfs_bmap *bmap; +}; + +/* Report on bad extents found during a media scan. */ +static int +report_badfile( + uint64_t start, + uint64_t length, + void *arg) +{ + struct badfile_report *br = arg; + unsigned long long bad_offset; + unsigned long long bad_length; + + /* Clamp the bad region to the file mapping. */ + if (start < br->bmap->bm_physical) { + length -= br->bmap->bm_physical - start; + start = br->bmap->bm_physical; + } + length = min(length, br->bmap->bm_length); + + /* Figure out how far into the bmap is the bad mapping and report it. */ + bad_offset = start - br->bmap->bm_physical; + bad_length = min(start + length, + br->bmap->bm_physical + br->bmap->bm_length) - start; + + str_error(br->ctx, br->descr, +_("media error at data offset %llu length %llu."), + br->bmap->bm_offset + bad_offset, bad_length); + return 0; +} + /* Report if this extent overlaps a bad region. */ static bool report_data_loss( @@ -122,8 +157,14 @@ report_data_loss( struct xfs_bmap *bmap, void *arg) { + struct badfile_report br = { + .ctx = ctx, + .descr = descr, + .bmap = bmap, + }; struct media_verify_state *vs = arg; struct bitmap *bmp; + int ret; /* Only report errors for real extents. */ if (bmap->bm_flags & (BMV_OF_PREALLOC | BMV_OF_DELALLOC)) @@ -134,11 +175,12 @@ report_data_loss( else bmp = vs->d_bad; - if (!bitmap_test(bmp, bmap->bm_physical, bmap->bm_length)) - return true; - - str_error(ctx, descr, -_("offset %llu failed read verification."), bmap->bm_offset); + ret = bitmap_iterate_range(bmp, bmap->bm_physical, bmap->bm_length, + report_badfile, &br); + if (ret) { + str_liberror(ctx, ret, descr); + return false; + } return true; } From patchwork Fri Sep 6 03:39:14 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: 11134389 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 62F6C924 for ; Fri, 6 Sep 2019 03:39:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F13D206B8 for ; Fri, 6 Sep 2019 03:39:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cpinnr6L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387597AbfIFDjS (ORCPT ); Thu, 5 Sep 2019 23:39:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52624 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732014AbfIFDjS (ORCPT ); Thu, 5 Sep 2019 23:39:18 -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 x863dGJh113013; Fri, 6 Sep 2019 03:39:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=QYa0J/56ik0cVNr/8sYuAIpx/THjsj3tnlpDeE/UnGA=; b=cpinnr6LT0ckuvg3BCtVjl7G7ZYw0gup2OLepESpO1EOxSfzbBS6vj3wY3nkzuASXXej 1LaFi6kurqXVMTLQ/EA6OK5GlPu+ZHMulK3g62r70kqvS8TapH2AJ2NH8hX8oDOHYze8 2z+Lu4pxh/eHiy0y2G0JOM6junhkGaZHcvgvsoltmz/qwLk8oxOq7vhaIid3Lvl79RXO UHJOy3VK6NAcqXMDDO1RGzksOH1IYgewk5rk/2vYF/VU52rFqckQvV/ZT2/bLYEWoBWv WtcN73sTYRA3JArA5YYIV8znIZdSmJThzWJL1fjxMIvTHmZ1HwwGe+sjb5/nIVOpUKlt KQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2uufr08008-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:16 +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 x863cT1N096174; Fri, 6 Sep 2019 03:39:15 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2uu1b99t4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:15 +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 x863dEpc006145; Fri, 6 Sep 2019 03:39:14 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:14 -0700 Subject: [PATCH 03/11] xfs_scrub: better reporting of metadata media errors From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:14 -0700 Message-ID: <156774115430.2645432.7940198097391039890.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong When we report bad metadata, we inexplicably report the physical address in units of sectors, whereas for file data we report file offsets in units of bytes. Fix the metadata reporting units to match the file data units (i.e. bytes) and skip the printf for all other cases. Signed-off-by: Darrick J. Wong --- scrub/phase6.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scrub/phase6.c b/scrub/phase6.c index a16ad114..310ab36c 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -368,7 +368,7 @@ xfs_check_rmap_error_report( void *arg) { const char *type; - char buf[32]; + char buf[DESCR_BUFSZ]; uint64_t err_physical = *(uint64_t *)arg; uint64_t err_off; @@ -377,14 +377,12 @@ xfs_check_rmap_error_report( else err_off = 0; - snprintf(buf, 32, _("disk offset %"PRIu64), - (uint64_t)BTOBB(map->fmr_physical + err_off)); - + /* Report special owners */ if (map->fmr_flags & FMR_OF_SPECIAL_OWNER) { + snprintf(buf, DESCR_BUFSZ, _("disk offset %"PRIu64), + (uint64_t)map->fmr_physical + err_off); type = xfs_decode_special_owner(map->fmr_owner); - str_error(ctx, buf, -_("%s failed read verification."), - type); + str_error(ctx, buf, _("media error in %s."), type); } /* From patchwork Fri Sep 6 03:39:20 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: 11134397 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 575B2924 for ; Fri, 6 Sep 2019 03:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4452A20842 for ; Fri, 6 Sep 2019 03:39:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UN6TTvnu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392103AbfIFDjY (ORCPT ); Thu, 5 Sep 2019 23:39:24 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38392 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392104AbfIFDjY (ORCPT ); Thu, 5 Sep 2019 23:39:24 -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 x863dM7n108644; Fri, 6 Sep 2019 03:39:22 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=rzTlZzfpq3322fRMTaFPFb0G9ApAMzqkOoXZnyxTmds=; b=UN6TTvnu6ogkSADaaZFRxj1vKD9EvIm60zPuHH5CN7HPkTe9iU17AHQ72BJeWP63/wb3 dWdDsGgN2TSBbNs36w233aMauMAR0abAKaW1/DvfI0p7uBG0wJA8OMo+vUnEBNb0iao2 0ofEjjcLAlJNwTZ/kBlWNToUOwoKIaKK7Xthi5ZHmHrMCocKCgbIQmLcqzSrttIzfsIt ESMkpQ0oKF3toej0sfH0VvK09IKGfZevyBA49pm6uHemEwTKUm27GYs8syIIyNAwpWw8 6owaYoUJ/CCWXPJSKIFQeoa4tj9yadCTOly81ajjYIZcLH3U+imJbdj2ZQFi1lboO5ea Og== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuf5f839w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:22 +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 x863dHKJ112774; Fri, 6 Sep 2019 03:39:21 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2uud7p2sma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:21 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x863dLcd006168; Fri, 6 Sep 2019 03:39:21 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:20 -0700 Subject: [PATCH 04/11] xfs_scrub: improve reporting of file metadata media errors From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:20 -0700 Message-ID: <156774116044.2645432.13242297185306235262.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Report media errors that map to data and attr fork extent maps. Signed-off-by: Darrick J. Wong --- scrub/phase6.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scrub/phase6.c b/scrub/phase6.c index 310ab36c..1013ba6d 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -385,6 +385,17 @@ xfs_check_rmap_error_report( str_error(ctx, buf, _("media error in %s."), type); } + /* Report extent maps */ + if (map->fmr_flags & FMR_OF_EXTENT_MAP) { + bool attr = (map->fmr_flags & FMR_OF_ATTR_FORK); + + scrub_render_ino_suffix(ctx, buf, DESCR_BUFSZ, + map->fmr_owner, 0, " %s", + attr ? _("extended attribute") : + _("file data")); + str_error(ctx, buf, _("media error in extent map")); + } + /* * XXX: If we had a getparent() call we could report IO errors * efficiently. Until then, we'll have to scan the dir tree From patchwork Fri Sep 6 03:39:26 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: 11134399 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 27940924 for ; Fri, 6 Sep 2019 03:39:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1274C20820 for ; Fri, 6 Sep 2019 03:39:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KuuzyA6a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388662AbfIFDj3 (ORCPT ); Thu, 5 Sep 2019 23:39:29 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45788 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404451AbfIFDj3 (ORCPT ); Thu, 5 Sep 2019 23:39:29 -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 x863dIpX078116; Fri, 6 Sep 2019 03:39:28 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=VxaygWhDkwmV3aBCJxtuaz+/G5I2VIoghhYEwIuEhqA=; b=KuuzyA6arSklP/N/Siu3g26MBm3v0V3QxtU3CMR3D62tetbFqjQMCIY8DI20gGjljtks wiMqCjuInGRDDOme8OrCozE5smXLmNF8BS/TKOAq0WVfPj4sYJRR53zUuGSXgC1oYM85 uDukSgLgVeTl5ME4jn1V/P98Lz/IVxeRuaKvuYiFjZxS4FmLE0iuC2N6mk6NKaHVWRBB l+2RTtdGPzfeCzAtJWTJ3Aa/sKeAflnmdAiuF08jsZCIcWZbSCkd10CWeMj2nNrozs36 ixB7x10M53okdk4OGiyhHE2ZaB5KtxlFgmYri01cB3wzUStTkk9zqLIrUUYd84qfrJcN bQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uuf51g3ff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:28 +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 x863dHlc112798; Fri, 6 Sep 2019 03:39:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uud7p2sp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:27 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x863dRXK022365; Fri, 6 Sep 2019 03:39:27 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:27 -0700 Subject: [PATCH 05/11] xfs_scrub: don't report media errors on unwritten extents From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:26 -0700 Message-ID: <156774116660.2645432.9472113352336880202.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=940 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Don't report media errors for unwritten extents since no data has been lost. Signed-off-by: Darrick J. Wong --- scrub/phase6.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scrub/phase6.c b/scrub/phase6.c index 1013ba6d..ec821373 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -372,6 +372,10 @@ xfs_check_rmap_error_report( uint64_t err_physical = *(uint64_t *)arg; uint64_t err_off; + /* Don't care about unwritten extents. */ + if (map->fmr_flags & FMR_OF_PREALLOC) + return true; + if (err_physical > map->fmr_physical) err_off = err_physical - map->fmr_physical; else From patchwork Fri Sep 6 03:39:32 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: 11134401 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 6E1A676 for ; Fri, 6 Sep 2019 03:39:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 50BA520820 for ; Fri, 6 Sep 2019 03:39:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YHZsW3zW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392104AbfIFDjh (ORCPT ); Thu, 5 Sep 2019 23:39:37 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52794 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfIFDjh (ORCPT ); Thu, 5 Sep 2019 23:39:37 -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 x863dW3C113300; Fri, 6 Sep 2019 03:39:35 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=IkB5ZAQXVS+mOofugMVus4E7J0bEVDmxenzrMbuqRI8=; b=YHZsW3zWDjJzOT0CICjkQNgd1hnYxU89Wjjedm0p5Bf15htLpZLBszDSeSSG25zkuYL6 SVNYvfrwnT7T4+tVKzHCXn7U2kHpeFANI33T1SQdrP1WGIIgkp5Lla3613wNulLTFZde KwSzFvmiyem6xHLsvIvPhAT+z2zRA/5+VMYqw0N4Rsq3/25E5dglJZKzGzj05TSHXGfC v4Juq6Kvjc35hYc6UM7n0HHdEzH9w6mYGHuda/GJdzGXe4xOI/1dpxKQ0QvhrSgFZH8y b1F3iWzmMlPekYjABXk4cfYQ9YRpAEo96zy9QNnK+ek3Ews/ivfSOq+St8xjb6999OMP 5A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2uufr0800s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:35 +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 x863dHwJ112799; Fri, 6 Sep 2019 03:39:34 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uud7p2sr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:34 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x863dX10022393; Fri, 6 Sep 2019 03:39:33 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:33 -0700 Subject: [PATCH 06/11] xfs_scrub: reduce fsmap activity for media errors From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:32 -0700 Message-ID: <156774117287.2645432.16766043740527927902.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Right now we rather foolishly query the fsmap data for every single media error that we find. This is a silly waste of time since we have yet to combine adjacent bad blocks into bad extents, so move the rmap query until after we've constructed the bad block bitmap data. Signed-off-by: Darrick J. Wong --- libfrog/bitmap.c | 10 +--- scrub/phase6.c | 148 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 108 insertions(+), 50 deletions(-) diff --git a/libfrog/bitmap.c b/libfrog/bitmap.c index 6a88ef48..5daa1081 100644 --- a/libfrog/bitmap.c +++ b/libfrog/bitmap.c @@ -314,7 +314,6 @@ bitmap_clear( } #endif -#ifdef DEBUG /* Iterate the set regions of this bitmap. */ int bitmap_iterate( @@ -324,20 +323,19 @@ bitmap_iterate( { struct avl64node *node; struct bitmap_node *ext; - int error = 0; + int ret; pthread_mutex_lock(&bmap->bt_lock); avl_for_each(bmap->bt_tree, node) { ext = container_of(node, struct bitmap_node, btn_node); - error = fn(ext->btn_start, ext->btn_length, arg); - if (error) + ret = fn(ext->btn_start, ext->btn_length, arg); + if (ret) break; } pthread_mutex_unlock(&bmap->bt_lock); - return error; + return ret; } -#endif /* Iterate the set regions of part of this bitmap. */ int diff --git a/scrub/phase6.c b/scrub/phase6.c index ec821373..378ea0fb 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -341,27 +341,9 @@ xfs_report_verify_dirent( return moveon; } -/* Given bad extent lists for the data & rtdev, find bad files. */ -static bool -xfs_report_verify_errors( - struct scrub_ctx *ctx, - struct media_verify_state *vs) -{ - bool moveon; - - /* Scan the directory tree to get file paths. */ - moveon = scan_fs_tree(ctx, xfs_report_verify_dir, - xfs_report_verify_dirent, vs); - if (!moveon) - return false; - - /* Scan for unlinked files. */ - return xfs_scan_all_inodes(ctx, xfs_report_verify_inode, vs); -} - /* Report an IO error resulting from read-verify based off getfsmap. */ static bool -xfs_check_rmap_error_report( +ioerr_fsmap_report( struct scrub_ctx *ctx, const char *descr, struct fsmap *map, @@ -409,12 +391,31 @@ xfs_check_rmap_error_report( return true; } +static struct bitmap * +bitmap_for_disk( + struct scrub_ctx *ctx, + struct disk *disk, + struct media_verify_state *vs) +{ + dev_t dev = xfs_disk_to_dev(ctx, disk); + + /* + * If we don't have parent pointers, save the bad extent for + * later rescanning. + */ + if (dev == ctx->fsinfo.fs_datadev) + return vs->d_bad; + else if (dev == ctx->fsinfo.fs_rtdev) + return vs->r_bad; + return NULL; +} + /* * Remember a read error for later, and see if rmap will tell us about the * owner ahead of time. */ static void -xfs_check_rmap_ioerr( +remember_ioerr( struct scrub_ctx *ctx, struct disk *disk, uint64_t start, @@ -422,32 +423,39 @@ xfs_check_rmap_ioerr( int error, void *arg) { - struct fsmap keys[2]; - char descr[DESCR_BUFSZ]; struct media_verify_state *vs = arg; struct bitmap *tree; - dev_t dev; int ret; - dev = xfs_disk_to_dev(ctx, disk); + tree = bitmap_for_disk(ctx, disk, vs); + if (!tree) + return; - /* - * If we don't have parent pointers, save the bad extent for - * later rescanning. - */ - if (dev == ctx->fsinfo.fs_datadev) - tree = vs->d_bad; - else if (dev == ctx->fsinfo.fs_rtdev) - tree = vs->r_bad; - else - tree = NULL; - if (tree) { - ret = bitmap_set(tree, start, length); - if (ret) - str_liberror(ctx, ret, _("setting bad block bitmap")); - } + ret = bitmap_set(tree, start, length); + if (ret) + str_liberror(ctx, ret, _("setting bad block bitmap")); +} + +struct walk_ioerr { + struct scrub_ctx *ctx; + struct disk *disk; +}; + +static int +walk_ioerr( + uint64_t start, + uint64_t length, + void *arg) +{ + struct walk_ioerr *wioerr = arg; + struct fsmap keys[2]; + char descr[DESCR_BUFSZ]; + dev_t dev; + + dev = xfs_disk_to_dev(wioerr->ctx, wioerr->disk); - snprintf(descr, DESCR_BUFSZ, _("dev %d:%d ioerr @ %"PRIu64":%"PRIu64" "), + snprintf(descr, DESCR_BUFSZ, +_("dev %d:%d ioerr @ %"PRIu64":%"PRIu64" "), major(dev), minor(dev), start, length); /* Go figure out which blocks are bad from the fsmap. */ @@ -459,8 +467,60 @@ xfs_check_rmap_ioerr( (keys + 1)->fmr_owner = ULLONG_MAX; (keys + 1)->fmr_offset = ULLONG_MAX; (keys + 1)->fmr_flags = UINT_MAX; - xfs_iterate_fsmap(ctx, descr, keys, xfs_check_rmap_error_report, + xfs_iterate_fsmap(wioerr->ctx, descr, keys, ioerr_fsmap_report, &start); + return 0; +} + +static int +walk_ioerrs( + struct scrub_ctx *ctx, + struct disk *disk, + struct media_verify_state *vs) +{ + struct walk_ioerr wioerr = { + .ctx = ctx, + .disk = disk, + }; + struct bitmap *tree; + + if (!disk) + return 0; + tree = bitmap_for_disk(ctx, disk, vs); + if (!tree) + return 0; + return bitmap_iterate(tree, walk_ioerr, &wioerr); +} + +/* Given bad extent lists for the data & rtdev, find bad files. */ +static bool +xfs_report_verify_errors( + struct scrub_ctx *ctx, + struct media_verify_state *vs) +{ + bool moveon; + int ret; + + ret = walk_ioerrs(ctx, ctx->datadev, vs); + if (ret) { + str_liberror(ctx, ret, _("walking datadev io errors")); + return false; + } + + ret = walk_ioerrs(ctx, ctx->rtdev, vs); + if (ret) { + str_liberror(ctx, ret, _("walking rtdev io errors")); + return false; + } + + /* Scan the directory tree to get file paths. */ + moveon = scan_fs_tree(ctx, xfs_report_verify_dir, + xfs_report_verify_dirent, vs); + if (!moveon) + return false; + + /* Scan for unlinked files. */ + return xfs_scan_all_inodes(ctx, xfs_report_verify_inode, vs); } /* Schedule a read-verify of a (data block) extent. */ @@ -571,7 +631,7 @@ xfs_scan_blocks( } ret = read_verify_pool_alloc(ctx, ctx->datadev, - ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr, + ctx->mnt.fsgeom.blocksize, remember_ioerr, scrub_nproc(ctx), &vs.rvp_data); if (ret) { str_liberror(ctx, ret, _("creating datadev media verifier")); @@ -579,7 +639,7 @@ xfs_scan_blocks( } if (ctx->logdev) { ret = read_verify_pool_alloc(ctx, ctx->logdev, - ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr, + ctx->mnt.fsgeom.blocksize, remember_ioerr, scrub_nproc(ctx), &vs.rvp_log); if (ret) { str_liberror(ctx, ret, @@ -589,7 +649,7 @@ xfs_scan_blocks( } if (ctx->rtdev) { ret = read_verify_pool_alloc(ctx, ctx->rtdev, - ctx->mnt.fsgeom.blocksize, xfs_check_rmap_ioerr, + ctx->mnt.fsgeom.blocksize, remember_ioerr, scrub_nproc(ctx), &vs.rvp_realtime); if (ret) { str_liberror(ctx, ret, From patchwork Fri Sep 6 03:39:39 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: 11134403 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 2BDDE76 for ; Fri, 6 Sep 2019 03:39:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15E8920820 for ; Fri, 6 Sep 2019 03:39:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mj0p1k6V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387776AbfIFDjn (ORCPT ); Thu, 5 Sep 2019 23:39:43 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38680 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfIFDjn (ORCPT ); Thu, 5 Sep 2019 23:39:43 -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 x863dIJb108594; Fri, 6 Sep 2019 03:39:41 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=4h3OQuBn8pRUP0g/Wi+oBN7oH8p3EQKoSQamm3fBr9w=; b=mj0p1k6V0qRziDZtunCSqx38YGABmHYoRIqi8pTrM8Sw9pQN/doCgYc3feOaB0hYqDx6 4YuaBesdbzaiBqoZKgJbFt+aRDrBLdAcu7b9yZJgA4H7fN64Vw3hZnbACSSs4iJPN1Zb 0jZ0y076ZyWvDs/G7dQ7xxB5raaMNqqBcqztcz/Y6O0MGe6TnBbAy/rLw4qSUuz8xham gvR3Ov7hNtreNOkES/poFfb7zIz98hjXuSq0hM4BE73u4uT9cF1HfNJTANkeM4VBNjr+ CnHZgdIbaWdzfWmGy6QoX1CiCDcSw2saRyxj0WC3FBOvrXZgslUhGDSJGIPU3tj9H7PD iw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuf5f83ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:40 +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 x863dGaA112714; Fri, 6 Sep 2019 03:39:40 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2uud7p2su8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:40 +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 x863ddm3006329; Fri, 6 Sep 2019 03:39:39 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:39 -0700 Subject: [PATCH 07/11] xfs_scrub: request fewer bmaps when we can From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:39 -0700 Message-ID: <156774117912.2645432.10361703081233421846.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong In xfs_iterate_filemaps, we query the number of bmaps for a given file that we're going to iterate, so feed that information to bmap so that the kernel won't waste time allocating in-kernel memory unnecessarily. Signed-off-by: Darrick J. Wong --- scrub/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrub/filemap.c b/scrub/filemap.c index bdc6d8f9..aaaa0521 100644 --- a/scrub/filemap.c +++ b/scrub/filemap.c @@ -71,7 +71,6 @@ xfs_iterate_filemaps( map->bmv_length = ULLONG_MAX; else map->bmv_length = BTOBB(key->bm_length); - map->bmv_count = BMAP_NR; map->bmv_iflags = BMV_IF_NO_DMAPI_READ | BMV_IF_PREALLOC | BMV_IF_NO_HOLES; switch (whichfork) { @@ -96,6 +95,7 @@ xfs_iterate_filemaps( moveon = false; goto out; } + map->bmv_count = min(fsx.fsx_nextents + 2, BMAP_NR); while ((error = ioctl(fd, XFS_IOC_GETBMAPX, map)) == 0) { for (i = 0, p = &map[i + 1]; i < map->bmv_entries; i++, p++) { From patchwork Fri Sep 6 03:39:45 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: 11134405 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 4FFEB924 for ; Fri, 6 Sep 2019 03:39:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CE832082C for ; Fri, 6 Sep 2019 03:39:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="EuX+eB4R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392155AbfIFDjt (ORCPT ); Thu, 5 Sep 2019 23:39:49 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52888 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfIFDjt (ORCPT ); Thu, 5 Sep 2019 23:39:49 -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 x863dU4Y113288; Fri, 6 Sep 2019 03:39:47 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=wzEqYcM9uFZaX8olf5yaSwN0FKy3KOJJZG54g/+fHfA=; b=EuX+eB4Rh0Aa1vCo/F/SAQnkYKzh78aElZBPUXdTR04Mplo01ulC3pdWqKPeL2GBD9gY Unh0YGOnHHSnKeIGYz/qPs4Ka3+3csiBaABg7hYB+xgtyCoHrfstnx6W4hwmJOqjPwJ5 bM63dTc/FwoH6/dtDxo2N/yK6s1QwiL287jzUpui5AmSvxQUuSbk1fDnSWYFkJDDyHAq 6jfkPDc0WLaDoQcwvTtDbTbFP0VYEfFKuzgx1DZUStBLz/1aF0XxuLFnUFPecNHsA8Su SRms/czsh3Hx4cnAWitLCqzu5RvF0ZILY2svdqQdzyW58to40ma8TCl9tcUx3lb4vk1A qw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2uufr08015-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:47 +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 x863dHmY112817; Fri, 6 Sep 2019 03:39:46 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2uud7p2sw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:46 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x863djVO022611; Fri, 6 Sep 2019 03:39:45 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:45 -0700 Subject: [PATCH 08/11] xfs_scrub: fix media verification thread pool size calculations From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:45 -0700 Message-ID: <156774118527.2645432.8208786952640433174.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The read verifier pool deals with two different thread counts -- there's the submitter thread count that enables us to perform per-thread verify request aggregation, and then there's the io thread pool count which is the maximum number of IO requests we want to send to the disk at any given time. The io thread pool count should be derived from disk_heads() but instead we bungle it by measuring and modifying(!) the nproc global variable. Fix the derivation to use global variables correctly. Signed-off-by: Darrick J. Wong --- scrub/read_verify.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scrub/read_verify.c b/scrub/read_verify.c index 3dac10ce..834571a7 100644 --- a/scrub/read_verify.c +++ b/scrub/read_verify.c @@ -75,6 +75,7 @@ read_verify_pool_alloc( struct read_verify_pool **prvp) { struct read_verify_pool *rvp; + unsigned int verifier_threads = disk_heads(disk); int ret; /* @@ -94,7 +95,7 @@ read_verify_pool_alloc( RVP_IO_MAX_SIZE); if (ret) goto out_free; - ret = ptcounter_alloc(nproc, &rvp->verified_bytes); + ret = ptcounter_alloc(verifier_threads, &rvp->verified_bytes); if (ret) goto out_buf; rvp->miniosz = miniosz; @@ -106,11 +107,8 @@ read_verify_pool_alloc( &rvp->rvstate); if (ret) goto out_counter; - /* Run in the main thread if we only want one thread. */ - if (nproc == 1) - nproc = 0; ret = workqueue_create(&rvp->wq, (struct xfs_mount *)rvp, - disk_heads(disk)); + verifier_threads == 1 ? 0 : verifier_threads); if (ret) goto out_rvstate; *prvp = rvp; From patchwork Fri Sep 6 03:39: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: 11134407 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 35929924 for ; Fri, 6 Sep 2019 03:39:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20E5B20820 for ; Fri, 6 Sep 2019 03:39:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pqY5Rc38" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388503AbfIFDj4 (ORCPT ); Thu, 5 Sep 2019 23:39:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52980 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfIFDj4 (ORCPT ); Thu, 5 Sep 2019 23:39:56 -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 x863dsgj113447; Fri, 6 Sep 2019 03:39: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-2019-08-05; bh=wvagb+Gs3gehSKyUZuM4DWdCt2GXmK8sP0sJDlViVaU=; b=pqY5Rc38l5EzKJ1/x6GzsEoGQREDWwhbL7sCIi5hawKxOGIAXlCho3xqFypaV9lq7Ol+ VoHId1FaWUl/sJWv/QupYWcDZilXXLAH/r61HUD/e0vSZsgRZyWT2+Zwzb1lXMVyDYIM WTk47AWtpCuwRUTJPgYunEVwtAyj1LBs0eUR4c/iGztQSUD+WydHoGRbdW97KY9Q/9tq wUp1/kRuVuid+5KoOFXAu/IIKfJATpGJ9yMl/r5x3HGKCcGfGaIHYRZroi5AHc4SVWSO B3TW8fAlLI33E5U4kqou4T1r80Gf8EefaNpA1BKV9MqyrkNY0Hq94mUOcQBlaGSR4C1N nw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2uufr0801a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:54 +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 x863cTgt096070; Fri, 6 Sep 2019 03:39:53 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2uu1b99tm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:53 +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 x863dquK020389; Fri, 6 Sep 2019 03:39:52 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:51 -0700 Subject: [PATCH 09/11] libfrog: clean up platform_nproc From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:51 -0700 Message-ID: <156774119138.2645432.6957640581961453315.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=9 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-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=9 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-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The platform_nproc function should check for error returns and obviously garbage values and deal with them appropriately. Fix the header declaration since it's part of the libfrog platform support code, not libxfs. xfs_scrub will make use of it in the next patch. Signed-off-by: Darrick J. Wong --- include/libxfs.h | 1 - include/platform_defs.h.in | 2 ++ libfrog/linux.c | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 63696df5..227084ae 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -135,7 +135,6 @@ extern void libxfs_device_close (dev_t); extern int libxfs_device_alignment (void); extern void libxfs_report(FILE *); extern void platform_findsizes(char *path, int fd, long long *sz, int *bsz); -extern int platform_nproc(void); /* check or write log footer: specify device, log size in blocks & uuid */ typedef char *(libxfs_get_block_t)(char *, int, void *); diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in index d111ec6d..adb00181 100644 --- a/include/platform_defs.h.in +++ b/include/platform_defs.h.in @@ -77,4 +77,6 @@ typedef unsigned short umode_t; # define ASSERT(EX) ((void) 0) #endif +extern int platform_nproc(void); + #endif /* __XFS_PLATFORM_DEFS_H__ */ diff --git a/libfrog/linux.c b/libfrog/linux.c index b6c24879..79bd79eb 100644 --- a/libfrog/linux.c +++ b/libfrog/linux.c @@ -242,10 +242,17 @@ platform_align_blockdev(void) return max_block_alignment; } +/* How many CPUs are online? */ int platform_nproc(void) { - return sysconf(_SC_NPROCESSORS_ONLN); + long nproc = sysconf(_SC_NPROCESSORS_ONLN); + + if (nproc < 1) + return 1; + if (nproc >= INT_MAX) + return INT_MAX; + return nproc; } unsigned long From patchwork Fri Sep 6 03:39:57 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: 11134409 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 8D378924 for ; Fri, 6 Sep 2019 03:40:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77A9420820 for ; Fri, 6 Sep 2019 03:40:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QuZYJqrH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726940AbfIFDkC (ORCPT ); Thu, 5 Sep 2019 23:40:02 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:46398 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733012AbfIFDkB (ORCPT ); Thu, 5 Sep 2019 23:40:01 -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 x863dEI1077818; Fri, 6 Sep 2019 03:40: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=mOWDBBO8dbjjr3lTgyLoSH687EEtqFjbkAfXclBNkVk=; b=QuZYJqrHqMmM7/N9Tx1MiSKGV+X+E87l2b+R9wuzNgLXx9iYAltJPwxP9pWK4G8MDNNz E5SzJQ8tsmizIQniEO3DtFHXBuhaEWqUJdkr1biBy0jlodmAglIBTui2TVs6L3/1m9or pVJhBe+YJlEj2RyypkMAIbbJMznDecQfRnz7nqe2/JBHx98++QTWJfywJcPhBsQlvpcm tlpFqmv9lPwQuvNuJyVEKP33+OvX/BCQ5UsCeZaGWUrv5kM22h942zDBBCU0TAR6Otrz Hh8pigxZ5YmT+BbBbRLXLt9HntB8ZBZU6wTg+P5ezVCXNS/SmoSpfOty6PGPu5XaB+S+ 5w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uuf51g3gn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:59 +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 x863dI8A112843; Fri, 6 Sep 2019 03:39:59 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2uud7p2t0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:39:59 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x863dwxH016581; Fri, 6 Sep 2019 03:39:58 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:39:57 -0700 Subject: [PATCH 10/11] xfs_scrub: clean out the nproc global variable From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:39:57 -0700 Message-ID: <156774119750.2645432.3129933658637857973.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Get rid of this global variable since we already have a libfrog function that does exactly what it does. Signed-off-by: Darrick J. Wong --- scrub/disk.c | 2 ++ scrub/xfs_scrub.c | 8 -------- scrub/xfs_scrub.h | 1 - 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/scrub/disk.c b/scrub/disk.c index 214a5346..31dc4192 100644 --- a/scrub/disk.c +++ b/scrub/disk.c @@ -22,6 +22,7 @@ #include "xfs_scrub.h" #include "common.h" #include "disk.h" +#include "platform_defs.h" #ifndef BLKROTATIONAL # define BLKROTATIONAL _IO(0x12, 126) @@ -42,6 +43,7 @@ __disk_heads( { int iomin; int ioopt; + int nproc = platform_nproc(); unsigned short rot; int error; diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c index b6a01274..147c114c 100644 --- a/scrub/xfs_scrub.c +++ b/scrub/xfs_scrub.c @@ -131,9 +131,6 @@ static bool display_rusage; /* Background mode; higher values insert more pauses between scrub calls. */ unsigned int bg_mode; -/* Maximum number of processors available to us. */ -int nproc; - /* Number of threads we're allowed to use. */ unsigned int force_nr_threads; @@ -717,11 +714,6 @@ main( } memcpy(&ctx.fsinfo, fsp, sizeof(struct fs_path)); - /* How many CPUs? */ - nproc = sysconf(_SC_NPROCESSORS_ONLN); - if (nproc < 1) - nproc = 1; - /* Set up a page-aligned buffer for read verification. */ page_size = sysconf(_SC_PAGESIZE); if (page_size < 0) { diff --git a/scrub/xfs_scrub.h b/scrub/xfs_scrub.h index f9a72052..37d78f61 100644 --- a/scrub/xfs_scrub.h +++ b/scrub/xfs_scrub.h @@ -15,7 +15,6 @@ extern char *progname; extern unsigned int force_nr_threads; extern unsigned int bg_mode; extern unsigned int debug; -extern int nproc; extern bool verbose; extern long page_size; extern bool want_fstrim; From patchwork Fri Sep 6 03:40:03 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: 11134411 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 78F82924 for ; Fri, 6 Sep 2019 03:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66C6B20820 for ; Fri, 6 Sep 2019 03:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="sGS+1iwM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733012AbfIFDkI (ORCPT ); Thu, 5 Sep 2019 23:40:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:39126 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731630AbfIFDkI (ORCPT ); Thu, 5 Sep 2019 23:40:08 -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 x863dL97108640; Fri, 6 Sep 2019 03:40:06 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=7szrSEIJJTxRGxLX78SZB7+fOnM/0dFPOhUvzp2blcE=; b=sGS+1iwM75Yku/6Z/ugjZVVFJuZf4bLgtdrQDNkGufKbzQmNL30ydoq+ZOfJ6yHhwlb6 8isLQiIK+S7V8B3GGSSkMV27vo/Gu6WkQDzLIy8LYNRTgOVMI3wTRU5olqqu7Y51v23i ocj3LpAsScd8Du4RVFd1GfMCkPpqlu/hkJkD1lu9JFLr4hkbVJQdGgYpfTIFGQx6AeMV IFu48+S3xLNDmqKl9fBiTTfSk4+cqjhsgtG3Le8776hmW33qvCH91yAgJoY/ThCekwgx WLoSc5vJG380nWup0CFyX4yYQdpPb0uKyUDvAcT6rN95Ri06xGjMmVr6mNosBk+Cf4wX +A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2uuf5f83bb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:40:06 +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 x863dHn4112824; Fri, 6 Sep 2019 03:40:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2uud7p2t4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Sep 2019 03:40:05 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x863e4rk006569; Fri, 6 Sep 2019 03:40:04 GMT Received: from localhost (/10.159.148.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Sep 2019 20:40:04 -0700 Subject: [PATCH 11/11] xfs_scrub: create a new category for unfixable errors From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Thu, 05 Sep 2019 20:40:03 -0700 Message-ID: <156774120361.2645432.13655152725555275236.stgit@magnolia> In-Reply-To: <156774113533.2645432.14942831726168941966.stgit@magnolia> References: <156774113533.2645432.14942831726168941966.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9371 signatures=668685 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-1906280000 definitions=main-1909060040 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong There's nothing that xfs_scrub (or XFS) can do about media errors for data file blocks -- the data are gone. Create a new category for these unfixable errors so that we don't advise the user to take further action that won't fix the problem. Signed-off-by: Darrick J. Wong --- scrub/common.c | 9 ++++++++- scrub/common.h | 3 +++ scrub/phase4.c | 3 ++- scrub/phase5.c | 2 +- scrub/phase6.c | 2 +- scrub/xfs_scrub.c | 15 +++++++++++++-- scrub/xfs_scrub.h | 1 + 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scrub/common.c b/scrub/common.c index a814f568..79ec9fd6 100644 --- a/scrub/common.c +++ b/scrub/common.c @@ -36,7 +36,8 @@ xfs_scrub_excessive_errors( bool ret; pthread_mutex_lock(&ctx->lock); - ret = ctx->max_errors > 0 && ctx->errors_found >= ctx->max_errors; + ret = ctx->max_errors > 0 && + (ctx->unfixable_errors + ctx->errors_found) >= ctx->max_errors; pthread_mutex_unlock(&ctx->lock); return ret; @@ -47,6 +48,10 @@ static struct { int loglevel; } err_levels[] = { [S_ERROR] = { .string = "Error", .loglevel = LOG_ERR }, + [S_UNFIXABLE] = { + .string = "Unfixable error", + .loglevel = LOG_ERR + }, [S_WARN] = { .string = "Warning", .loglevel = LOG_WARNING }, [S_REPAIR] = { .string = "Repaired", .loglevel = LOG_WARNING }, [S_INFO] = { .string = "Info", .loglevel = LOG_INFO }, @@ -108,6 +113,8 @@ __str_out( out_record: if (error) /* A syscall failed */ ctx->runtime_errors++; + else if (level == S_UNFIXABLE) + ctx->unfixable_errors++; else if (level == S_ERROR) ctx->errors_found++; else if (level == S_WARN) diff --git a/scrub/common.h b/scrub/common.h index 1b9ad48f..e8485b4c 100644 --- a/scrub/common.h +++ b/scrub/common.h @@ -17,6 +17,7 @@ bool xfs_scrub_excessive_errors(struct scrub_ctx *ctx); enum error_level { S_ERROR = 0, + S_UNFIXABLE, S_WARN, S_REPAIR, S_INFO, @@ -40,6 +41,8 @@ void __str_out(struct scrub_ctx *ctx, const char *descr, enum error_level level, __str_out(ctx, str, S_REPAIR, 0, __FILE__, __LINE__, __VA_ARGS__) #define record_preen(ctx, str, ...) \ __str_out(ctx, str, S_PREEN, 0, __FILE__, __LINE__, __VA_ARGS__) +#define str_unfixable_error(ctx, str, ...) \ + __str_out(ctx, str, S_UNFIXABLE, 0, __FILE__, __LINE__, __VA_ARGS__) #define dbg_printf(fmt, ...) \ do {if (debug > 1) {printf(fmt, __VA_ARGS__);}} while (0) diff --git a/scrub/phase4.c b/scrub/phase4.c index eb30c189..07927036 100644 --- a/scrub/phase4.c +++ b/scrub/phase4.c @@ -99,7 +99,8 @@ xfs_process_action_items( workqueue_destroy(&wq); pthread_mutex_lock(&ctx->lock); - if (moveon && ctx->errors_found == 0 && want_fstrim) { + if (moveon && ctx->errors_found == 0 && ctx->unfixable_errors == 0 && + want_fstrim) { fstrim(ctx); progress_add(1); } diff --git a/scrub/phase5.c b/scrub/phase5.c index 997c88d9..30346fc1 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -336,7 +336,7 @@ xfs_scan_connections( bool moveon = true; bool ret; - if (ctx->errors_found) { + if (ctx->errors_found || ctx->unfixable_errors) { str_info(ctx, ctx->mntpoint, _("Filesystem has errors, skipping connectivity checks.")); return true; diff --git a/scrub/phase6.c b/scrub/phase6.c index 378ea0fb..c50fb8fb 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -140,7 +140,7 @@ report_badfile( bad_length = min(start + length, br->bmap->bm_physical + br->bmap->bm_length) - start; - str_error(br->ctx, br->descr, + str_unfixable_error(br->ctx, br->descr, _("media error at data offset %llu length %llu."), br->bmap->bm_offset + bad_offset, bad_length); return 0; diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c index 147c114c..aa98caaa 100644 --- a/scrub/xfs_scrub.c +++ b/scrub/xfs_scrub.c @@ -515,12 +515,16 @@ report_outcome( total_errors = ctx->errors_found + ctx->runtime_errors; - if (total_errors == 0 && ctx->warnings_found == 0) { + if (total_errors == 0 && + ctx->unfixable_errors == 0 && + ctx->warnings_found == 0) { log_info(ctx, _("No errors found.")); return; } - if (total_errors == 0) { + if (total_errors == 0 && ctx->warnings_found == 0) { + /* nothing to report */ + } else if (total_errors == 0) { fprintf(stderr, _("%s: warnings found: %llu\n"), ctx->mntpoint, ctx->warnings_found); log_warn(ctx, _("warnings found: %llu"), ctx->warnings_found); @@ -536,6 +540,13 @@ report_outcome( total_errors, ctx->warnings_found); } + if (ctx->unfixable_errors) { + fprintf(stderr, _("%s: unfixable errors found: %llu\n"), + ctx->mntpoint, ctx->unfixable_errors); + log_err(ctx, _("unfixable errors found: %llu"), + ctx->unfixable_errors); + } + /* * Don't advise the user to run repair unless we were successful in * setting up the scrub and we actually saw corruptions. Warnings diff --git a/scrub/xfs_scrub.h b/scrub/xfs_scrub.h index 37d78f61..54876acb 100644 --- a/scrub/xfs_scrub.h +++ b/scrub/xfs_scrub.h @@ -74,6 +74,7 @@ struct scrub_ctx { unsigned long long max_errors; unsigned long long runtime_errors; unsigned long long errors_found; + unsigned long long unfixable_errors; unsigned long long warnings_found; unsigned long long inodes_checked; unsigned long long bytes_checked;