From patchwork Thu Oct 13 03:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13005593 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 2A2D6C4332F for ; Thu, 13 Oct 2022 03:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbiJMDPv (ORCPT ); Wed, 12 Oct 2022 23:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiJMDPu (ORCPT ); Wed, 12 Oct 2022 23:15:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15FD9DF8E for ; Wed, 12 Oct 2022 20:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665630944; 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=cDBYeCioz5Ylq0nOSbrPei7nc8mXM61MkA1D1bEYWL4dMwI0/KLYPYELiYYtgE4P2qXWKU +/191ha5FRrJ9ZfHRdWUybwEbfwGj2fgr9uOlfoSUz3ItpeKOyo0fMwLutu65I6eAmkxWO I91pXd4RB56qkK4WUl/Fv0zKRo8lVNE= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-349-2RqiQep3N4eGOb0cnsK2-w-1; Wed, 12 Oct 2022 23:15:43 -0400 X-MC-Unique: 2RqiQep3N4eGOb0cnsK2-w-1 Received: by mail-pf1-f198.google.com with SMTP id cu10-20020a056a00448a00b00562f2ff1058so456199pfb.23 for ; Wed, 12 Oct 2022 20:15:43 -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=vrEb++phpDEMrolzqS4aY3a+TYx7A0ihW+7E8iXpyHHV2dNFe5ceAtI3dfFGux6V5B BFKj9s358a1fjAL6WElie5QY0TxDoyxQiUmVmDXK8NoHaRApTj2tB3F9Re2QUE6OxaXZ KV2Y/8oi3VxQDwFDbjUAUXnn86UERGAOvGySPHLb9HoanHyX4HhsoXerNJo8i1xe0dHn FHWjjjzcCkT4gPJ6aTEqmo+D//hdGpgAe3eis7E/PFbsxEI/Pj8Fn8xjHgLxi0SR8DPh m+VEcv/QNs/i57hTM98RXdKCCqpNN52oPeGM+zSUul/XwlvvngNMTH/gaI2+XU6wzdnG tGmQ== X-Gm-Message-State: ACrzQf0KxP7Jukv4Ctco2roc7bWkBP+Nr/RdqKlVoMaUjPrUNJSAzfCI QhiNJ1gcDHOiewJaM3fIMzxs6pSl/P/QhcqbxlLFaUKPvpeiOJMkywTrR9uZVi3wkpUYJ+PaM3O vbTf4rHl7d2CtncQVBS1vjR34Bw2NgRVYVU3YpsjU/uC8l5NNOFrHlOtLe7qSx5CElhwRCyMI X-Received: by 2002:a17:90b:350d:b0:20d:5438:f59a with SMTP id ls13-20020a17090b350d00b0020d5438f59amr8461423pjb.41.1665630942037; Wed, 12 Oct 2022 20:15:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hO4hRAlN/Ux0T8yrOU6+80QeULqWjLpOGI8M3NS1Ap5gqfN5qcf67iIoCgEG9MwtHZubUig== X-Received: by 2002:a17:90b:350d:b0:20d:5438:f59a with SMTP id ls13-20020a17090b350d00b0020d5438f59amr8461401pjb.41.1665630941679; Wed, 12 Oct 2022 20:15:41 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id b7-20020a170902650700b00176b84eb29asm11273085plk.301.2022.10.12.20.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:15:41 -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: Thu, 13 Oct 2022 14:15:15 +1100 Message-Id: <20221013031518.1815861-2-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221013031518.1815861-1-ddouwsma@redhat.com> References: <20221013031518.1815861-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 Thu Oct 13 03:15:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13005595 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 2ED9AC4332F for ; Thu, 13 Oct 2022 03:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbiJMDPx (ORCPT ); Wed, 12 Oct 2022 23:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiJMDPu (ORCPT ); Wed, 12 Oct 2022 23:15:50 -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 EF2B3D03BB for ; Wed, 12 Oct 2022 20:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665630946; 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=UUn9mTE/CtTxZ1M+0xe9Y+UJkklaVOEWr1FvYYh+nxE=; b=DCKT3MB+sRPys3jWupDGHsEZp3QgfBY2bVpFCTZg9sH7jtURxUJ+pGscianDq9u3odmsCV GHmt0IYxFrTAywZcViNCrZxAB472JmJF7pzkglRp4mlcVRv93JK+ucbWyPojJPyBRFe0ak 84DAQNZyrGeFQGMgdtH41yIIgJo8feo= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-42-1QY3H4aNMRilGcRIWwtUag-1; Wed, 12 Oct 2022 23:15:45 -0400 X-MC-Unique: 1QY3H4aNMRilGcRIWwtUag-1 Received: by mail-pl1-f199.google.com with SMTP id d18-20020a170903231200b0018031042fb6so485059plh.19 for ; Wed, 12 Oct 2022 20:15:45 -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=UUn9mTE/CtTxZ1M+0xe9Y+UJkklaVOEWr1FvYYh+nxE=; b=nwCoiI/douHBBjqRrQIvMmyelA8QE3/+x63hF6kjs0Z6vEXjC91xL7x6mLWGys/zkC 3zV0GpmIXzGMQSMlueMyUo8ZzCgYcidnDgNF9Cz5yQm88TxwfShVWnRyBLZu4WXLPHBc ENwRgmXoHZdZHOa5/a/uaxkZj+7qwFGsLokYwi0T0oIJdQbMy6ENZzj7nu5ng2/M18aP p7WJkjiUL/SgzNsGN3CowKbymbDtq3g8BlkchxiiTEVaCZw6s56xJzDLRYp/lxdyBkA/ +8m3pGthI1zDIcQCtGbKSRtmsYY+9UzCp1nj756YqXXjKGiKm2N0mzEBzEzMJFAY2bQV UOfQ== X-Gm-Message-State: ACrzQf09uWuhGo++/ktn6JpgkwgPJ7y4adsED5Kyv2d5Q0pR8ddio7LE 2inbV+Civ7zx7lM//lNgrm9d9C93dTlPiHKMD4Ovcg8tgxj57Pysb8W6dxdGzkVXxETH6swnmNZ QbberfRHBKkH6RnXctsREG3XFps6aZrYWgkyOKZ5qbVyu/cDrnsnIk2t5X3yv6MdHVyg0ExOL X-Received: by 2002:a17:90a:ad82:b0:20c:feb2:bceb with SMTP id s2-20020a17090aad8200b0020cfeb2bcebmr8544927pjq.93.1665630944206; Wed, 12 Oct 2022 20:15:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78uFKwlRyt3mjZGkwKdrXlyqB/sIwo0F+QNSHpQ6HUGvGWkFzWCSP6GwLS/5pIfPBEQSoKdQ== X-Received: by 2002:a17:90a:ad82:b0:20c:feb2:bceb with SMTP id s2-20020a17090aad8200b0020cfeb2bcebmr8544901pjq.93.1665630943801; Wed, 12 Oct 2022 20:15:43 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id b7-20020a170902650700b00176b84eb29asm11273085plk.301.2022.10.12.20.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:15:43 -0700 (PDT) From: Donald Douwsma To: linux-xfs@vger.kernel.org Cc: Donald Douwsma Subject: [PATCH 2/4] xfsrestore: fix on-media inventory stream unpacking Date: Thu, 13 Oct 2022 14:15:16 +1100 Message-Id: <20221013031518.1815861-3-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221013031518.1815861-1-ddouwsma@redhat.com> References: <20221013031518.1815861-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 Thu Oct 13 03:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13005596 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 C8617C43219 for ; Thu, 13 Oct 2022 03:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbiJMDPy (ORCPT ); Wed, 12 Oct 2022 23:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiJMDPw (ORCPT ); Wed, 12 Oct 2022 23:15:52 -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 D9297D0CFB for ; Wed, 12 Oct 2022 20:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665630949; 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=NKbZRrXx0PfDM02qQ/CpNcNDatA7RHunHC1Au6KU6fM=; b=Vdg1EerlfLRFTHP7oWgHugqm3fQT+Kzf2GfV73GJ6BFdRR5Ze283ZDZY2xM6dZONB1mMD1 j12UHnUE8bH66EdP0AMsPSbgr5KbSVRQcZtfAKu7o5T4t5Ke6yFqDGZML5jZVHQ+HWFZgG Rw9st87bUpXbf7+rcExXI4Kt0/fx+jI= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-644-KLtmQII4MKqm8GfkDl41zg-1; Wed, 12 Oct 2022 23:15:48 -0400 X-MC-Unique: KLtmQII4MKqm8GfkDl41zg-1 Received: by mail-pj1-f69.google.com with SMTP id pq17-20020a17090b3d9100b0020a4c65c3a9so422294pjb.0 for ; Wed, 12 Oct 2022 20:15:47 -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=NKbZRrXx0PfDM02qQ/CpNcNDatA7RHunHC1Au6KU6fM=; b=AbA/EcTSTLrCZLqPrjRv4VOv15ZGujf/YIsA3PzjYpHMNDzh7uInMMJazmTT4S7C0c 5q8PngC1PrW8E8vfILvTNpJGfCjNYk0JpjoOa/uIzHlPr00IoNrS6vbnwixtmamnwjAS twKN8dZdwv4hWuOyDVt4V7JCaj7afl0XVwMng7IpUab1/83bba2AtAzR9bVe+8GZlxdh OiHGQrup4Y52vAA52jvlQX4pX3lOcPGbgILa/BNd0R0OzAsB8/zkhkKYIZcAhRPDlQYw uzUwdfJgTAcg470TV1R+Ix1tMSbCi/f7b1dli+rg+6b8Kv52EwQkWcTkXB2sro+2A0MU EpnA== X-Gm-Message-State: ACrzQf2R0zgihJtKt6RxZs+/0gEhA6GfOrUMHAzEc7Fi6WVYSsfOxpU4 EXMxx0t/SiQ8Yu5olLA3yRuNJsT71Wm7v02VKu8U3GNyrtr4svQHrWbCh2F9O8DHd83gqxM/pis QCi9db8aNEeOWLyxgjXVloCz04n0IuwbRujmESh3B7K1hvuk0zBFjRmiSuil0/aZ3NNz9gz8Q X-Received: by 2002:a17:902:8c92:b0:178:29d4:600f with SMTP id t18-20020a1709028c9200b0017829d4600fmr33408492plo.40.1665630946639; Wed, 12 Oct 2022 20:15:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SnMuL8TOBbzX8fV8T7ww/knCmv+DNOXD5EjJVvUKwmpfES6sDfwdkEwxEv9buyLQ/sAUqqA== X-Received: by 2002:a17:902:8c92:b0:178:29d4:600f with SMTP id t18-20020a1709028c9200b0017829d4600fmr33408459plo.40.1665630946255; Wed, 12 Oct 2022 20:15:46 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id b7-20020a170902650700b00176b84eb29asm11273085plk.301.2022.10.12.20.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:15:45 -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: Thu, 13 Oct 2022 14:15:17 +1100 Message-Id: <20221013031518.1815861-4-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221013031518.1815861-1-ddouwsma@redhat.com> References: <20221013031518.1815861-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 "Test2" -f /dev/nst0 -M "tape1" -f /dev/nst1 -M "tape2" /boot ... [root@rhel8 xfsdump-dev]# rm -rf /var/lib/xfsdump/inventory /tmp/test1/* [root@rhel8 xfsdump-dev]# restore/xfsrestore -L Test2 -f /dev/nst0 -f /dev/nst1 /tmp/test2 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: Wed Oct 12 15:36:55 2022 session label: "Test2" session id: 50be3b17-d9f9-414d-885b-ababf660e189 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: 2 mfile type: data mfile size: 165675008 mfile start: ino 133 offset 0 mfile end: ino 28839 offset 0 media label: "test" media id: e2e6978d-5546-4f1f-8c9e-307168071889 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: 1ad6d919-7159-42fb-a20f-5a2c4e3e24b1 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 Thu Oct 13 03:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Douwsma X-Patchwork-Id: 13005597 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 3E5BBC43217 for ; Thu, 13 Oct 2022 03:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiJMDP4 (ORCPT ); Wed, 12 Oct 2022 23:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiJMDPy (ORCPT ); Wed, 12 Oct 2022 23:15:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC86D2CF0 for ; Wed, 12 Oct 2022 20:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665630951; 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=PsRQGAMdQBC9M7jU3l93FRHi7jvy3f0g+PgBahTjfDfd48YjbZPFwCEoIZbyVfzzumfm7G EgfFtl9gCmHDCS6nlsB194HdVyWq3DkpZkM9pwlaUEuUIriREVnnNPL7084oAK+pwSvfnU UdSFHdGaunmBV6MM5HD7xzev109or/4= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-127-U7NVBiy-NVS9Zgn_xYMvAA-1; Wed, 12 Oct 2022 23:15:50 -0400 X-MC-Unique: U7NVBiy-NVS9Zgn_xYMvAA-1 Received: by mail-pj1-f69.google.com with SMTP id mq15-20020a17090b380f00b0020ad26fa5edso2498702pjb.7 for ; Wed, 12 Oct 2022 20:15:50 -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=upXsS8dPE40wa0GH+KriCRw/Ex+HEhN12tF1+yxr0Fb32C/wnw0ulwXRz5tmqHMnh5 0OlQ5bE000rivMXVSGhelzbJRQPoPSZJp1N7TR1bZQyFuo3XNU9vZh/deqYQ8jouDKOS 5LCWxe6o7CT4yY3gNpoFY81f5A5oQoJ5qKvXqnSyc1QF+Q7S6pEl8TnEKN7uoaOUBmYn PMktIush6q8rXlSuorZQ3V/mGeA0kYSwGg5Z2opB7tqrYzpbdgZKijkCj6wVjIdgFMkY raPiQzH9hOBCZEOuQv/6xCNKnk/D9j715Ct7Hlr8rghR7ZdpYp09Ea9ZAxBw61Oy9V/b Zy+A== X-Gm-Message-State: ACrzQf1jTGjanBmhPiWy46J1E1qrvn7+jTJAbqFrXqFlbSi15FGaaB7m eHj/S1ZvGlkVktWLFHC+whxwtmhl9x9Picr/lXvrMIAp3Wk+sFd2oRswexmAXu/8H4g2cyIq4D7 mUi56s7jM2XF4NI6CfclFT67aqWsQGze4RCSwuynMdij/SKBRmwvmkfmyfsddDjopmOxi9aTE X-Received: by 2002:a17:90a:1b65:b0:1f7:4725:aa6e with SMTP id q92-20020a17090a1b6500b001f74725aa6emr8466523pjq.179.1665630949099; Wed, 12 Oct 2022 20:15:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4cSgParvKTnjfX2j2MSF/yq3Qsu09qXVanrZribhb3aJUMV1kJM8fuigvYjSEwFIfiYO5vBw== X-Received: by 2002:a17:90a:1b65:b0:1f7:4725:aa6e with SMTP id q92-20020a17090a1b6500b001f74725aa6emr8466497pjq.179.1665630948703; Wed, 12 Oct 2022 20:15:48 -0700 (PDT) Received: from snowcrash.redhat.com ([2001:8003:4800:1b00:4c4a:1757:c744:923]) by smtp.gmail.com with ESMTPSA id b7-20020a170902650700b00176b84eb29asm11273085plk.301.2022.10.12.20.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:15:48 -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: Thu, 13 Oct 2022 14:15:18 +1100 Message-Id: <20221013031518.1815861-5-ddouwsma@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221013031518.1815861-1-ddouwsma@redhat.com> References: <20221013031518.1815861-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 "