From patchwork Wed Sep 25 21:36: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: 11161499 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 BF34376 for ; Wed, 25 Sep 2019 21:36:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E17121D80 for ; Wed, 25 Sep 2019 21:36:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="PFjqI3S6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbfIYVgU (ORCPT ); Wed, 25 Sep 2019 17:36:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60574 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbfIYVgU (ORCPT ); Wed, 25 Sep 2019 17:36:20 -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 x8PLYWSg054898; Wed, 25 Sep 2019 21:36:17 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=PFjqI3S6U0OgxPqs7whD+YNA1mL/gr0C01+XULTWO5M/0yYUJzLm3zwl4Ba0sWVd+f1E oCQcNmMsHUzOdGM8GR7p2d9qtOFYVv8d7HrTmzfSULohvXjphFj7gxVCZh2jfISYgbfU qUo2MrKjnv2s5OwJaV50M+Bw9BNNMeK4zjrjGwl6Fcspz4zVPNd0l9Bj+NQYKKDoqyNU s2N8kooHfGuAEYlDbOv8xq3XOjBRRGVnOapTmOFjjeHd1D/gL9tl2BWcDeehP77eHMu/ g0bSHfc4phvXNbT2NbMwakyoQDV+xTCLCeHJRuJegH6t63BzEoEl21todgXW3LpshKtP 3A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2v5cgr7f2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:17 +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 x8PLYSWN078776; Wed, 25 Sep 2019 21:36:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2v82tkrj73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:16 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8PLaFeD016071; Wed, 25 Sep 2019 21:36:15 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:15 -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: Wed, 25 Sep 2019 14:36:14 -0700 Message-ID: <156944737397.300131.4607692740306012565.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:36: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: 11161501 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 DEC85912 for ; Wed, 25 Sep 2019 21:36:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD1C621D81 for ; Wed, 25 Sep 2019 21:36:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hVPGrnSc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727840AbfIYVg0 (ORCPT ); Wed, 25 Sep 2019 17:36:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60666 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbfIYVg0 (ORCPT ); Wed, 25 Sep 2019 17:36:26 -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 x8PLYZRm054965; Wed, 25 Sep 2019 21:36:23 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=hVPGrnScEqe1MM8m3TbR3L4Sh5FMu3qgbS/Y3OJzJfZvJVDe3oVWL/EQzzospE+fmdCb kTnKAMdYYXCv0jrvK8t+3MBm1w4tQpkuFYZ5HezxEMOhTVermwZ+bWFMV2En5x3VfILd dyIMxvYv0aiOpKoPp1mIhjrclCwI5tucA6jlcU5wX/vbm1NFV4KXChcluSxZWxXrshmQ o2p/ZfymNoD1w2XSwoFXABMiFzkNF/fvGvy1F8OGBrE6KETAieo9gAKkekasi5TNpUgE RbItMGSbhWokQPX4poCugJsGUrQZwMtjxABjDXMOr88ed1mrTeXziQW5lB216WMXagK3 sA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2v5cgr7f2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:23 +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 x8PLYRBO078737; Wed, 25 Sep 2019 21:36:22 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2v82tkrjcc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:22 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8PLaLVV016185; Wed, 25 Sep 2019 21:36:21 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:21 -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: Wed, 25 Sep 2019 14:36:20 -0700 Message-ID: <156944737999.300131.8592981210219230662.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:36: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: 11161541 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 D2E4D912 for ; Wed, 25 Sep 2019 21:38:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B257021D80 for ; Wed, 25 Sep 2019 21:38:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="j9lYwo8n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727926AbfIYVib (ORCPT ); Wed, 25 Sep 2019 17:38:31 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:41104 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbfIYVib (ORCPT ); Wed, 25 Sep 2019 17:38:31 -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 x8PLYc7t058172; Wed, 25 Sep 2019 21:38: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=QYa0J/56ik0cVNr/8sYuAIpx/THjsj3tnlpDeE/UnGA=; b=j9lYwo8n8Ld5YUt/jwkTqUUR8ZUlQom635SIRSYYbnjwGsATfzC/Qc6Ie3cAu/HCms3V Tb3d8OrQWBg72mDHS4dK2Yr7LpGh/y5Y+pVJPHlMJvo7pnU2Ey0RP0YSl2E8TzsrIpDJ 4hL8rgF6VGdXBZmVSivyLNTl/mx8B3CWVSn+iAZ8CO7i2q4NIgSaAd9Q6lK0k3u/CM5E QxY3DKDopkIh6hrZZFGwRj/wtpPZ5TN7ESXhyqMIbju/KycWdmp1pYzMSQC69KDw0SjQ fSZtFFKeCGhx04a8UbU6Nx02tmQJCtxxXZ/5P/U7rN3njK6W7sMBp309c4MCIFzwxjpj KA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2v5b9tyhe3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:38: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 x8PLYQJu023792; Wed, 25 Sep 2019 21:36:28 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2v7vnyus8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:27 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLaRUK020995; Wed, 25 Sep 2019 21:36:27 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:27 -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: Wed, 25 Sep 2019 14:36:26 -0700 Message-ID: <156944738604.300131.8278382614496808681.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:36: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: 11161503 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 C206B76 for ; Wed, 25 Sep 2019 21:36:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A076021D80 for ; Wed, 25 Sep 2019 21:36:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="J+JTKJOl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727855AbfIYVgh (ORCPT ); Wed, 25 Sep 2019 17:36:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45202 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbfIYVgh (ORCPT ); Wed, 25 Sep 2019 17:36:37 -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 x8PLYO9t009867; Wed, 25 Sep 2019 21:36: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=rzTlZzfpq3322fRMTaFPFb0G9ApAMzqkOoXZnyxTmds=; b=J+JTKJOlFctKcvL6BhwMu37liZltQn4gcM0CtMLRjfbPW5iJQyu/ChjVOtdq9cA+3b+/ 9s+vMzGopRgdb6GCUFPcFABwKHLtQa5Mbhx/Bl8fcrS6V6DHNTrdi8MXvCyMCx8dFJ/P SmtxaVAdtzAVUcKQ5ibJXpY42zfI6szmtdC9fx/NAqTV5eTx0h9e0GBXtBgCWhjJi2b1 daXGYEiHXIIooTwTEoWH7fheHiY46oOwuyQjCbmG+4cIhEaRKjhFRhHMLsBLLzM40HjD QZheflQFVLzNQEXuaVEGZYc7gwDVfvDNmDuZUiCYFWNitDNXo53sUfA00CdJduuS4ZSB 8A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2v5btq7hw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:35 +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 x8PLYTEN078949; Wed, 25 Sep 2019 21:36:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2v82tkrjpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:34 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLaX6G015516; Wed, 25 Sep 2019 21:36:33 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:33 -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: Wed, 25 Sep 2019 14:36:32 -0700 Message-ID: <156944739208.300131.5955900694911585741.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Reviewed-by: Eric Sandeen --- 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 Wed Sep 25 21:36:38 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: 11161505 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 C22C376 for ; Wed, 25 Sep 2019 21:36:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0C4721D80 for ; Wed, 25 Sep 2019 21:36:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="iUhhDBsQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727859AbfIYVgn (ORCPT ); Wed, 25 Sep 2019 17:36:43 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45278 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbfIYVgn (ORCPT ); Wed, 25 Sep 2019 17:36:43 -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 x8PLYTjS010165; Wed, 25 Sep 2019 21:36: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=VxaygWhDkwmV3aBCJxtuaz+/G5I2VIoghhYEwIuEhqA=; b=iUhhDBsQphPyKPqi2ACbRFbWoJKn+mix0QlClxKXDIrZmF+eXlH0al+dmcB6DN305O4b CKjJ0DB7y9BfJRAsKAt93+BBdCoJObX3Pvhcm9vA6Vx6EVOV4koBWr0mqglw6TRrwIh2 6Jiudez454JnftrDAfAhS5Y4FaH1yfe48FYtNgMCgs/Eq554n9AMBqZ+u+32zfjy2C4q My1RGvKunzeOA7S2AOzvE8h4pyOFCq2junebvo+/2rUZcDoxAfVcF9XN1KfWFREVa/Vn UE3XTdazT9b7aYTftgJzJ0ffbnPRUi7+StcvxiAm9S3HRy0E+cjAqdpXIAO7jiOxsN+b eQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2v5btq7hwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:41 +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 x8PLYScH011446; Wed, 25 Sep 2019 21:36:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2v829w525q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:40 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8PLad9t016087; Wed, 25 Sep 2019 21:36:39 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:39 -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: Wed, 25 Sep 2019 14:36:38 -0700 Message-ID: <156944739811.300131.17079426522479861861.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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=978 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Reviewed-by: Eric Sandeen --- 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 Wed Sep 25 21:36:44 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: 11161507 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 76DD076 for ; Wed, 25 Sep 2019 21:36:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CE5C21D80 for ; Wed, 25 Sep 2019 21:36:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="pN+ARriq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbfIYVgu (ORCPT ); Wed, 25 Sep 2019 17:36:50 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60992 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbfIYVgt (ORCPT ); Wed, 25 Sep 2019 17:36:49 -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 x8PLYjoD055357; Wed, 25 Sep 2019 21:36: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=IkB5ZAQXVS+mOofugMVus4E7J0bEVDmxenzrMbuqRI8=; b=pN+ARriq/vKi8hxMYtEKk4j17OqeZlx9wJIrijOYYA17fMMtlz0Z8DPkyxxQFGgm9Hkm qVN6UCjT4RXR4H5QlkhF1OExdNlhHAfwWkfP9/3Syy/NLKO6xEKHYAIuH16bgCTD/Tqz 27xHBeFQ+RtoKm3syeFrmwrW9rx2MaEcIaGExL98IvrLzrbkTQjGvPBJbIAzgOkTVlfE fVZE0kbt+JqP5q1PFsl+HJf5kVa3tFPET8z4IoD4IPLghroxGK+fuXg/Z0JNFJmXks6M mKnLIAGR/k7RWnfdudhxhvyg9z9yfbZ+6gfDJZ3IFmC+U10WByIMSk93OGBCo2BgMwLA ZQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2v5cgr7f3w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:47 +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 x8PLYR5v011352; Wed, 25 Sep 2019 21:36:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2v829w52aw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:46 +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 x8PLajaf021204; Wed, 25 Sep 2019 21:36:45 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:45 -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: Wed, 25 Sep 2019 14:36:44 -0700 Message-ID: <156944740409.300131.11774965759850122284.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:36:50 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: 11161545 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 F0EDD76 for ; Wed, 25 Sep 2019 21:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF133205F4 for ; Wed, 25 Sep 2019 21:38:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YX5ohGbu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbfIYViz (ORCPT ); Wed, 25 Sep 2019 17:38:55 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47250 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbfIYViz (ORCPT ); Wed, 25 Sep 2019 17:38:55 -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 x8PLYQcD009886; Wed, 25 Sep 2019 21:38:53 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=YX5ohGbu1bmUqBmZXTW8YSiCdWw7C4yP1uhmvzVgJnJM2LkoEEfSaz2HM/laDNZHKkTq 2DQM0aP5JetLOrG1XNeZla83nXVe9mzKUfyKH8Rv9FgZ/dahrRtbsdZQaK9V0EUi/yAw Jbkz4hM4CE5GEfRQDOcoQZa958RKRp9Xznt0vzOhKWHJSV0vOD/3tcviTJG2M0QWklxd /ecqz+HnXaZeSoIaplh5RZmJ+XHPJXgfz/WhyDcwHVgUSMHZszHHskEmUmqIE6I0X97Z KUa7dqYEwkPEaIB0sszQXf3EhwWmcfBGFFnc8hvKBverKPZLz3kj8mF+DTxI3MKUVyQ2 gQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2v5btq7j3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:38:53 +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 x8PLYPgE078623; Wed, 25 Sep 2019 21:36:53 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2v82tkrk65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:52 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLapir015693; Wed, 25 Sep 2019 21:36:51 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:51 -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: Wed, 25 Sep 2019 14:36:50 -0700 Message-ID: <156944741018.300131.13838435268141846825.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:36:56 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: 11161509 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 EA11276 for ; Wed, 25 Sep 2019 21:37:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8F1021D81 for ; Wed, 25 Sep 2019 21:37:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gP9Fvdm+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727868AbfIYVhB (ORCPT ); Wed, 25 Sep 2019 17:37:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:32988 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbfIYVhB (ORCPT ); Wed, 25 Sep 2019 17:37:01 -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 x8PLYc3h055018; Wed, 25 Sep 2019 21:36:59 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=gP9Fvdm+nCQx8anOcKK5QwmlkFBbetsavBotV9tLMj9yauWrKzT7ylkntsn+I591G33n HKdLe5psuIROmkHWaknnUHZDVNm061lSs9sY49OXHh+zaBYo7c1GNCBzCp4knkUiWdpt ehkcBS8wnNlkcrd9HIJkE1RQkXPhYD3wBrClmQLbPBoWy2EsheE+WQQ3CuIvfK9p/c6d /fEdoIqV9+qQC12N9DfXqLDawVLGiGosINXPq2d89GxIv3Xiz36J0ByVLxkmX+j5wAtI SeH4WHgbShiXQ0WREpeYPH+uNtEwAszVgMY4ghzqxGqlj75mNLtLWeddNEHdlRS3qYuG pA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2v5cgr7f4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:58 +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 x8PLYRsr011398; Wed, 25 Sep 2019 21:36:58 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2v829w52nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:36:58 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x8PLavnT016460; Wed, 25 Sep 2019 21:36:57 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:36:57 -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: Wed, 25 Sep 2019 14:36:56 -0700 Message-ID: <156944741622.300131.15141442959494340981.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Reviewed-by: Eric Sandeen --- 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 Wed Sep 25 21:37: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: 11161547 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 D21AA912 for ; Wed, 25 Sep 2019 21:39:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0189205F4 for ; Wed, 25 Sep 2019 21:39:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Mq8LX9+R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbfIYVjJ (ORCPT ); Wed, 25 Sep 2019 17:39:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47442 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbfIYVjJ (ORCPT ); Wed, 25 Sep 2019 17:39:09 -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 x8PLYVDj010189; Wed, 25 Sep 2019 21:39:07 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=Mq8LX9+RJgzrmCmlVuqi7z9pvXoAqkYdIjRmr5+kSlv7NG5fcFEOTFJm4i+7Imc6XqHX MTPkZ2Wm5yjM3RuJGEj2QJ+XY37+cLONHRqCgUUgtv5vsXtFO/hPeFBXoYNshzfsMTUt iFulHGL66nE0IZ1HSaEiwlbR0oOS351DNinCQEmruoL9p4aTjhAducxlmjHJc9lZmUnd s7vOx5ATNfXyy2hf9yB2eWrrYGb05wwRoicvW1w7+26gdEBPtqlJRSL3X2esXtu+bNVz DDJiEBMcOOGuUDzYJ9yYJe8bULAYS7Gb6KG7NsFrHBLHPbW7SDepW5b9uVCOaiAxY+6Y dg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2v5btq7j4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:39:07 +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 x8PLYOgW023662; Wed, 25 Sep 2019 21:37:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2v7vnyutb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:37:06 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLb34l015851; Wed, 25 Sep 2019 21:37:03 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:37:03 -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: Wed, 25 Sep 2019 14:37:02 -0700 Message-ID: <156944742224.300131.10235357474710122535.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Wed Sep 25 21:37:08 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: 11161549 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 AB27A912 for ; Wed, 25 Sep 2019 21:39:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8974C20872 for ; Wed, 25 Sep 2019 21:39:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bDSKLr/j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728605AbfIYVjN (ORCPT ); Wed, 25 Sep 2019 17:39:13 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35026 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbfIYVjN (ORCPT ); Wed, 25 Sep 2019 17:39:13 -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 x8PLYc3r055018; Wed, 25 Sep 2019 21:39:11 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=bDSKLr/jGpxSB8HHaeHohhI9Rsj03xDrV5VSf3siAW62aK7PBXCbRBGyHi5Z0Fj8Cg0B a+9UHRa6YZDYSMhmaX7gI2ihCyxB+eo0zpsaDwFXroEbFJziY9h9fnGoD/pQFQLCLM9z 2utejqpzwK6Og2k7C9Pr8XKRyoIeA094blO+MV86nrXQVtDD83idUYXJ1iYHwEvZtl5n VslJqdSWZG2SwZ1Dar7c1I3eZas7DMH/xhBDl2ILsuVE51739uo/Sik7QoXTr0qEtULN 6NvHzRNjnTycbOpsiGg06Dx13d6X6o400+Inm0bfAz4rTyZlKLFS5uMvXiNyzhKSB4Q0 Kg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2v5cgr7fb3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:39:11 +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 x8PLYQno097674; Wed, 25 Sep 2019 21:37:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2v82qakwjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:37:10 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLb9L0015975; Wed, 25 Sep 2019 21:37:09 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:37:09 -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: Wed, 25 Sep 2019 14:37:08 -0700 Message-ID: <156944742829.300131.10853963179326362863.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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 Reviewed-by: Eric Sandeen --- 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 Wed Sep 25 21:37: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: 11161511 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 8670B912 for ; Wed, 25 Sep 2019 21:37:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6138F21D81 for ; Wed, 25 Sep 2019 21:37:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jkAb+U8C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbfIYVhT (ORCPT ); Wed, 25 Sep 2019 17:37:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33340 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727982AbfIYVhT (ORCPT ); Wed, 25 Sep 2019 17:37: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 x8PLYZRp054965; Wed, 25 Sep 2019 21:37:17 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=jkAb+U8CCP6qrgkPZac6LXzCx/B1FxMDGa411HrTbFxPIruHy9SpR3jTkz3vtsCVx16x RogHpEvfKSi7cwPTdsV1oO+ZdMAO9vI6THhr9OEPrRAPwd9rnlyeCBZQuSVYcVlFZEfj VkHFYVrENect4cdUnpp7k+ybCLUJtyeIOfVf9qKgSvqSYhyZmn+BgG1qv0VgIkd5xUHe 0Jid94l3S4wXYkN1YQxwQLqzZXJ5wGQo5rccqzLMSaqsNLWv1tPfciDBpJ3xWxx2OPda KJg+xlOoy3uApmco1Hf/gGtCY54wusrqtsxQNwdHEkoq37SSW8KDyoqXiIU4YhN8FN1D Aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2v5cgr7f6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:37:17 +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 x8PLYSTB097714; Wed, 25 Sep 2019 21:37:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2v82qakwrx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Sep 2019 21:37:17 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8PLbFBc021535; Wed, 25 Sep 2019 21:37:15 GMT Received: from localhost (/10.145.178.55) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Sep 2019 14:37:15 -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: Wed, 25 Sep 2019 14:37:14 -0700 Message-ID: <156944743430.300131.9710870375452494499.stgit@magnolia> In-Reply-To: <156944736739.300131.5717633994765951730.stgit@magnolia> References: <156944736739.300131.5717633994765951730.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 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-1908290000 definitions=main-1909250174 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;