From patchwork Fri Oct 14 07:58:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13006742 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 40F92C433FE for ; Fri, 14 Oct 2022 07:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbiJNH7G (ORCPT ); Fri, 14 Oct 2022 03:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiJNH7F (ORCPT ); Fri, 14 Oct 2022 03:59:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0DCB317C0 for ; Fri, 14 Oct 2022 00:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665734341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wmuhRiMUfeqXX9acLWNCY0G1BBH8QsHMianSlQ0tkmY=; b=N2qYSVRW4uTQT7VOZWs5PWOoZmfmzJ8Pz8IRrrB11p//slVDwq4cRCN5mmrT9/HKTLeUR9 EtURGgmo/Dd6W65YG2LWBzidHyR8hKGVMbFg/JQ6AMX4gjTm8FAUq0mrFEyf5lmVKFUFK1 LXduuFYWzyw05ot6th2aywq27vbpNGo= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-588-tKe_ro9EMfSSh5b8tPfm1Q-1; Fri, 14 Oct 2022 03:58:59 -0400 X-MC-Unique: tKe_ro9EMfSSh5b8tPfm1Q-1 Received: by mail-pl1-f198.google.com with SMTP id f18-20020a170902ce9200b0017f9ac4cfb5so2853884plg.22 for ; Fri, 14 Oct 2022 00:58:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmuhRiMUfeqXX9acLWNCY0G1BBH8QsHMianSlQ0tkmY=; b=rCMxrUX8JD8OAwuwrJvyIuUxrzIvWDPuEcwN9lcCtzFkAPZDetk8Yn/kwvZV3uNrab l87iLR3KFiNn/x89o261qEmQzP15me0PtQYuBySNDOcDsprrf89df+6MyWyXvtP4HKQK iHeqspE6b7G0OC/rtpRkiUoLAr00Nao/4UabPWzwK+AYq2JQInqwjHO6I57ky5Gj6Fw3 NCFSkgKzo6cPIAkoBOUQIE6jSJoK0ZACg6A8H1AVIZcq7FA2ZpkZ8XftxC5H4HDCTBpX KBUYqoVxAifbC5GBle/DPsaeuiOEmJ/fTM+DbySskKXQuGcAng2AYSUqBsYmoUx9v8Qh +1ew== X-Gm-Message-State: ACrzQf0FWuxYbeZIhEOVwnh69y0Q+C3KrDdZ6oOkzLWP4dEJNVcX1Kxe J6kNfjsNVG82y1a8AA3Xtud3NQwXNotF58tsjP9cq4/MMevoqBGUCAphI6WRIXyVvoA5pmfddFM 8OmEMPjRBvOrNDEcAclmm9rd502H4mOKtY7n0JnGw5VZ09tBVn8tuKTFyG4+WtH4WUfX08FKd X-Received: by 2002:a05:6a00:18a9:b0:563:95bd:269e with SMTP id x41-20020a056a0018a900b0056395bd269emr4061029pfh.49.1665734338405; Fri, 14 Oct 2022 00:58:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fo1yyingVyQ/LOZmlP4tS4u1i4XOhqgqcUXMjY4btt7FX/sRHBuqQRe42v61JSxh5DBjpCw== X-Received: by 2002:a05:6a00:18a9:b0:563:95bd:269e with SMTP id x41-20020a056a0018a900b0056395bd269emr4061008pfh.49.1665734338009; Fri, 14 Oct 2022 00:58:58 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id nn13-20020a17090b38cd00b0020b21019086sm8550382pjb.3.2022.10.14.00.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 00:58:57 -0700 (PDT) From: Donald Douwsma To: linux-xfs@vger.kernel.org Cc: Donald Douwsma , "Darrick J . Wong" Subject: [PATCH 1/4] xfsrestore: fix on-media inventory media unpacking Date: Fri, 14 Oct 2022 18:58:44 +1100 Message-Id: <20221014075847.2047427-2-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014075847.2047427-1-ddouwsma@redhat.com> References: <20221014075847.2047427-1-ddouwsma@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org When xfsrestore reads the inventory from tape media it fails to convert media file records from bigendian. If the xfsdump inventory is not available xfsrestore will write this invalid record to the on-line inventory. [root@rhel8 ~]# xfsdump -L Test1 -M "" -f /dev/st0 /boot > /dev/null [root@rhel8 ~]# xfsdump -L Test2 -M "" -f /dev/st0 /boot > /dev/null [root@rhel8 ~]# rm -rf /var/lib/xfsdump/inventory/ [root@rhel8 ~]# mt -f /dev/nst0 asf 2 [root@rhel8 ~]# xfsrestore -f /dev/nst0 -L Test2 /tmp/test2 xfsrestore: using scsi tape (drive_scsitape) strategy xfsrestore: version 3.1.8 (dump format 3.0) - type ^C for status and control xfsrestore: searching media for dump xfsrestore: preparing drive xfsrestore: examining media file 3 xfsrestore: found dump matching specified label: xfsrestore: hostname: rhel8 xfsrestore: mount point: /boot xfsrestore: volume: /dev/sda1 xfsrestore: session time: Tue Sep 27 16:05:28 2022 xfsrestore: level: 0 xfsrestore: session label: "Test2" xfsrestore: media label: "" xfsrestore: file system id: 26dd5aa0-b901-4cf5-9b68-0c5753cb3ab8 xfsrestore: session id: 62402423-7ae0-49ed-8ecb-9e5bc7642b91 xfsrestore: media id: 47ba45ca-3417-4006-ab10-3dc6419b83e2 xfsrestore: incorporating on-media session inventory into online inventory xfsrestore: /var/lib/xfsdump/inventory created xfsrestore: using on-media session inventory xfsrestore: searching media for directory dump xfsrestore: rewinding xfsrestore: examining media file 0 xfsrestore: inventory session uuid (62402423-7ae0-49ed-8ecb-9e5bc7642b91) does not match the media header's session uuid (1771d9e8-a1ba-4e87-a61e-f6be97e41b45) xfsrestore: examining media file 1 xfsrestore: inventory session uuid (62402423-7ae0-49ed-8ecb-9e5bc7642b91) does not match the media header's session uuid (1771d9e8-a1ba-4e87-a61e-f6be97e41b45) xfsrestore: examining media file 2 xfsrestore: reading directories xfsrestore: 9 directories and 320 entries processed xfsrestore: directory post-processing xfsrestore: restore complete: 0 seconds elapsed xfsrestore: Restore Summary: xfsrestore: stream 0 /dev/nst0 OK (success) xfsrestore: Restore Status: SUCCESS [root@rhel8 ~]# xfsdump -I file system 0: fs id: 26dd5aa0-b901-4cf5-9b68-0c5753cb3ab8 session 0: mount point: rhel8:/boot device: rhel8:/dev/sda1 time: Tue Sep 27 16:05:28 2022 session label: "Test2" session id: 62402423-7ae0-49ed-8ecb-9e5bc7642b91 level: 0 resumed: NO subtree: NO streams: 1 stream 0: pathname: /dev/st0 start: ino 133 offset 0 end: ino 1572997 offset 0 interrupted: YES media files: 1 media file 0: mfile index: 33554432 mfile type: data mfile size: 211187836911616 mfile start: ino 9583660007044415488 offset 0 mfile end: ino 9583686395323482112 offset 0 media label: "" media id: 47ba45ca-3417-4006-ab10-3dc6419b83e2 xfsdump: Dump Status: SUCCESS [root@rhel8 ~]# [root@rhel8 ~]# ls /tmp/test2 efi grub2 loader The invalid start and end inode information cause xfsrestore to consider that non-directory files do not reside in the current media and will fail to restore them. The behaviour of an initial restore may succeed if the position of the tape is such that the data file is encountered before the inventory file, or if there is only one dump session on tape, xfsrestore is somewhat inconsistent in this regard. Subsequent restores will use the invalid on-line inventory and fail to restore files. Fix this by correctly unpacking the inventory data. Signed-off-by: Donald Douwsma Reviewed-by: Darrick J. Wong --- inventory/inv_stobj.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/inventory/inv_stobj.c b/inventory/inv_stobj.c index c20e71c..b461666 100644 --- a/inventory/inv_stobj.c +++ b/inventory/inv_stobj.c @@ -1008,7 +1008,7 @@ stobj_unpack_sessinfo( size_t bufsz, invt_sessinfo_t *s) { - uint i; + uint i, j; char *tmpbuf; char *p = (char *)bufp; @@ -1087,26 +1087,13 @@ stobj_unpack_sessinfo( /* all the media files */ s->mfiles = (invt_mediafile_t *)p; - -#ifdef INVT_DELETION - { - int tmpfd = open("moids", O_RDWR | O_CREAT, S_IRUSR|S_IWUSR); - uint j; - invt_mediafile_t *mmf = s->mfiles; - for (i=0; i< s->ses->s_cur_nstreams; i++) { - for (j=0; j< s->strms[i].st_nmediafiles; - j++, mmf++) - xlate_invt_mediafile((invt_mediafile_t *)mmf, (invt_mediafile_t *)tmpbuf, 1); - bcopy(tmpbuf, mmf, sizeof(invt_mediafile_t)); - put_invtrecord(tmpfd, &mmf->mf_moid, - sizeof(uuid_t), 0, SEEK_END, 0); - } - close(tmpfd); - } -#endif for (i = 0; i < s->ses->s_cur_nstreams; i++) { - p += (size_t) (s->strms[i].st_nmediafiles) - * sizeof(invt_mediafile_t); + for(j = 0; j < s->strms[i].st_nmediafiles; j++) { + xlate_invt_mediafile((invt_mediafile_t *)p, + (invt_mediafile_t *)tmpbuf, 1); + bcopy(tmpbuf, p, sizeof(invt_mediafile_t)); + p += sizeof(invt_mediafile_t); + } } /* sanity check the size of the buffer given to us vs. the size it From patchwork Fri Oct 14 07:58:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13006743 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 3714EC4332F for ; Fri, 14 Oct 2022 07:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbiJNH7H (ORCPT ); Fri, 14 Oct 2022 03:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiJNH7G (ORCPT ); Fri, 14 Oct 2022 03:59:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7A7317CE for ; Fri, 14 Oct 2022 00:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665734343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nwOMt3ttbO8Px4J5UR+PbpFZx/ZDEh5Tw+F9P0+vS5w=; b=eqtda1Fw34JD7N1/33viINvp1qtwx9iA/KO2La+bHbM1NhVUk6edzokg5tHUGMX3BsU4WK v06TKje0h44+sqLpVDw956pDRov+4d/vr+GfYCF5KO+4i/DDrQJLYbnNr3wQmxFFFTsT4C QR4QXNViNxNtPOy1PabNCtpufv8tXwE= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-436-FeobtQFmOUmUsLVqOKtTVg-1; Fri, 14 Oct 2022 03:59:02 -0400 X-MC-Unique: FeobtQFmOUmUsLVqOKtTVg-1 Received: by mail-pl1-f197.google.com with SMTP id o1-20020a170902d4c100b00177f59a9889so2855913plg.13 for ; Fri, 14 Oct 2022 00:59:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nwOMt3ttbO8Px4J5UR+PbpFZx/ZDEh5Tw+F9P0+vS5w=; b=Q1Ze1N3LrxykmFrieFlKLx2qAanJZ0nUduI+BJ2aen1wbx/PwrWWOTyAnt7PS71ZPw FDLEOoNIAUS6HY0nvRnn/6dlCuwkhOejRYJJ+vVY97KmNSKlxxRcpvGXf2hNvH4xSLJD x3kI9ICeWo5gCdceU9wqeHuvLO4F3IiiEen/Igl06o7/mCsiumtZL5cnk3W5uI3DcemS EhQdZlcPBVp9qljEpV6yRqSwUtCN2GbEVCPElEc1itXE1a38VPtvmcsMHmKhg2cce3A9 n8Fg373wW9zFseyfg7aTGFN4XgjdIc1B77IbvPCZzch0XvgK+XwqSrlPSkz1GnwkDWx6 ZQTw== X-Gm-Message-State: ACrzQf0exmHWTrIAdUbUQxX4pvNZey0z6agLGkKjE7wZxAzaJyhkZriz cPnFep5KNZi4y6h2liv08enFWuSiWD9whvLa6s90VQRQyMxfP/4LmFvg8ai61oMmkcraZYu7oYV yQeKK2Qt5Z9H8P7WCZUdM8m7O8oaohdaTzxZR1YnQoTUpwqiTt/jCNAnxyeziCbP4/BFVis+N X-Received: by 2002:a17:90a:1c1:b0:20a:e745:bc30 with SMTP id 1-20020a17090a01c100b0020ae745bc30mr16405750pjd.131.1665734340734; Fri, 14 Oct 2022 00:59:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5oIK/Rp2X/JjP0PAJRXvXLADAV8USV+5IvmivYJC8O/LIdHzfEexeM97R5Eu5832XgkPGSgg== X-Received: by 2002:a17:90a:1c1:b0:20a:e745:bc30 with SMTP id 1-20020a17090a01c100b0020ae745bc30mr16405721pjd.131.1665734340307; Fri, 14 Oct 2022 00:59:00 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id nn13-20020a17090b38cd00b0020b21019086sm8550382pjb.3.2022.10.14.00.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 00:58:59 -0700 (PDT) From: Donald Douwsma To: linux-xfs@vger.kernel.org Cc: Donald Douwsma , "Darrick J . Wong" Subject: [PATCH 2/4] xfsrestore: fix on-media inventory stream unpacking Date: Fri, 14 Oct 2022 18:58:45 +1100 Message-Id: <20221014075847.2047427-3-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014075847.2047427-1-ddouwsma@redhat.com> References: <20221014075847.2047427-1-ddouwsma@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org xfsdump can create multiple streams, when restoring the online inventory with multiple streams we fail to process these and assert when the inventory buffer is not fully decoded. [root@rhel8 ~]# xfsdump -L "Test1" -f /dev/nst0 -M tape1 -f /dev/nst1 -M tape2 /boot xfsdump: using scsi tape (drive_scsitape) strategy xfsdump: using scsi tape (drive_scsitape) strategy xfsdump: version 3.1.8 (dump format 3.0) - type ^C for status and control xfsdump: level 0 dump of rhel8:/boot xfsdump: dump date: Thu Oct 6 13:50:45 2022 xfsdump: session id: aa25fa48-4493-45c7-9027-61e53e486445 xfsdump: session label: "Test1" xfsdump: ino map phase 1: constructing initial dump list xfsdump: ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: identifying stream starting points xfsdump: stream 0: ino 133 offset 0 to ino 28839 offset 0 xfsdump: stream 1: ino 28839 offset 0 to end xfsdump: ino map construction complete xfsdump: estimated dump size: 328720704 bytes xfsdump: estimated dump size per stream: 164375728 bytes xfsdump: /var/lib/xfsdump/inventory created xfsdump: drive 0: preparing drive xfsdump: drive 1: preparing drive xfsdump: drive 1: creating dump session media file 0 (media 0, file 0) xfsdump: drive 1: dumping ino map xfsdump: drive 1: dumping non-directory files xfsdump: drive 0: creating dump session media file 0 (media 0, file 0) xfsdump: drive 0: dumping ino map xfsdump: drive 0: dumping directories xfsdump: drive 0: dumping non-directory files xfsdump: drive 1: ending media file xfsdump: drive 1: media file size 166723584 bytes xfsdump: drive 1: waiting for synchronized session inventory dump xfsdump: drive 0: ending media file xfsdump: drive 0: media file size 165675008 bytes xfsdump: drive 0: waiting for synchronized session inventory dump xfsdump: drive 0: dumping session inventory xfsdump: drive 0: beginning inventory media file xfsdump: drive 0: media file 1 (media 0, file 1) xfsdump: drive 0: ending inventory media file xfsdump: drive 0: inventory media file size 2097152 bytes xfsdump: drive 0: writing stream terminator xfsdump: drive 0: beginning media stream terminator xfsdump: drive 0: media file 2 (media 0, file 2) xfsdump: drive 0: ending media stream terminator xfsdump: drive 0: media stream terminator size 1048576 bytes xfsdump: drive 1: dumping session inventory xfsdump: drive 1: beginning inventory media file xfsdump: drive 1: media file 1 (media 0, file 1) xfsdump: drive 1: ending inventory media file xfsdump: drive 1: inventory media file size 2097152 bytes xfsdump: drive 1: writing stream terminator xfsdump: drive 1: beginning media stream terminator xfsdump: drive 1: media file 2 (media 0, file 2) xfsdump: drive 1: ending media stream terminator xfsdump: drive 1: media stream terminator size 1048576 bytes xfsdump: dump size (non-dir files) : 328189016 bytes xfsdump: dump complete: 4 seconds elapsed xfsdump: Dump Summary: xfsdump: stream 0 /dev/nst0 OK (success) xfsdump: stream 1 /dev/nst1 OK (success) xfsdump: Dump Status: SUCCESS [root@rhel8 ~]# xfsdump -I file system 0: fs id: 26dd5aa0-b901-4cf5-9b68-0c5753cb3ab8 session 0: mount point: rhel8:/boot device: rhel8:/dev/sda1 time: Thu Oct 6 13:50:45 2022 session label: "Test1" session id: aa25fa48-4493-45c7-9027-61e53e486445 level: 0 resumed: NO subtree: NO streams: 2 stream 0: pathname: /dev/nst0 start: ino 133 offset 0 end: ino 28839 offset 0 interrupted: NO media files: 2 media file 0: mfile index: 0 mfile type: data mfile size: 165675008 mfile start: ino 133 offset 0 mfile end: ino 28839 offset 0 media label: "tape1" media id: adb31f2a-f026-4597-a20a-326f28ecbaf1 media file 1: mfile index: 1 mfile type: inventory mfile size: 2097152 media label: "tape1" media id: adb31f2a-f026-4597-a20a-326f28ecbaf1 stream 1: pathname: /dev/nst1 start: ino 28839 offset 0 end: ino 1572997 offset 0 interrupted: NO media files: 2 media file 0: mfile index: 0 mfile type: data mfile size: 166723584 mfile start: ino 28839 offset 0 mfile end: ino 1572997 offset 0 media label: "tape2" media id: 22224f02-b6c7-47d5-ad61-a61ba071c8a8 media file 1: mfile index: 1 mfile type: inventory mfile size: 2097152 media label: "tape2" media id: 22224f02-b6c7-47d5-ad61-a61ba071c8a8 xfsdump: Dump Status: SUCCESS [root@rhel8 ~]# mv /var/lib/xfsdump/inventory /var/lib/xfsdump/inventory_two_sessions [root@rhel8 ~]# xfsdump -I xfsdump: Dump Status: SUCCESS [root@rhel8 ~]# xfsrestore -L Test1 -f /dev/nst0 /tmp/test1/ xfsrestore: using scsi tape (drive_scsitape) strategy xfsrestore: version 3.1.8 (dump format 3.0) - type ^C for status and control xfsrestore: searching media for dump xfsrestore: preparing drive xfsrestore: examining media file 2 xfsrestore: found dump matching specified label: xfsrestore: hostname: rhel8 xfsrestore: mount point: /boot xfsrestore: volume: /dev/sda1 xfsrestore: session time: Thu Oct 6 13:50:45 2022 xfsrestore: level: 0 xfsrestore: session label: "Test1" xfsrestore: media label: "tape1" xfsrestore: file system id: 26dd5aa0-b901-4cf5-9b68-0c5753cb3ab8 xfsrestore: session id: aa25fa48-4493-45c7-9027-61e53e486445 xfsrestore: media id: adb31f2a-f026-4597-a20a-326f28ecbaf1 xfsrestore: searching media for directory dump xfsrestore: rewinding xfsrestore: examining media file 0 xfsrestore: reading directories xfsrestore: 9 directories and 320 entries processed xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: examining media file 1 xfsrestore: inv_stobj.c:1119: stobj_unpack_sessinfo: Assertion `(size_t) ( p - (char *) bufp ) == bufsz' failed. Aborted (core dumped) Make sure we unpack multiple streams when restoring the online inventory from media. Signed-off-by: Donald Douwsma Reviewed-by: Darrick J. Wong --- inventory/inv_stobj.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inventory/inv_stobj.c b/inventory/inv_stobj.c index b461666..025d431 100644 --- a/inventory/inv_stobj.c +++ b/inventory/inv_stobj.c @@ -1065,25 +1065,26 @@ stobj_unpack_sessinfo( return BOOL_FALSE; } + /* get the seshdr and then, the remainder of the session */ xlate_invt_seshdr((invt_seshdr_t *)p, (invt_seshdr_t *)tmpbuf, 1); bcopy(tmpbuf, p, sizeof(invt_seshdr_t)); - - /* get the seshdr and then, the remainder of the session */ s->seshdr = (invt_seshdr_t *)p; s->seshdr->sh_sess_off = -1; p += sizeof(invt_seshdr_t); - xlate_invt_session((invt_session_t *)p, (invt_session_t *)tmpbuf, 1); bcopy (tmpbuf, p, sizeof(invt_session_t)); s->ses = (invt_session_t *)p; p += sizeof(invt_session_t); /* the array of all the streams belonging to this session */ - xlate_invt_stream((invt_stream_t *)p, (invt_stream_t *)tmpbuf, 1); - bcopy(tmpbuf, p, sizeof(invt_stream_t)); s->strms = (invt_stream_t *)p; - p += s->ses->s_cur_nstreams * sizeof(invt_stream_t); + for (i = 0; i < s->ses->s_cur_nstreams; i++) { + xlate_invt_stream((invt_stream_t *)p, + (invt_stream_t *)tmpbuf, 1); + bcopy(tmpbuf, p, sizeof(invt_stream_t)); + p += sizeof(invt_stream_t); + } /* all the media files */ s->mfiles = (invt_mediafile_t *)p; From patchwork Fri Oct 14 07:58:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13006746 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 AD294C43219 for ; Fri, 14 Oct 2022 07:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiJNH7M (ORCPT ); Fri, 14 Oct 2022 03:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiJNH7K (ORCPT ); Fri, 14 Oct 2022 03:59:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C85317C0 for ; Fri, 14 Oct 2022 00:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665734348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vV5nbGN+Fjt+fqoenGe4Sq/4qYnTyDa9tFvq3HrYH8w=; b=LcQ3J2Iz1k7kdOg5sh2UXDBENXapGGjd1sS3J8LmLW89SkUshaGAjljqvdnlAIw7N+9KRh 6IGyOdzekx/2Q3isYf26/VIjf8hbxbFt+wENPA7wyfSaolhQF0cqQqW31C0qDH7zf2O9cs F4r43Tega3LnNIZ0oHjTlD93oz5Sse4= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-608-wuPO3_LmNbGaI2KErxEFXQ-1; Fri, 14 Oct 2022 03:59:04 -0400 X-MC-Unique: wuPO3_LmNbGaI2KErxEFXQ-1 Received: by mail-pg1-f200.google.com with SMTP id p18-20020a63e652000000b0046b27534651so841533pgj.17 for ; Fri, 14 Oct 2022 00:59:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vV5nbGN+Fjt+fqoenGe4Sq/4qYnTyDa9tFvq3HrYH8w=; b=dHo/DktQ4N+B3Q5ahYVEW7kVbID2c2NeAVn6TyYXe5nCrecCF9k3TBLkW3RDSnBobr Nq702ugRkhoBguTL4etDwki/lNke2i+1b1+0UQiszui/opZlP6pFDs/w+lnuGbhYb1Vj fH4+ETL8zMVytLwBgJz6BpLUabIbD/3+aKqTc72ASACovNenz6tg14goRZecVxQtV7OS SCi8bxfByM1OQaGCtUGDdHVkVL+vmeJOr7Md+Q45EVL7dpyZs7RXxrVluWgpMI//0mRo h3LuLZeR32fOx7EjtF3d/OSGs2L4F1qqqmyw+Jco3EvN0xiTJ3ml5ki8K+1+KxKrE5wm f7qw== X-Gm-Message-State: ACrzQf3sDg8vMrjhKewokVZv/HURaSSCmSn7Zb/tK66DOW1tEdchAppt BClwg/KTsWInyEb/SzRm3EbUlqjdsEbjK+s+n1rKUf0QoN+Dhq463GT3AvFMUjY7N7Yw18o4pFm wKtDVPFXW4REpjJRx75Qk/qeOQp5xyVjbHmGDC2dO26OY9HDPa93Z9wkxR7tHOQ/VjOrKlrPt X-Received: by 2002:a63:c4e:0:b0:45f:795:c20a with SMTP id 14-20020a630c4e000000b0045f0795c20amr3537300pgm.559.1665734343155; Fri, 14 Oct 2022 00:59:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4K+hgvZ9k9EuIkusvdWqZSvhuhksiU29dnNVcHDT8/Gg/OxAsOB1C6SlQAkA/6AkR4rtJF0w== X-Received: by 2002:a63:c4e:0:b0:45f:795:c20a with SMTP id 14-20020a630c4e000000b0045f0795c20amr3537278pgm.559.1665734342806; Fri, 14 Oct 2022 00:59:02 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id nn13-20020a17090b38cd00b0020b21019086sm8550382pjb.3.2022.10.14.00.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 00:59:02 -0700 (PDT) From: Donald Douwsma To: linux-xfs@vger.kernel.org Cc: Donald Douwsma , "Darrick J . Wong" Subject: [PATCH 3/4] xfsdump: fix on-media inventory stream packing Date: Fri, 14 Oct 2022 18:58:46 +1100 Message-Id: <20221014075847.2047427-4-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014075847.2047427-1-ddouwsma@redhat.com> References: <20221014075847.2047427-1-ddouwsma@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org With the on-media inventory now being restored for multiple streams we can see that the restored streams both claim to be for /dev/nst0. [root@rhel8 xfsdump-dev]# xfsdump -L "Test" -f /dev/nst0 -M tape1 -f /dev/nst1 -M tape2 /boot ... [root@rhel8 ~]# rm -rf /var/lib/xfsdump/inventory [root@rhel8 xfsdump-dev]# restore/xfsrestore -L Test -f /dev/nst0 -f /dev/nst1 /tmp/test restore/xfsrestore: using scsi tape (drive_scsitape) strategy restore/xfsrestore: using scsi tape (drive_scsitape) strategy restore/xfsrestore: version 3.1.10 (dump format 3.0) - type ^C for status and control ... restore/xfsrestore: Restore Summary: restore/xfsrestore: stream 0 /dev/nst0 OK (success) restore/xfsrestore: stream 1 /dev/nst1 ALREADY_DONE (another stream completed the operation) restore/xfsrestore: Restore Status: SUCCESS [root@rhel8 xfsdump-dev]# xfsdump -I file system 0: fs id: 26dd5aa0-b901-4cf5-9b68-0c5753cb3ab8 session 0: mount point: rhel8:/boot device: rhel8:/dev/sda1 time: Fri Oct 14 18:31:40 2022 session label: "Test" session id: 96538a3d-2af8-4a79-8865-afec6e3e55f4 level: 0 resumed: NO subtree: NO streams: 2 stream 0: pathname: /dev/nst0 start: ino 133 offset 0 end: ino 28839 offset 0 interrupted: YES media files: 1 media file 0: mfile index: 0 mfile type: data mfile size: 165675008 mfile start: ino 133 offset 0 mfile end: ino 28839 offset 0 media label: "tape1" media id: 8a9d0ced-61f6-4332-a0c1-f1e38641c4e6 stream 1: pathname: /dev/nst0 start: ino 133 offset 0 end: ino 28839 offset 0 interrupted: YES media files: 1 media file 0: mfile index: 0 mfile type: data mfile size: 166723584 mfile start: ino 28839 offset 0 mfile end: ino 1572997 offset 0 media label: "tape2" media id: 7d569377-6bfb-4c02-b299-4dbe753bb048 xfsdump: Dump Status: SUCCESS [root@rhel8 xfsdump-dev]# Fix this by indexing the stream being packed for the on-media inventory. Signed-off-by: Donald Douwsma Suggested-by: Darrick J. Wong Reviewed-by: Darrick J. Wong --- inventory/inv_stobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inventory/inv_stobj.c b/inventory/inv_stobj.c index 025d431..fb4d93a 100644 --- a/inventory/inv_stobj.c +++ b/inventory/inv_stobj.c @@ -798,7 +798,7 @@ stobj_pack_sessinfo(int fd, invt_session_t *ses, invt_seshdr_t *hdr, sesbuf += sizeof(invt_session_t); for (i = 0; i < ses->s_cur_nstreams; i++) { - xlate_invt_stream(strms, (invt_stream_t *)sesbuf, 1); + xlate_invt_stream(&strms[i], (invt_stream_t *)sesbuf, 1); sesbuf += sizeof(invt_stream_t); } From patchwork Fri Oct 14 07:58:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13006745 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 01AB8C433FE for ; Fri, 14 Oct 2022 07:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbiJNH7L (ORCPT ); Fri, 14 Oct 2022 03:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiJNH7J (ORCPT ); Fri, 14 Oct 2022 03:59:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD54F317D7 for ; Fri, 14 Oct 2022 00:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665734347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UaKxwXZs5j3I47+jfA+D9uXp42ETQG8kiqYPq0Jybsk=; b=eZ6irP7otudFm24n5mLrMAOPEfTacTRUaYJOeVusK2WcrS2H+coiv416B0e+1PDAn6pAjp wG3Tr3QF1O1m3/HrRTKGuC7FcODKtK3cVjlP786CclX4FMJv5rfbUzeNg2r36g/HfBsRif JfCF5eDiTo3Hm53EyD3YJs/7UVqx3MA= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-158-EYxmsBSMO-KmPZcMciXSYQ-1; Fri, 14 Oct 2022 03:59:06 -0400 X-MC-Unique: EYxmsBSMO-KmPZcMciXSYQ-1 Received: by mail-pl1-f198.google.com with SMTP id u5-20020a170902e80500b00178944c46aaso2858657plg.4 for ; Fri, 14 Oct 2022 00:59:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UaKxwXZs5j3I47+jfA+D9uXp42ETQG8kiqYPq0Jybsk=; b=N8eOsyzizwpmi/KKss5JxFnN2lNpIH4USlnbmnsSTKfLMeW1eIMQ4VofimtE9vAGXh bx0i5V5s7mb4lq3CPEWFSse+8/DlUkRAo+VkJGJG+0j8NCS0naW5nOnWXzlsF8X2Eryj JcYOssL2hYBNykiEkNoMzRHoRHzl+6QDkTl/fvcoe+EfO2+T3YGRDEHcUFCJojlNiyBn omJFX61azsnBzEbIFnR2kGxsc/SJj7XhqsROYJsfTet2ZlAMg7lMAXs9JLb0d8SEoyfL lywM2TBoBcdq01WNJ9WybHkQHz8Tw702P12Fya12NtzA4gL4SR6m815mqjolkK6CglsO flAA== X-Gm-Message-State: ACrzQf0w87ls1Bx9EiggTghKIYC59H7K42BPex9YgqRv43v9YHPPzVpN z3BKDFi/hIw64psWkTq9tQG/yBPBqPI6kuNMzil2lErboeN5VO2+mtYl1pSAzPzO775e186eICw OQhFARDfq7APLL+ByE+m69fs3I/ngqc7VgKbEQ8NPpuyj6F0n9JIHZVkdlx+82rItZxGWEJAH X-Received: by 2002:a63:18f:0:b0:43c:24d2:c0f7 with SMTP id 137-20020a63018f000000b0043c24d2c0f7mr3524261pgb.470.1665734345579; Fri, 14 Oct 2022 00:59:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WCaCWo+Gec2PQpMdMRSxTH53581SGgZgbJB3PdRVB8myG2BMlPLV08XsT0taKENWho/9tmA== X-Received: by 2002:a63:18f:0:b0:43c:24d2:c0f7 with SMTP id 137-20020a63018f000000b0043c24d2c0f7mr3524243pgb.470.1665734345167; Fri, 14 Oct 2022 00:59:05 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id nn13-20020a17090b38cd00b0020b21019086sm8550382pjb.3.2022.10.14.00.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 00:59:04 -0700 (PDT) From: Donald Douwsma To: linux-xfs@vger.kernel.org Cc: Donald Douwsma , "Darrick J . Wong" Subject: [PATCH 4/4] xfsrestore: untangle inventory unpacking logic Date: Fri, 14 Oct 2022 18:58:47 +1100 Message-Id: <20221014075847.2047427-5-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014075847.2047427-1-ddouwsma@redhat.com> References: <20221014075847.2047427-1-ddouwsma@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org stobj_unpack_sessinfo returns bool_t, fix logic in pi_addfile so errors can be properly reported. Signed-off-by: Donald Douwsma Reviewed-by: Darrick J. Wong --- restore/content.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/restore/content.c b/restore/content.c index b3999f9..04b6f81 100644 --- a/restore/content.c +++ b/restore/content.c @@ -5463,17 +5463,14 @@ pi_addfile(Media_t *Mediap, * desc. */ sessp = 0; - if (!buflen) { - ok = BOOL_FALSE; - } else { - /* extract the session information from the buffer */ - if (stobj_unpack_sessinfo(bufp, buflen, &sessinfo)<0) { - ok = BOOL_FALSE; - } else { + ok = BOOL_FALSE; + /* extract the session information from the buffer */ + if (buflen && + stobj_unpack_sessinfo(bufp, buflen, &sessinfo)) { stobj_convert_sessinfo(&sessp, &sessinfo); ok = BOOL_TRUE; - } } + if (!ok || !sessp) { mlog(MLOG_DEBUG | MLOG_WARNING | MLOG_MEDIA, _( "on-media session "