Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jC5IR-00021X-Jk for mharc-grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC5IO-0001z0-TY for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jC5IL-0008D6-1Q for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:28 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:38875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jC5IK-0008Ae-Qh for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:24 -0400 Received: by mail-pl1-x644.google.com with SMTP id w3so1421785plz.5 for ; Wed, 11 Mar 2020 10:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphix.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=57ymH81gamdn9LhqFC0ICZl3/QJ+h/W2G09HAwFvAVk=; b=T+5EoxJy0lQTV1NLegJNgmxfo/DoIPRMO8NNc7xIu2og4fRrXCSoD+I0lifPl8ancz NLuW9QrYqA28x1ZqacLL6bcdyvKIfhP5PmeoV8llHbkWZmGhfjavy3AaED4a4kzXPm2r VZMO2cEZB88XhSl5WtIbIMcVbD2fJfWpo2NHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=57ymH81gamdn9LhqFC0ICZl3/QJ+h/W2G09HAwFvAVk=; b=D+ipkmoUWIXk3E44f/lcLL0qpHh0swTLwrbchNNDr/g69BT2Ro3EU55tAD9EeODvmA DEtRSRszE9tx4cuEoKlplBC2E3YExdE7/t2rX14XyHhHD6YUAsqeNJ5qYSxK/+Pj6U83 WVWB2N3pN+KRkOyZ5Gf87333DVjPIk3iNJxE2CW7rD+ej3wYixt9Qpiu2Vx1SwQNRlJq nbJhcn/WdNCS/p4irp1B4BSsDWh1CaXKzwUOMxDKH3pkZ1JHzyszafl+JZMHUwi4nURM ilLwCvyJI01Vk/wIaOQIZH/mEgNxHY0N2TVflWECPvMO5CIqj+Uog9nBvbWfxvITfJhK Wdaw== X-Gm-Message-State: ANhLgQ2Xl4vuSeGotEnw9Lx9Hqw4lqomnC3H4nyqE61jq3Iu9mnm0sbv XcsFsTYusc2Z3sWP7GQdl8hyCQMjHqGGyyxBvPDp9KhKtvDbGwbcWIdeOwHd/5EkfPz2fdzwLtM 1QkiPiSEQg2g5AOLl8GO3pQqHul2qgX4TCl5l4douDI2cjJkfJ/Hhuw== X-Google-Smtp-Source: ADFU+vstRo6OwRcJMvhinv1bG3rW9T1mxRsuzllSNun9bETnGV6xikBdsVdlTbiwmFJdbjZla2cXJA== X-Received: by 2002:a17:90a:2a06:: with SMTP id i6mr347421pjd.99.1583948242781; Wed, 11 Mar 2020 10:37:22 -0700 (PDT) Received: from localhost.localdomain (c-73-162-153-225.hsd1.ca.comcast.net. [73.162.153.225]) by smtp.gmail.com with ESMTPSA id b3sm6342060pjq.38.2020.03.11.10.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2020 10:37:22 -0700 (PDT) From: Paul Dagnelie To: grub-devel@gnu.org Cc: mahrens@delphix.com, behlendorf1@llnl.gov, george.wilson@delphix.com, sebastien.roy@delphix.com, Paul Dagnelie Subject: [PATCH 0/7] ZFS/other CoW FS save_env support Date: Wed, 11 Mar 2020 10:37:08 -0700 Message-Id: <20200311173715.22274-1-pcd@delphix.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2020 17:37:30 -0000 Hey all, I previously discussed my concept for this patch in my email https://lists.gnu.org/archive/html/grub-devel/2020-01/msg00004.html . I'm pleased to announce that I've gotten it into a working state and it is ready to review. There are a number of changes here, which I will break down below. First, the concept of "special files" is introduced into grub. These are files that are manipulated using different functions from the remainder of the filesystem. A filesystem advertises its support for these files by filling in new entries in the grub_fs struct. Second, the loadenv command was modified to use the special file functions of the root filesystem if they are detected. If that happens, these functions are used to open, read, and write to the loadenv file instead of the normal grub file functions. A variable was also added that allows the user to force a file to be used instead of the special files, or vice versa. Third, the grub-editenv command was modified to teach it to probe the root filesystem and then check in an array of structures that contain functions that will read and modify the filesystem's special file in userland. These functions are very similar to normal read and write functions, and so don't result in a very different code flow. Finally, the GRUB ZFS logic was modified to have new special_file functions. These functions manipulate the pad2 area of the ZFS label, which was previously unused. It now stores a version number, the raw contents of the grubenv file, and an embedded checksum for integrity purposes. GRUB was taught to read and verify these areas, and also to modify them, computing the embeddded checksum appropriately. In addition, if GRUB is build with libzfs support, an entry is added to the grub-editenv table that points GRUB to the appropriate libzfs functions, and init and fini functions are built into grub-editenv itself. Future work: * In the ZFS code could store a packed nvlist instead of a raw file, but this would involve further changes to the grub environment file code and was deferred for when it would be more useful and important. * For the special files code, there is only one special file allowed per filesystem, but a specification interface (using either an enum or a set of names) could be added in the future. * Other filesystem support was not built into this change, but extensibility was a primary goal, so adding support for btrfs or other filesystems should be relatively straightforward. * I did not implement the proposed UEFI variable support, but I did develop this with that future in mind, so adding it should be a relatively simple extension of these changes. This patchset has been tested on systems with and without ZFS as the boot filesystem, and built with and without ZFS libraries installed. It worked in each case I tried, including with manual corruption applied to the ZFS labels to force GRUB to read from the other label. This was tested in conjunction with https://github.com/zfsonlinux/zfs/pull/10009 , the ZoL patch that enables ZFS to read from and write to the padding areas we reserved for the data. Paul Dagnelie (7): Factor out file filter function for reuse Add support for special envblk functions in GRUB Factor out envblk buffer creation for reuse Use envblk file and fs functions to implement reading the grubenv file from special FS regions Add ZFS envblock functions Refactor default envblk size out for reuse Update editenv to support editing zfs envblock, fix whitespace, and autodetect bootenv support in libzfs configure.ac | 8 + grub-core/commands/loadenv.c | 122 +++++++++++++-- grub-core/fs/zfs/zfs.c | 134 +++++++++++++++-- grub-core/kern/file.c | 76 +++++++--- include/grub/file.h | 10 ++ include/grub/fs.h | 12 ++ include/grub/lib/envblk.h | 3 + include/grub/util/install.h | 3 + include/grub/util/libzfs.h | 7 + include/grub/zfs/vdev_impl.h | 33 ++--- util/editenv.c | 31 ++-- util/grub-editenv.c | 278 +++++++++++++++++++++++++++++++++-- 12 files changed, 632 insertions(+), 85 deletions(-) -- 2.19.0