From patchwork Tue Jun 27 08:53:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13294209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C64B4EB64D9 for ; Tue, 27 Jun 2023 08:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230513AbjF0Ixl (ORCPT ); Tue, 27 Jun 2023 04:53:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjF0Ixk (ORCPT ); Tue, 27 Jun 2023 04:53:40 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F708A4 for ; Tue, 27 Jun 2023 01:53:38 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35R8E0p4004331 for ; Tue, 27 Jun 2023 08:53:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=sfHNJdUlhL/8kA7zdL/OEaOERDdH5e2QILIxLoyBKn8=; b=JaB+lk1EmUA9FRCoM2/MkAFRU3Min4aTrziaIwutlIsi4fwJ7e7j+9K5dkzSC9/NxTTK fk3UfHZppoxOl6pCTWV4vxKAlNve/ItYrzV9ZVsz+FnrWIfAW4adIyHRCtPC5LNqCIzV VwXk1zQVbe52x/I9+/4LvDS+9jSNbb6nN3HyNv3dAnzlK8jRa8+mAUpYNdTQ7xTJwKGx fcRIccQbBJaSrqN0a7ukf6YHcKq3iOhFlEHe8D6uees49S53fw3NHY3QP9Q92Tkb1rPx DwG0cMlBXcWLx3OvmAFxoD2se+yu/x3GL63ICJMArZ51OlaVa3DYhs9XSCFfuKwOzqxS 4w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq934fwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:38 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35R8fJTL028344 for ; Tue, 27 Jun 2023 08:53:37 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx4792g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BIQ3OUC5bt3S/XhqxW37pP007yqQu4lcGoanLvtCMZiufVuHimrOIpP/Ik2f4e967XcajIAdhfAH48jmfpfNh8q7ihIoYvw8oBQRm+jzqX4el64/o097Xe7ZqRSwa2CgdISZcpApWnN8xmdievOvOH38RizKISJ8OiKcjhjlbSinqV4y4cI7el0E5ICma/lojGjfaMCfDdvGNTMA/CTCJuM/D/wC5/HFCZ57obbv6d1uAbG1bFmCRHBWLZIsI+SZKx9JMuS+OLnnPL/z1NXaqQZU/ipQAgxvem1I/qjyYugXyK7OlfPk8BmZEMpj/jjzvQUgVuDz+BV+dADrighquw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sfHNJdUlhL/8kA7zdL/OEaOERDdH5e2QILIxLoyBKn8=; b=fYBH9mRpBR6ihO2Py+1uWDPZH8arNyGXvZ73/i80btb1dLPIdgEojncLQGLg1RAGTYTzY7TVkNEp62P6pAmiZF9N71pakKLfquKCzE3wkfqgH2D7DYzUj391+pCxwGnkbb0SZjbQp5YBMQRUl4fi4IctLjq3YdNx+hffblJFklNOaToZ/ra0hpFbzKXFPG09Kt/gYaOIF0OjmLCkAe0+k/f5gXzkHWCbOKYnK95HvpoZNt2jwfeMfuTOtpQW9oLNQOZjgjsKHRo77wWx7eK7FX5Q4gsecS9dZKiRWAMJeFoE0yR5ev9uPMls7aCUDM+e56JbNFYUFTDagYf3DzC0xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sfHNJdUlhL/8kA7zdL/OEaOERDdH5e2QILIxLoyBKn8=; b=PiT84PZhwEwjZVHnpzVK8wb2HHbidaDNQhF16PiX6gIg5+M+MYqeu17Rvo7W1p3hbSQbvEuX+QtdrPnJJ1+RU/dotHYsZI/sQD7mZiDWeUUCFYcnMktDN0K6I4v0ryXfCXO/KGYA6WQIsbvG25PNuTWjOp0CkxIIKXX5+KKbkI8= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6520.namprd10.prod.outlook.com (2603:10b6:806:2b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Tue, 27 Jun 2023 08:53:35 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e%7]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 08:53:35 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/3] btrfs-progs: dump-super: improve error log Date: Tue, 27 Jun 2023 16:53:13 +0800 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0039.apcprd02.prod.outlook.com (2603:1096:4:1f6::9) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SA1PR10MB6520:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a691b01-8b73-4b01-214f-08db76ebfdfa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MWG1ZZ/uQ/V9ISNF1bBTp9cFQtA4EMVAZ0g4r3dgoCjkqPSs0d72R9TGrmB6T2PN9KjMmyZAMlzqBr6aA1DtpTiIKXNM1LInrSd7oWrkQbVPBeBw1/IJ4KrBEwcY5Bu0kbr7wOclhQCs3qiilKo2hP9DIiUA86X0x12TyOhNxR/8Yu9NKubNd5JrOcyDikY4HSfR5Iz/kO3x4LWXcScT6ivGWs5jS+63harRLwx3uZo67SORnNOTY0ZWGpsgwyOI8AN0ttWPj1ZtFQzoYYgVsOuTdsdjkD+Yj/sz1LvjPk3SQkojloXhA5UCQCx7McImuxkznCTpsf7SodG0RikFPd83CIGqIdAONtJF0y4X0MuTZU4Gl+GGK2SDorqVYlCLPcXTnZdkpDZ6t2nbZeERc93vOksSy5jmUesFlzqP/0YOIidv1/D6Ew3CN6ZSNm7KYOGJyU1s2N2J8z8NcHy00/lRIm4oxu8U1GzQe+6RvGFHvoTliITNP+5pMFn26s/YJd3UOZbR2b5fYQ08fYyBHm+l+ZRx7BFUH86mVVgrvRosKLEKsCeA65VcEAJgWOPp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(376002)(396003)(136003)(451199021)(4744005)(6486002)(38100700002)(26005)(83380400001)(2616005)(6666004)(186003)(6506007)(6512007)(41300700001)(2906002)(86362001)(478600001)(316002)(66946007)(66476007)(6916009)(66556008)(44832011)(8936002)(36756003)(8676002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WGMD8rwtmJdHLPHOVigBSiII/AVrL2gjVHauG48cHAI9ezC1gaXWXs+bPjpi0sUJNhrY+2NokIBPCDJ26+kEzbX6v7vsd7c9GN9y7Fy93VVAoM2cKzd4mJa4HuxmI+jgtMOVsWXeQMLC8ZbkXRcKCdfZ1EqDPjRruFZWmVWq2NuwsP4RCW0a+y1qoKL0adzfheNaZQvUruUt/okI42tWotTYNF76Q9UwZ0oXBr+L6HL+N52uXyGACXC5nKkhk4RnDi4inI0fthFMH0JV4AgN4PyqTQGqyWgf+3hTUhPpWwrl4dXEpSdqQbH2cLnfy2fsZeJrEPoKgigg0iVcO7AqnbD+uYmDFl9E2tzx+Wx1U/0dCz8O+O416As+/7ak3LmrtMXmNXgDHxoJecOxrJNQXZq7Ed24cCynTOqzZSp/hNXLT8Z5xLfO84b2VnagXkuA5nXVAxBVzpaLCDsrAw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+fz1COUpm8yepI9jbR50OewwLFsJZNXD9sDpdg8havGIoBIJ3nY8Dx22g X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: C4uuDv5Fj+rBt2s4E/SelP18HPdxQ6dhmywv8vCOFYcUgKOFML0v8C2KPJbN7WF3b/SEgehnoXuXR6On/OHixiMYJWtWYb8z7ilz1sl/dbZugkY4VpdCvtZaSy77hxJ5/7G+y5xYw2S1pPv2IpbARkbRdEh0HswH5hpBgqDM6hJcYXX8XpccF9+jZQjQSXPjnE+HT8ym/sklz1UCPdohVEJcAyy0/Pp5e0spn2FIegh4A9q5M2jdl9MW3vfHIeVNiklB+uIHkGZRuu9Kp79MvODD3KwMDEnWBIpioHVYWaYmFq8bs6F9kEehl2Ic6EWBKXPuf85gHg3OXi7/82RyLgjORIFj4mHmLNE+TP1AVG+fmtnt6YMSgcA8SdgJMDpdz5oaNF+37yVzFlxkHwpXPwmtQvsrmkg30+leV9ZIkSbginMzASA8bX7Y1C3a2QqRaDBGnS1aQPBmYJp/WjSAQcUutPGAicLeOF2LpexqLt5FtYAIBu7rFO3pr7KtoaZMCYPZDlDkSxVl91JO1FLAuW14rtTfIAlf/te6Fd8UvvfWnx7SEyQ2FIhehOlNX2CJoB3dAM99mIyetziQMNdIDbEWZPVMQWhmtPkRrGf2tWKmcgEbNdrMFOrYryLhT0SnnWgyuoirRhWSdy87VbBBZMyqkj5WAMmMoQ6MJUxGruIqVPMeSRZWT3P94089a562w43uEHDItxll57rJ5ttT/BhNkDTAnRObh61z9n0dz9JGYMs5MVZFljWbKCxfnXfdsD7Sp1gz3WcGxc7EQqYDKg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a691b01-8b73-4b01-214f-08db76ebfdfa X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 08:53:35.4606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NMR77TFuaqWvOpwtmHSk3dvy/X+WLBO5oTIuuDxJriqplQe50YNcFYzdu7d5rZf/BRg/5dyycKvT9+xtkRNqVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6520 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-27_05,2023-06-26_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=942 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270084 X-Proofpoint-ORIG-GUID: nXBx9d2LmKFoUiz1ZKOb2va3GHiuv_dR X-Proofpoint-GUID: nXBx9d2LmKFoUiz1ZKOb2va3GHiuv_dR Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Add more error info to help debug. $ ./btrfs inspect-internal dump-super -Ffa /dev/vdb10 Before: ERROR: failed to read the superblock on /dev/vdb10 at 274877906944 After: ERROR: failed to read the superblock on /dev/vdb10 at 274877906944 read 0/4096 bytes Signed-off-by: Anand Jain Reviewed-by: Qu Wenruo --- cmds/inspect-dump-super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds/inspect-dump-super.c b/cmds/inspect-dump-super.c index d62c3a85d9ca..4529b2308d7e 100644 --- a/cmds/inspect-dump-super.c +++ b/cmds/inspect-dump-super.c @@ -41,7 +41,8 @@ static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full, if (ret == 0 && errno == 0) return 0; - error("failed to read the superblock on %s at %llu", filename, sb_bytenr); + error("Failed to read the superblock on %s at %llu read %llu/%d bytes", + filename, sb_bytenr, ret, BTRFS_SUPER_INFO_SIZE); error("error = '%m', errno = %d", errno); return 1; } From patchwork Tue Jun 27 08:53:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13294210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4B4EEB64D9 for ; Tue, 27 Jun 2023 08:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjF0IyA (ORCPT ); Tue, 27 Jun 2023 04:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjF0Ix6 (ORCPT ); Tue, 27 Jun 2023 04:53:58 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05E28A4 for ; Tue, 27 Jun 2023 01:53:57 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35R8Jbv2028000 for ; Tue, 27 Jun 2023 08:53:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Fx7IaBf8CR/fP1Wtxm/X6qMQSOmOwdOEDudKGXOs3NA=; b=znaZ2jnqYdprTeAaPTZKQTX5PW9k2/RYNeAf6GP56qXu0O0wbjWw1KmzmSeFjy3v1gxu qsMADyl2rhnWFjGW5kQVni/Z7K+hv2K+YZ8ysJiuIMlEO58cYgCsJKnIYb/IonkDKWQR l5Cyti6ogAU5Dma0rwiGoSotYcGT5h/71KU7TiQS/YRSyny03ahmKMBerpISFxAhMJmS ItcOoE1hFig03IPUsdwjjHhTdE0H8DtLg4tRMp2mdb7B9evC1ASFzWvLX2ETGG9dRyst DG+GeYcBL6y6Yux54QZZ7MjmSgqmeMPEt9YEamNHd+tdYJpD5+1KM2oIhxEFloNQc4FD Hg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdrhcmj3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:57 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35R88sfo011169 for ; Tue, 27 Jun 2023 08:53:44 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2043.outbound.protection.outlook.com [104.47.57.43]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx46twq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ms4P3FkIGZaevBUlebdJWS9GEhVenJWRhEW8lfTEIhzmGpz9a9bilp5eb2nQh+UzanaZYBaZLehfV09zVDzTBkY2xWx8ef+VpYQQc8ctMbM0t9WtYwrMdJUWdUKfgX5ophys+ptwPaRk9urhSagMwZ7NtCXAkE7v+mt3xePVCfRXJvobVadsag5dvFeKAZI0J3SxnYmr4v+xP2soImxA89apAkFXUPufKWikfIUyTTRpE+LwGaoq+WkDFbsqmp0CyTfXji2vW5rNjLLuPAfTKDruVi8WCYsLK2rcyC6rYOgT4Fy4QchQt0NFNRP546zgzqdcxF4wjw44Xasq63m4vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fx7IaBf8CR/fP1Wtxm/X6qMQSOmOwdOEDudKGXOs3NA=; b=gt+XFwJTg4kf7AKd7b7GOd5dN1mMDQs4hmArn+KDRiN2gUzCRDOgXI61pcWqMwIClX+vDN/m5lc7HWRsgT9Nf/H4uzb2HVNX13lhPx3cxV2kSV6iWBdtlxn0kL1eOBKmPIDktslizZ/Yo93rcDoOrMHX5EZ0jIPnRsqsdLSpc3541rmDMdR6UNGdgKtFPMjua6+bYHouv+ggvTU/6X59BNxkqYdEro5ezpZVtqof1pZU16s8QFw1NnrzJaCUfhieCGfNY1OKbveKiVduyUg1K1Pta6Em4qvQKo0hVHtDaq3ht7Xo0Pd7EvyUA1R5k9dk6CQv8bC2HjRiJ93LcIHUyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fx7IaBf8CR/fP1Wtxm/X6qMQSOmOwdOEDudKGXOs3NA=; b=F33QK5CK58xKeaTtHr2dt/1N0WiP3BsMSMwUIRm3rdT9l64j4l0/cNaJHebIRGEOeMIRkoDSLCTEepUptEHAooRgiaM9tynr/fE2Sa6SuQMfEvvx3nbTrapiBbaHQXBq7tB8W1P8Sm+bnoPeZM837M74Xij7+LOHG/HAYY1YqaA= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6520.namprd10.prod.outlook.com (2603:10b6:806:2b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Tue, 27 Jun 2023 08:53:42 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e%7]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 08:53:42 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/3] btrfs-progs: dump_super: drop the label out and variable ret Date: Tue, 27 Jun 2023 16:53:14 +0800 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SI2PR01CA0024.apcprd01.prod.exchangelabs.com (2603:1096:4:192::20) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SA1PR10MB6520:EE_ X-MS-Office365-Filtering-Correlation-Id: f28afeac-6a85-422d-bbbb-08db76ec0217 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aGW6lylSawf6nzIMiciO/yKUDm2QPwsuOlWulCm1jZZ/XAUM45N9SWd0L08vGy+IEv+V12osX3siHxqQ9G3yoNb6B9v2hsnTvZEDVPlDNXfALgYvJ6dMZD8/K5QadN7CbYJg13OOVZXyPOOplLtELTY5Q/S7rr++ysajMZlh8Msv0qr+HjDBF9ddirRpFPbBfLMl90Sj6lKhaaeahT83SjkCmkCeR8jmVKXZmnqgUgnzooG5j/M+bX/J3P1cVh8GUV8PIVC8PQ4MmEmIKUbJiFqXslfDA6250fUmZtscmKO14BjzgYdVACj5ZrLLJZ4ALUPnppONibnB4OXFcEOIX+mNXumlD60Xwy2P+ouJ1ZdSBdb8E8mzS4w/vAXolsRycmiMw5dDPqT/vDQpi2fwqakWGZv2UzVms2pGEGaXvZyMJsJzJb9JTL7lhXSKH6xAGGCPEmaCRR4Q7Ln6BhmywRXbl38vVoGqWo4QttkhuC4dZer3W1em2C3D0QWLu6zHq/chNcGQ5aYpxxjuSYg7srNfS7B1hUNyd4q5LyupceDeqF/KNjhR+bfs/6nE8s9+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(376002)(396003)(136003)(451199021)(6486002)(38100700002)(26005)(83380400001)(2616005)(6666004)(186003)(6506007)(6512007)(41300700001)(2906002)(86362001)(478600001)(316002)(66946007)(66476007)(6916009)(66556008)(44832011)(8936002)(36756003)(8676002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N9zGBFDEjqIP0yLz6AifF54pUTUaYwEsSxtIoVwnIqNwKcw3rJwx/Y55CkIz7yi6lZKCiP3B3CAlASiwKN31WagHqnZ34ScvQv55QqxeyVPGpc2QO3LsV2mE2apkFryEJpciEfJ8jMaw63DcgCzzuoOGzZN6vAVQPYuYN0bT/WEau+t8BDvQoq/nkc8UZ5Cq6lhNMw3qUEqdkEATlR2nN7z0EDJHjpF8jXCLRdw97XLyVRMbXGed8YRzolGNNeohjYHXYJfGgEDft6JlognCHXvmuVDN3OiJE8BZSkfNGz2bJP+t+OhS74QrzrXlDzIkZpwnbmkGx6MD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MS-Exchange-CrossTenant-Network-Message-Id: f28afeac-6a85-422d-bbbb-08db76ec0217 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 08:53:42.5703 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ul7uKelJHu8MV19h9/+mrvtF28Ywb6u9sZgwUcL9gs6ZzRHgkcHY2i3C15VlPUbT+5jDB1JdwhbLLEqHfedjwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6520 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-27_05,2023-06-26_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270084 X-Proofpoint-GUID: OeirntYT-bt2blc2DmjKKn8T186hfvDd X-Proofpoint-ORIG-GUID: OeirntYT-bt2blc2DmjKKn8T186hfvDd Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In cmd_inspect_dump_super(), at the label 'out', nothing much happens other than returning ret. At the goto statement to the label, in the for loop, we perform close(fd). However, moving the close(fd) to 'out' as well is not a good idea because close(fd) doesn't make sense outside the for loop. Instead, simply return 1 instead of ret=1 and then returning it. Drop both the 'out' label and ret. Signed-off-by: Anand Jain Reviewed-by: Qu Wenruo --- cmds/inspect-dump-super.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cmds/inspect-dump-super.c b/cmds/inspect-dump-super.c index 4529b2308d7e..f32c67fd5c4d 100644 --- a/cmds/inspect-dump-super.c +++ b/cmds/inspect-dump-super.c @@ -84,7 +84,6 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd, char *filename; int fd = -1; int i; - int ret = 0; u64 arg; u64 sb_bytenr = btrfs_sb_offset(0); @@ -156,8 +155,7 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd, fd = open(filename, O_RDONLY); if (fd < 0) { error("cannot open %s: %m", filename); - ret = 1; - goto out; + return 1; } if (all) { @@ -168,8 +166,7 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd, if (load_and_dump_sb(filename, fd, sb_bytenr, full, force)) { close(fd); - ret = 1; - goto out; + return 1; } putchar('\n'); @@ -177,15 +174,13 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd, } else { if (load_and_dump_sb(filename, fd, sb_bytenr, full, force)) { close(fd); - ret = 1; - goto out; + return 1; } putchar('\n'); } close(fd); } -out: - return ret; + return 0; } DEFINE_SIMPLE_COMMAND(inspect_dump_super, "dump-super"); From patchwork Tue Jun 27 08:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13294211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C25E2C001B0 for ; Tue, 27 Jun 2023 08:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbjF0IyB (ORCPT ); Tue, 27 Jun 2023 04:54:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbjF0Ix7 (ORCPT ); Tue, 27 Jun 2023 04:53:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F710B8 for ; Tue, 27 Jun 2023 01:53:58 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35R8DqtB021791 for ; Tue, 27 Jun 2023 08:53:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=OOdOXskmlhqOWVQ1qbGyzQ9ajpQ7At0RCzzoV8Ecn/0=; b=tyxBV1afyomplus0oYxCPvHT+yZluESAYe0U6Nk2QxS7PTwmT7nQBem61I1H9q7LSDJn Ziz7w6G8PvigyhpkJAbtTKUi5Mgg8uA4m8INlm6Xs2E/VZA2GUb4V/QDcETsflVqjSvk 8lfjiXasTxq0k3mQRC6eirUkmFJ7T4B2V/xV0nSMy4OKybWMkibyJTHvxbsP0LgRlLgk CbtMSjjDv5nqbQzK5Obb9VRSEfFbgUztsmWQye5l49LsHFj3Ox2C8pe32EaEs/xRkq9r 2fLaYlBcP9SDRzL55Evx0ujvT8FKUFpzZyw90Orvoj0gtjyji7aPLas1f/DPXuYGSm7m jQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdcgr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:57 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35R7C0Yo026361 for ; Tue, 27 Jun 2023 08:53:52 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2048.outbound.protection.outlook.com [104.47.57.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxaq3kw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 08:53:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frKzDA2iY3rGOLmo5TYr2nlwENpk6uXzPRLpKuKStY/StyJQaFUwpj9O+oxAFIg4i+9BS50fjuKjvDpqjX0c1teTlQB1Ms7P0IjwWkDGz3vZ+5hDpjzj0bzv3iSDzXsXHouRyfQKzPGdn13uOdxJXfDgF2lVX1ik7dvMETFGZ8r3xIKFTG5FNpJ1b+mdHe/TeH/0K9B3mFkj2itH1hxQ/gOSV/NN6R8JHdAVoRk1Gg+hdxl/6wyjWM8f0SMe/uGhSpfqhwmOim1gRDvd/dIzl8jVT+j2QOdBkP5T6pj+aGPsXQXqafRme4CSomPRc3XBtxXFST2Njcb+87CarvECig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OOdOXskmlhqOWVQ1qbGyzQ9ajpQ7At0RCzzoV8Ecn/0=; b=TGlxXkae7GnyP3jw8Gkdtgi2i2enyfDvft0JbJYmdbINhu9Es/8zhbW8krDdKLhHqAFumWR3L3tXVXY6J0qcuxQohZt7dOTM/7r6cJl0cgkKQg9s3TaRnUPUD+leON2w4KtIhYBMuDO7yF9o4h6Oq9JL7kiUhuNzD9l9R0BAY8Nfy78VvXfx0xGy9x5lEydovG/ynfNusltdJdIhZepqnbJk+9ycRphcqF8j73BmwUIoBV9BgQQHof72NBO9HNgXD8BEBssOhKQQw5DZ9YH3HH6JtywyZbvgYj0xG/q9PQOD993Pw8QT2EK7ukAKdL8lHVCZc+snU361MCMvAo9jhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OOdOXskmlhqOWVQ1qbGyzQ9ajpQ7At0RCzzoV8Ecn/0=; b=qguAkVwTcdRHZA3N7PaVmgQgHdgFyxx/iQZuQzVdngeHjBb0P0xLPXdKKAzaIDPNvnXG7Su2rYC3OH/0OG5NWfZeKmSrC0uXJbew+4Q4I/vs93lNbY7VSTQJCY4IVPoP9H2rnwp8BG+DEAeV/VFZwIclXItygRwcSZYdXIigU2k= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6520.namprd10.prod.outlook.com (2603:10b6:806:2b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Tue, 27 Jun 2023 08:53:50 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e%7]) with mapi id 15.20.6521.026; Tue, 27 Jun 2023 08:53:50 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/3] btrfs-progs: dump-super: fix read beyond device size Date: Tue, 27 Jun 2023 16:53:15 +0800 Message-Id: <6e8980b7306716ed8a71dc50868169ae96424e79.1687854248.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0002.apcprd02.prod.outlook.com (2603:1096:4:1f7::16) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SA1PR10MB6520:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d89f8ee-584c-4304-7f88-08db76ec06ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sP3oMasPxCc+qDBLPC7UZ5jjHAzi5B6BKF+RdtC05VlpfDfQwWNyc2zq3zGgvDQRFaoPapAEobI31SvDDEnbO8l27ZiLzFCdNq5RwZXZUhL0643ypw07aH68pG3cE0MjKhrg5DlIJi2e6HjD5kPc61fb2uWPS6eZGJtp961pyX9uMG7TjEwE3GRNmdwxuDLi4NuyU0kyt+E9+pUHIitGbvxadY1DyOfmdOfagM61I6NM0/QbbG9H60WlaZSMKodZmK74FZzBWFBM7dm1KsJedK7r2N2r8bFouv2NRPThihKTZEcLgPp79TCWu0y5qbJnKRC8+lrFnUPv5g+9JpymMfiRj3kz2fDZLaEFRtxGFZgeS1BTA/aCtTohPu436yFoiFYdCoRXXzd7tkQ/DowYD8w6qZhE7uMHlKWZvwYY0/P/bZvIufBehDgEqFR4AIDRCltzHFmzqSU7n4t4BXRPpb5gbFHbK6lT8PChXvqbvRDMskn9Qbu14sktgNZgISxHicuCflcVN1impFENV9sw72JvPKR/9NLP/yB4jLtQks5M6Eu+8xqaIzUxYkFjdleW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(376002)(396003)(136003)(451199021)(6486002)(38100700002)(26005)(83380400001)(2616005)(6666004)(186003)(6506007)(6512007)(41300700001)(2906002)(86362001)(478600001)(316002)(66946007)(66476007)(6916009)(66556008)(44832011)(8936002)(36756003)(8676002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +CTxe6AkzDoaKbkYWhtkedoUgul974IrITvvaXvyDRACsuKLg0iqR/iLk24J00iIfwB4GC/TyW+gN3hPX7T0L1yJXcLu+PLKfyO3oMYgS8KdUcjNp03+w2ow4GhUw6Y9T1ZPv5kzsEc0DD8DxVbzt+U2l3nifryABF5/LzLOs1BZV/IuAdJU1cRG4K89s7ne5oPDpY9XuoKm0plpz6D+CFfznWbrf7IRUPQYJRZGScLAl0P2l7KQZ3xKP3pLNs1+czeARNj4qx8gmb+CsHmyX05Wuk0httANLGx/nCjXsNqrRR7zkVcVC6gYqdHRu07xzucS9T/MnQeNQr5OlnYYbPKq6h1J2CablzGnEL0DFa/EYfGJdXy+aVK7d12Ymobm+sB7SnL8gGbGMzsXreZdLTHuMJ3/Z1MNwKVDoRkDYwWOpB/I13yApzMEWpk3ffS+pivB2+amjtWpS9yDs3dExawNkFL/SN6OLOcIMR9Gtcw+NDqQXBoyiNU3LYXzLikh9c7OCSOpme81STWRMMWhyTmTS9ClOQppI9RIeyI1LShKbRwDsWDDTCC/t80QU+v+0zoPKM5gKhb1e+VvSaRFJYnYyGPHz4P3Y70N9qIPWfGNpxSQ+D1YqcrrHpPekjxd0EeXdCC19mW4J9Rg0LTerle8BCCloee23w74z+m5KYUeM+bBTj7iJcbucdqTdtEV9MwlfXh1jAhwOJCV+5QTRyqmLGlaNasGO5jaSbidX675d+VXTUno0C/V5BalusaYQneQwLENdtEPssYpytHN0J383+Fsp1mbXzaGGAzVXgyY0onMmj6hLJAkkFik5BarMA0LXo6iO8T3499aPEFm7q3KPpW5A4DmczegpXrNy/g+B/Zf+mDqgGEnzk0wTtiAZTunvTnl0U0r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J1dQhiDZELKv4ZeQXMHKpbS46IbGlX6VILbznKraZrcC1C6Yd5hNg+ryPN3uALZh8kFBn1CQ0BNsPsnkfLzMDve2UUzDDTYwyt+p668Zvt0eJcuKH/XI8TS3dVCE+vTz6iQoIC9DD8GNKKdS2JU2NzR2NVQx/Qki9XAEYBdcq+ZDdJgpOOBO7oyzh48vPSZSvUB/KfdTYHYkM4ujWpWuAmRE0ZH+ZYjTmu7OfkOPSWHWLt2LutPl+ZX7y+VaOIN62Xy1Hf8iJbbsy/878aepEqqck24Rp7ASvgahpBQ3xYUkd8KGlO8xexZifSHLbav11cU74/M+La0bM0+mM1UBhTN+K7/6hyuM1Rxq+1InxxBe5K+emQK3K7rrSPe4YI7pwg1v0aj/AZTXJQb1LQgIlLfrarZgvEmsFVkxxKcqkRp1PY7WDNwtl3nVtAZvt1T0oBeIn4q6nUB8L46fUBjdu1I8XLbUg4OT/O1ntFM3CPDyBfSew== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d89f8ee-584c-4304-7f88-08db76ec06ea X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 08:53:50.6076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RfgLzLNWXDVyepSgiyJiK+1v/6wicP7isR48JmknoeIELcO/IHy9daqLYy4jIfIVNiuStQl4wCRmic+CeJaImA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6520 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-27_05,2023-06-26_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270084 X-Proofpoint-GUID: 6Trpm4K35uJk6QziiIEDfb8sDP0c2u4w X-Proofpoint-ORIG-GUID: 6Trpm4K35uJk6QziiIEDfb8sDP0c2u4w Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On aarch64 systems with glibc 2.28, several btrfs-progs test cases are failing because the command 'btrfs inspect dump-super -a ' reports an error when it attempts to read beyond the disk/file-image size. $ btrfs inspect dump-super -a /dev/vdb12 ERROR: Failed to read the superblock on /dev/vdb12 at 274877906944 ERROR: Error = 'No such file or directory', errno = 2 And btrfs/184 also fails, as it uses -s 2 option to dump the last super block. $ ./check btrfs/184 FSTYP -- btrfs PLATFORM -- Linux/aarch64 a4k 6.4.0-rc7+ #7 SMP PREEMPT Sat Jun 24 02:47:24 EDT 2023 MKFS_OPTIONS -- /dev/vdb2 MOUNT_OPTIONS -- /dev/vdb2 /mnt/scratch btrfs/184 1s ... [failed, exit status 1]- output mismatch (see /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad) --- tests/btrfs/184.out 2020-03-03 00:26:40.172081468 -0500 +++ /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad 2023-06-24 05:54:40.868210737 -0400 @@ -1,2 +1,3 @@ QA output created by 184 -Silence is golden +Deleted dev superblocks not scratched +(see /Volumes/ws/xfstests-dev/results//btrfs/184.full for details) ... (Run 'diff -u /Volumes/ws/xfstests-dev/tests/btrfs/184.out /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad' to see the entire diff) Ran: btrfs/184 Failures: btrfs/184 Failed 1 of 1 tests This is because `pread()` behaves differently on aarch64 and sets `errno = 2` instead of the usual `errno = 0`. To fix check if the sb offset is beyond the device size or regular file size and skip the corresponding sbread(). Also, move putchar('\n') after a successful call to load_and_dump_sb() to the load_and_dump_sb() itself. Signed-off-by: Anand Jain Reviewed-by: Qu Wenruo --- cmds/inspect-dump-super.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/cmds/inspect-dump-super.c b/cmds/inspect-dump-super.c index f32c67fd5c4d..a1c3dcd9d90b 100644 --- a/cmds/inspect-dump-super.c +++ b/cmds/inspect-dump-super.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "kernel-shared/ctree.h" #include "kernel-shared/disk-io.h" #include "kernel-shared/print-tree.h" @@ -33,8 +34,27 @@ static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full, int force) { struct btrfs_super_block sb; + struct stat st; u64 ret; + if (fstat(fd, &st)) { + error("error = '%m', errno = %d", errno); + return 1; + } + + if (S_ISBLK(st.st_mode) || S_ISREG(st.st_mode)) { + off_t last_byte; + + last_byte = lseek(fd, 0, SEEK_END); + if (last_byte == -1) { + error("error = '%m', errno = %d", errno); + return 1; + } + + if (sb_bytenr > last_byte) + return 0; + } + ret = sbread(fd, &sb, sb_bytenr); if (ret != BTRFS_SUPER_INFO_SIZE) { /* check if the disk if too short for further superblock */ @@ -54,6 +74,7 @@ static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full, return 1; } btrfs_print_superblock(&sb, full); + putchar('\n'); return 0; } @@ -168,15 +189,12 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd, close(fd); return 1; } - - putchar('\n'); } } else { if (load_and_dump_sb(filename, fd, sb_bytenr, full, force)) { close(fd); return 1; } - putchar('\n'); } close(fd); }