From patchwork Mon Aug 26 21:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11115679 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 DE8661395 for ; Mon, 26 Aug 2019 21:31:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC7D521883 for ; Mon, 26 Aug 2019 21:31:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eKerFFj4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728704AbfHZVbR (ORCPT ); Mon, 26 Aug 2019 17:31:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34934 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728673AbfHZVbR (ORCPT ); Mon, 26 Aug 2019 17:31:17 -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 x7QLDl9P000864; Mon, 26 Aug 2019 21:31:15 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=X7LtZomcC3o24aWMUujYM4G8HTGAMm7mFUHqfyB9meE=; b=eKerFFj4Q78j6fLZofwiQeieGTcY+htdw6xmYuc0MSnmn+tZr6n4Zm1/ObsUDoaV05qH vmyYxInqG1ek39OBsUSBAgvp5/qQ+jE39vFi0Cgf1Kpa/JLGGHb2wOSl6yY2yAPnUEvj jZ07lYl2ZngPw4R6UrTdbAJTsrhDeH+H3MUM/prox1cEtbtqbofTpSUOqN9qJZIGu+sO gn0Bh0bclRKY14P2fr5bOCsehokDXNPmObH6ZtUX6UeFbvJYuK1K1g57xx6O65/dShYR kmEF++0L5JLMXH20B/CioBUKwnUpVgJhz+ETOl0V2qRNgRdgkc9YOAC4gw1/y6kj1uRN vQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2umpxx05jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:15 +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 x7QLIR9w024995; Mon, 26 Aug 2019 21:31:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2umj1tk8xe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:14 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLVDIY029979; Mon, 26 Aug 2019 21:31:13 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:13 -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: Mon, 26 Aug 2019 14:31:12 -0700 Message-ID: <156685507246.2843133.6278494675997623986.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 fec25c31..60355bb8 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 Mon Aug 26 21:31:18 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: 11115681 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 028D214E5 for ; Mon, 26 Aug 2019 21:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C98172186A for ; Mon, 26 Aug 2019 21:31:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="sDsWW1Hi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbfHZVbY (ORCPT ); Mon, 26 Aug 2019 17:31:24 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50920 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728673AbfHZVbY (ORCPT ); Mon, 26 Aug 2019 17:31:24 -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 x7QLFVKn162597; Mon, 26 Aug 2019 21:31: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=pgrCmq58otpGd+7MOsmlsJJykbpRO7it8vejwWHVim4=; b=sDsWW1HiHoIREzyjcukASvEfM1Vm9mOWX/owM5EhPeT2mI3k7+PFyhpOshIGRt2Ghw5+ yjhabyiy7koYpzNln4Ga9WYJrfGG0D6AehcIBHURCKqGJz3HC7j6uJCubMU2mEvUoES6 VFFlYmeNZyfZKnoXqW1+m4s3rMSPgyCSYQmWOnz89mo+75eheFd0id8BhP0s2fFgXyDj G1TkujOuAFJjwSzkXzv2K3BssqiZUE/4YkLySGNH7RAGZwBjZA3JmbFM7PoVxlDWbU5K iNNVVUlZPOg2Ah/Rk/FsA4tvKKCsfp6h05exfQzJ408qTMlds0SMTYUtkmcoq72w/iPX 4A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2umq5t82bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:21 +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 x7QLIs5J184963; Mon, 26 Aug 2019 21:31:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2umj2xvymt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:20 +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 x7QLVJSj030032; Mon, 26 Aug 2019 21:31:20 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:19 -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: Mon, 26 Aug 2019 14:31:18 -0700 Message-ID: <156685507865.2843133.13819584101266401531.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong 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 --- include/bitmap.h | 2 ++ libfrog/bitmap.c | 39 +++++++++++++++++++++++++++++++++++++++ scrub/phase6.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/include/bitmap.h b/include/bitmap.h index 13154975..4dfb2412 100644 --- a/include/bitmap.h +++ b/include/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/libfrog/bitmap.c b/libfrog/bitmap.c index 82ac8210..cc5d99f1 100644 --- a/libfrog/bitmap.c +++ b/libfrog/bitmap.c @@ -342,6 +342,45 @@ 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; + + ret = pthread_mutex_lock(&bmap->bt_lock); + if (ret) + return ret; + + 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/scrub/phase6.c b/scrub/phase6.c index 60355bb8..e78c8463 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 Mon Aug 26 21:31:24 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: 11115683 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 3FF2F1395 for ; Mon, 26 Aug 2019 21:31:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E22321883 for ; Mon, 26 Aug 2019 21:31:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="n+UJX7NV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728673AbfHZVbc (ORCPT ); Mon, 26 Aug 2019 17:31:32 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51046 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728595AbfHZVbc (ORCPT ); Mon, 26 Aug 2019 17:31:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7QLEuwq161933; Mon, 26 Aug 2019 21:31:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=VceLnt+CSl8VWMjZl0O/AzUH6xTt1RDr4Ob3TN0db40=; b=n+UJX7NVqlx8rmaBQ4VQVbUGPg9uKj40pMf03PewoN03dI5Q60+94UV0lNcfHNon1vTG 5IpgvJJa4+gGH53I+ZOShOJrH2MxrGGopyPXPJo7SGNG5bPBKjDinCsjAl2V0rxEyLfd R5sDw+FkfjyYB3DZdn1rlwTDeLTVXDqpbYZVkkKCyOYIBpiOrreuVYnRgyD1ziKmmsIR 6l+6o74To/zAEx4gLj6FJ/8GFImlX+VPKPehAFqRxq9y3GF2Pb8T/HohXvhi3Jlzs6rX ay80N84YrjkuZ6ca1BFqad4z1nFzFPVdqoPM0KNP9losnOTNoTm7udESF/lNQlP3G7Sh nw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2umq5t82c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:30 +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 x7QLIQdj024952; Mon, 26 Aug 2019 21:31:29 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2umj1tk99s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:29 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLVSdY008478; Mon, 26 Aug 2019 21:31:28 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:28 -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: Mon, 26 Aug 2019 14:31:24 -0700 Message-ID: <156685508488.2843133.4495703850578724801.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 e78c8463..a83fffdd 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 Mon Aug 26 21:31:33 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: 11115685 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 ED54614DB for ; Mon, 26 Aug 2019 21:31:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC3A522CBB for ; Mon, 26 Aug 2019 21:31:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="k+ld77dc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728739AbfHZVbi (ORCPT ); Mon, 26 Aug 2019 17:31:38 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51160 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728595AbfHZVbi (ORCPT ); Mon, 26 Aug 2019 17:31:38 -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 x7QLElSn161898; Mon, 26 Aug 2019 21:31:36 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=3CNZ9YyYt92xEwH/THf1ZEoalA/EolQF17uPAhtkRkM=; b=k+ld77dcEhirAjpYaqf1xMMD80W0yqxNQCSdKTU4/7hhlRRWBDx28nHvvsFQoPugjUPS o2NZURH1gAszYtw8M1rtBrvnJ017Syk5z0Kj3MoIq7dcTatPHBq9KeRJ3x2lkMZMATTF HFjR87Qy30mid15Qh4vwbzaWZ/tlyIPzHq2wEDjhY3kxra4j0dx+ku1J2IKAgykk2qIX Mb0lK0aq/OwooMRgsnLpzZumwykeO2SRLPJ44THhqy4k2FfCfkwxBXpWwh8pSvZ7JocJ FIRabTiPc6KETYngR9rmdykW0JnOwGz9dUx/yTfx5C2dxoajXHDIjbNgP8XVc57PdmF5 FA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2umq5t82cg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:36 +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 x7QLIMal170042; Mon, 26 Aug 2019 21:31:35 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2umj2789xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:35 +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 x7QLVZFg030229; Mon, 26 Aug 2019 21:31:35 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:34 -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: Mon, 26 Aug 2019 14:31:33 -0700 Message-ID: <156685509389.2843133.9738555995561268153.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 a83fffdd..d6688418 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); + + xfs_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 Mon Aug 26 21:31:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11115687 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 2EDC014DB for ; Mon, 26 Aug 2019 21:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DA5B2189D for ; Mon, 26 Aug 2019 21:31:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="i83H6FLh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728595AbfHZVbp (ORCPT ); Mon, 26 Aug 2019 17:31:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35432 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbfHZVbo (ORCPT ); Mon, 26 Aug 2019 17:31:44 -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 x7QLDlZs000848; Mon, 26 Aug 2019 21:31:43 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=+2dtofMhRW7N7Chgqq/nlz/Ss/ekFfdAj6pXzPaeqyU=; b=i83H6FLhRF+QB9Cs9pp3bw+O0fHQTi5YpltFyEYG+rZeDK0CkL1X5DCRSqUi0FVCxeDt Txf+nTs1bOqNIOlfqGCICU3JAq5Sb8/cuw2YIBSO0I53Idi+Z8GY29NIs72lNJ0mBxsW aAuidUE7L9+zZ2cd4M/Afv/juQgXWAWGaZdAeJ2W2y7plCbYqCwRmtet6f+nxpIrikhR oo/Kki0JzZ8Wsu7+oUbOZ6ylc3iCHgkMPjTPAShmFasPEFsBGwzbIbx+yUtdQOnrz3+7 cjEGleVXb4IXmP/gWm6bf7bqOxFpWHDcXsDx1qUq5MEWkH1g5xiBkkUA9+6si8qvn/yA sA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2umpxx05mv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:42 +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 x7QLIR0v025060; Mon, 26 Aug 2019 21:31:42 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2umj1tk9kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:42 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7QLVfqu029956; Mon, 26 Aug 2019 21:31:41 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:41 -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: Mon, 26 Aug 2019 14:31:40 -0700 Message-ID: <156685510004.2843133.6588901612950010876.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=963 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 d6688418..f5b57185 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 Mon Aug 26 21:31:46 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: 11115689 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 7DC701395 for ; Mon, 26 Aug 2019 21:31:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5245D22CBB for ; Mon, 26 Aug 2019 21:31:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HBBjBVko" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728784AbfHZVbv (ORCPT ); Mon, 26 Aug 2019 17:31:51 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51422 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbfHZVbu (ORCPT ); Mon, 26 Aug 2019 17:31:50 -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 x7QLEi8C161895; Mon, 26 Aug 2019 21:31:49 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=whXtwiVfPJmrXSGOpxhivXZSN922kZCMEoZ5TS35APE=; b=HBBjBVko1LkCVmN0rEFwwoOkHRiqM9KWyyNOa66exzVWaoJIHKMAxKa6STZO56JWFxFz QsYjDJP2o+1gdjBTf9nKWJ9I7R2daS++EGWFgJr3KNqJuDJwuY7oiRfyUAVe8iBvyh9v ilk27LTRIlt0k3a7RBQZClmSa7+Dl9A2/pZzT8TO8KtKiE+/PeVDacx28DLiubexhUWu mgii4KNQBW7n38DahtvW9UENclMr9Jy59U0/FraKWKKxQYo2BoGl6EjncR5ElEtohlKQ MVjXSq3jta1lGSG8X2WNC+6nF7imbJf06qADHwrV2yBG5W7TCfawFCQaYtLM6YZ8BwqO Jg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2umq5t82e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:48 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7QLIw5g185531; Mon, 26 Aug 2019 21:31:48 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2umj2xw01q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:47 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLVlpL008881; Mon, 26 Aug 2019 21:31:47 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:47 -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: Mon, 26 Aug 2019 14:31:46 -0700 Message-ID: <156685510636.2843133.11157951829193779296.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 | 15 +++-- scrub/phase6.c | 148 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 112 insertions(+), 51 deletions(-) diff --git a/libfrog/bitmap.c b/libfrog/bitmap.c index cc5d99f1..c3aa2545 100644 --- a/libfrog/bitmap.c +++ b/libfrog/bitmap.c @@ -317,7 +317,6 @@ bitmap_clear( } #endif -#ifdef DEBUG /* Iterate the set regions of this bitmap. */ int bitmap_iterate( @@ -327,20 +326,22 @@ bitmap_iterate( { struct avl64node *node; struct bitmap_node *ext; - int error = 0; + int ret; + + ret = pthread_mutex_lock(&bmap->bt_lock); + if (ret) + return 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 f5b57185..33ed75cc 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 Mon Aug 26 21:31:52 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: 11115691 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 2ED4D14DB for ; Mon, 26 Aug 2019 21:31:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D42C2189D for ; Mon, 26 Aug 2019 21:31:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="mfUWnpCK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728793AbfHZVb4 (ORCPT ); Mon, 26 Aug 2019 17:31:56 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35612 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbfHZVb4 (ORCPT ); Mon, 26 Aug 2019 17:31:56 -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 x7QLDlDU000821; Mon, 26 Aug 2019 21:31: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=P5l5f/+tYVAj77qCj2BiPr+7b6pIqH9mkNpAO5X5vAs=; b=mfUWnpCKi7BvWd5jxs5vfR3g3O7nc1s31+FPCfyXbRH7TAFJlwixI4CcD4uxvcM6d5R7 R3uldc0Psx+rOhrQSRbRkZlg/ZhfsS6MjnxfUjf9uH0cbqnju+ucOyRkbUWoIq1IwDQ7 DHNS8Fzr3Ar1fkGzMj5oFQTXHz2FjKKj7Fg1gHnMGPTDSGoQVnCDX9f2ujKwnHjKXAic +vlHcvH+11se9cVLIRd9ceUitb9JbK8Oi6u3zqA1cEXFb06h8sRSWTuYWj9p6UQvpIHT +xpOo+mkB9KEEzFRulFO5uxP+PH7QHLI28mDLhWdKMlbzP5GKEaqRvDwd/w65q9P8mRt 2A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2umpxx05nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:54 +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 x7QLItFb185000; Mon, 26 Aug 2019 21:31:54 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2umj2xw044-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:31:54 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLVrdt009033; Mon, 26 Aug 2019 21:31:53 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:53 -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: Mon, 26 Aug 2019 14:31:52 -0700 Message-ID: <156685511262.2843133.11543255530722170850.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 dc8f4881..4dfa3fe6 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 Mon Aug 26 21:31:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11115693 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 B5DA91395 for ; Mon, 26 Aug 2019 21:32:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 937F022CED for ; Mon, 26 Aug 2019 21:32:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bYkDOkkI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbfHZVcD (ORCPT ); Mon, 26 Aug 2019 17:32:03 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:35734 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbfHZVcC (ORCPT ); Mon, 26 Aug 2019 17:32:02 -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 x7QLDl54000839; Mon, 26 Aug 2019 21:32: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=uENuGiK6yIjN6IgoAFydLMlWOLWxGhb8Tz6PhDekyrM=; b=bYkDOkkIWnpKmMF2SpTFzjKMQXHUxox/9vLI93vn2458HTbe3E8vda2cSVBIGJzfJiCP speRKmiPVL0RzLrUkAjNaGGMBitI4m6gblSk9lIv/Wbj6+VfbN5k75X8xyz6Iz8Oy2EQ 5UtQNLEKUuCj/G0vqyhQMmvxhrQejmuRuPCBzC6Aqo6pSHVQTZsUH7xslzKFu3YzQxra lH5zLjagnF7K7YuHGqPRb1l99XXDHzcJUTLolkdLkbRUaTLddi5OeEIdrNVNZHEPn9tV LRMboyfcHBkOg3cdV563D/Uxo2a73Bj+1S9kpPdedWqbCULpBd1TuMMlCmhEpLVuUc+p rA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2umpxx05pb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:00 +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 x7QLItsJ185068; Mon, 26 Aug 2019 21:32:00 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2umj2xw06u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:00 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLVxli009126; Mon, 26 Aug 2019 21:31:59 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:31:59 -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: Mon, 26 Aug 2019 14:31:58 -0700 Message-ID: <156685511873.2843133.18068987858962966160.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908260198 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong 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 bab8411a..c8e0f562 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 Mon Aug 26 21:32:04 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: 11115695 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 B5DF31395 for ; Mon, 26 Aug 2019 21:32:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9362F2186A for ; Mon, 26 Aug 2019 21:32:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qT7I5FON" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728936AbfHZVcK (ORCPT ); Mon, 26 Aug 2019 17:32:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51766 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbfHZVcJ (ORCPT ); Mon, 26 Aug 2019 17:32:09 -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 x7QLFIuI162223; Mon, 26 Aug 2019 21:32: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=R87H1I18+LoaG7SaSOMBuU9moRCa4bs0hv8j2iblvW4=; b=qT7I5FONDl+rtun6pffCYMQHn661vuK366zFlkW0mtFFb46MiSe4T/IhgcO1IWXwbYKC dYZEmH1uFkFfEfSpj27uCbrguUgc5xJConCzJgrs5UdQIkiNA6qnk3QayoiUUBqpi87e cfP7b2iV8kQL3OsSzUmCs82cEtjpj6izdl68n5n/X+kKEyL4qoDK7w/xVIvSfhYPTt2b 3dmKg/VBe1FF8zBBP2m65Ed3YXntvr1Rh8MUKcXY3qIAwEXDdmXiMtgPeplpIjMuAkjr pEF9PTreBEBYm4ocVR+WTe+cd3nFK/q8L1x+Rjdo9N2iP1XW5wutjnAvK1HXOw24l9ws 2g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2umq5t82fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:07 +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 x7QLIQto024938; Mon, 26 Aug 2019 21:32:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2umj1tka9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:07 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLW6Ds009209; Mon, 26 Aug 2019 21:32:06 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:32:05 -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: Mon, 26 Aug 2019 14:32:04 -0700 Message-ID: <156685512486.2843133.4982411923908096479.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 3bf7feab..d4a8b209 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 Mon Aug 26 21:32:11 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: 11115697 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 1C6A81395 for ; Mon, 26 Aug 2019 21:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE16B21872 for ; Mon, 26 Aug 2019 21:32:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Jh9m3R38" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728964AbfHZVcQ (ORCPT ); Mon, 26 Aug 2019 17:32:16 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:53972 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728807AbfHZVcP (ORCPT ); Mon, 26 Aug 2019 17:32:15 -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 x7QLQogt003337; Mon, 26 Aug 2019 21:32:13 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=555upV/s/eH9nUfAjhk6HSrMBsulQH3wPfhiVz761Q4=; b=Jh9m3R38IXvFhNs82vWKwTE7BK6Ypyuu0wNdhCcsoS7p8mMF1Tzd3K1BNK8FkUhJS2H3 9bStgf/l/d5Fn62D7W2MjHTe3NAJiscdKy2a2Stjwis6pZdvUSJWQqE1mQK3vR/tZ2os eHVQYqg0/sZIA/2EEJOxQ+Rh9K8L5M5FZgTpIFOk2FfqKGWxm3uye+H3vmLWbRZQsYyO tz89nl91PxPHGwnAMpaUCG5JlCpBjyk8fF+V9Q33QmBY+/TmjwhHnKxslJMQSlPGFE2T lpzeBCU33P+cbEABLsORi/igbSbaTTJzfTsiNLzTUTL8PsBW1EaKMQmxI9FOWr/6jqCm Mw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2umqbe80sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:13 +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 x7QLIcjr169563; Mon, 26 Aug 2019 21:32:12 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2umhu7x21k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:12 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7QLWCoh009276; Mon, 26 Aug 2019 21:32:12 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 14:32:12 -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: Mon, 26 Aug 2019 14:32:11 -0700 Message-ID: <156685513113.2843133.11215244971656871347.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 2178c528..9b458fb7 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 d068634b..99bf54f5 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 fb34c587..bce56b1d 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 Mon Aug 26 21:32:17 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: 11115699 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 3199F1395 for ; Mon, 26 Aug 2019 21:32:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0545B2186A for ; Mon, 26 Aug 2019 21:32:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WDDpHBRl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728962AbfHZVcW (ORCPT ); Mon, 26 Aug 2019 17:32:22 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36120 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728807AbfHZVcW (ORCPT ); Mon, 26 Aug 2019 17:32:22 -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 x7QLDrlJ001023; Mon, 26 Aug 2019 21:32:20 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=zq1+yaKl/PDatoP88GAhJJ03OVlYBl5I5wvVoPv+S5c=; b=WDDpHBRlr6VrdgZrdBzBTipe8+EWHy9EwEf3lpsdG+sIW8YypMzbT0ZTMyv9XSH5uN0+ OSWIm2tte3qf0Ny/Wphu5ZW4G6T8x+I+vp9tbjkuC+Vb74ryZM/rMHs9wksD/0E7BDLM rol7ngeqomPjrWWyWxjguRlmv+lz3OJJNass1N7hY6VU7Eg83TqkUgClkVjFgB/8h99U roEdyq2rZbe2rfcKobIWPrichMor0YqmTmOYR+p/pIevetgYbs7UMXMNDvCv5ohI44kY pZAeL8hldUQOwSUKh5J0wHH96/9jzId/o3Rj4Vzbz98+BsigC3Mdk2VKTrUsncSm1rGn 5A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2umpxx05rk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:20 +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 x7QLIRQV024992; Mon, 26 Aug 2019 21:32:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2umj1tkane-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Aug 2019 21:32:19 +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 x7QLWIjL030371; Mon, 26 Aug 2019 21:32:18 GMT Received: from localhost (/10.159.144.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Aug 2019 21:32:18 +0000 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: Mon, 26 Aug 2019 14:32:17 -0700 Message-ID: <156685513738.2843133.13097768805699303210.stgit@magnolia> In-Reply-To: <156685506615.2843133.16536353613627426823.stgit@magnolia> References: <156685506615.2843133.16536353613627426823.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=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-1908260198 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9361 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=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-1908260198 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 fdbbf294..1ca550dd 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 b34cb4a6..886e6c2e 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 79c8a6b8..a030b1de 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 224081d5..d90b4028 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 33ed75cc..1e55fad8 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 99bf54f5..645b2c50 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 bce56b1d..6984d24c 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;