5 Commits

Author SHA1 Message Date
Thomas Lamprecht 3efcc79c39 bump version to 2.1.7-pve3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-07 13:22:02 +01:00
Thomas Lamprecht 85a3ff856d adapt to 6.1 changes for open syscall with TMPFILE option
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-07 13:20:28 +01:00
Thomas Lamprecht dca6abbf07 backport pipe-resize and xattr fix
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-07 13:19:51 +01:00
Thomas Lamprecht 5a2ad46755 bump version to 2.1.7-pve2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-02 17:07:23 +01:00
Stoiko Ivanov d0e8c24e02 fix #4440: cherry-pick patch for mountpoint=legacy on /
As reported having set 'mountpoint=legacy' on the root dataset (for a
default install this would be 'rpool/ROOT/pve-1') for mounting through
e.g. /etc/fstab breaks booting in initramfs

The cherry-picked patch is already applied to zfs-2.1.8-staging
upstream so will be included in the next zfs point release.

reproduced the issue on a VM with ZFS on root by:
* booting into a PVE 7.3 iso (to have zfs and an inactive
  rpool/ROOT/pve-1)
* `zpool import -ocachefile=none -N -f rpool
* `zfs set mountpoint=legacy rpool/ROOT/pve-1`
* `mount -t zfs rpool/ROOT/pve-1 /mnt
* `echo "rpool/ROOT/pve-1 / zfs defaults 0 0" >> /mnt/etc/fstab`
* `zpool export rpool`
* reboot - the boot breaks with zfs-initramfs 2.1.7-pve1 but works
  with this patch applied

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2023-01-02 17:03:49 +01:00
6 changed files with 374 additions and 0 deletions
+16
View File
@@ -1,3 +1,19 @@
zfs-linux (2.1.7-pve3) bullseye; urgency=medium
* backport a fix for as potentially hanging pipe when resizing it on recv
* backport a fix for setting extended attributes (xattr)
* adapt to 6.1 changes for open syscall with TMPFILE option
-- Proxmox Support Team <support@proxmox.com> Sat, 07 Jan 2023 13:21:57 +0100
zfs-linux (2.1.7-pve2) bullseye; urgency=medium
* backport fix for initramfs script when detecting rootfs legacy mountpoints
-- Proxmox Support Team <support@proxmox.com> Mon, 02 Jan 2023 17:07:18 +0100
zfs-linux (2.1.7-pve1) bullseye; urgency=medium
* update ZFS to 2.1.7
@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ryan Moeller <ryan@iXsystems.com>
Date: Mon, 12 Dec 2022 13:23:06 -0500
Subject: [PATCH] initramfs: Fix legacy mountpoint rootfs
Legacy mountpoint datasets should not pass `-o zfsutil` to `mount.zfs`.
Fix the logic in `mount_fs()` to not forget we have a legacy mountpoint
when checking for an `org.zol:mountpoint` userprop.
Reviewed-by: Richard Yao <ryao@gentoo.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #14274
(cherry picked from commit 786ff6a6cb33226b4f4292c7569b9093286f74d9)
(cherry picked from commit f28c7302cb77a8cb6112690d0eed0bf4adeeae15)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
contrib/initramfs/scripts/zfs | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs
index 9169adf5f..c7548fa07 100644
--- a/contrib/initramfs/scripts/zfs
+++ b/contrib/initramfs/scripts/zfs
@@ -331,25 +331,21 @@ mount_fs()
# Can't use the mountpoint property. Might be one of our
# clones. Check the 'org.zol:mountpoint' property set in
# clone_snap() if that's usable.
- mountpoint=$(get_fs_value "$fs" org.zol:mountpoint)
- if [ "$mountpoint" = "legacy" ] ||
- [ "$mountpoint" = "none" ] ||
- [ "$mountpoint" = "-" ]
+ mountpoint1=$(get_fs_value "$fs" org.zol:mountpoint)
+ if [ "$mountpoint1" = "legacy" ] ||
+ [ "$mountpoint1" = "none" ] ||
+ [ "$mountpoint1" = "-" ]
then
if [ "$fs" != "${ZFS_BOOTFS}" ]; then
# We don't have a proper mountpoint and this
# isn't the root fs.
return 0
- else
- # Last hail-mary: Hope 'rootmnt' is set!
- mountpoint=""
fi
- fi
-
- # If it's not a legacy filesystem, it can only be a
- # native one...
- if [ "$mountpoint" = "legacy" ]; then
ZFS_CMD="mount.zfs"
+ # Last hail-mary: Hope 'rootmnt' is set!
+ mountpoint=""
+ else
+ mountpoint="$mountpoint1"
fi
fi
@@ -0,0 +1,68 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Rich Ercolani <214141+rincebrain@users.noreply.github.com>
Date: Mon, 9 May 2022 19:33:55 -0400
Subject: [PATCH] Add workaround for broken Linux pipes
Linux has an unresolved hang if you resize a pipe with bytes
in it.
Since there's no obvious way to detect this happening, added a
workaround to disable resizing the pipe buffer if you set an
environment variable.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13309
(cherry picked from commit e84a2ed7a8b9e6458c25c6e93a93601eaf4128eb)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
lib/libzfs/os/linux/libzfs_sendrecv_os.c | 16 ++++++++++++++++
man/man8/zfs.8 | 8 ++++++++
2 files changed, 24 insertions(+)
diff --git a/lib/libzfs/os/linux/libzfs_sendrecv_os.c b/lib/libzfs/os/linux/libzfs_sendrecv_os.c
index ac7ab95a3..8fc02fff2 100644
--- a/lib/libzfs/os/linux/libzfs_sendrecv_os.c
+++ b/lib/libzfs/os/linux/libzfs_sendrecv_os.c
@@ -35,6 +35,22 @@
void
libzfs_set_pipe_max(int infd)
{
+#if __linux__
+ /*
+ * Sadly, Linux has an unfixed deadlock if you do SETPIPE_SZ on a pipe
+ * with data in it.
+ * cf. #13232, https://bugzilla.kernel.org/show_bug.cgi?id=212295
+ *
+ * And since the problem is in waking up the writer, there's nothing
+ * we can do about it from here.
+ *
+ * So if people want to, they can set this, but they
+ * may regret it...
+ */
+ if (getenv("ZFS_SET_PIPE_MAX") == NULL)
+ return;
+#endif
+
FILE *procf = fopen("/proc/sys/fs/pipe-max-size", "re");
if (procf != NULL) {
diff --git a/man/man8/zfs.8 b/man/man8/zfs.8
index fca1ba00d..a5c944169 100644
--- a/man/man8/zfs.8
+++ b/man/man8/zfs.8
@@ -713,6 +713,14 @@ to use
to mount ZFS datasets.
This option is provided for backwards compatibility with older ZFS versions.
.El
+.Bl -tag -width "ZFS_SET_PIPE_MAX"
+.It Sy ZFS_SET_PIPE_MAX
+Tells
+.Nm zfs
+to set the maximum pipe size for sends/recieves.
+Disabled by default on Linux
+due to an unfixed deadlock in Linux's pipe size handling code.
+.El
.
.Sh INTERFACE STABILITY
.Sy Committed .
@@ -0,0 +1,91 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ameer Hamza <ahamza@ixsystems.com>
Date: Wed, 23 Nov 2022 01:28:13 +0500
Subject: [PATCH] skip permission checks for extended attributes
zfs_zaccess_trivial() calls the generic_permission() to read
xattr attributes. This causes deadlock if called from
zpl_xattr_set_dir() context as xattr and the dent locks are
already held in this scenario. This commit skips the permissions
checks for extended attributes since the Linux VFS stack already
checks it before passing us the control.
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
(cherry picked from commit 75fbe7eb99c3d20403c79c7e24a97997c424313a)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
module/os/linux/zfs/zfs_dir.c | 3 ---
module/os/linux/zfs/zfs_vnops_os.c | 3 ++-
module/os/linux/zfs/zpl_xattr.c | 2 +-
tests/zfs-tests/tests/functional/acl/posix/posix_004_pos.ksh | 3 +++
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/module/os/linux/zfs/zfs_dir.c b/module/os/linux/zfs/zfs_dir.c
index 82b32d1cc..8ad5454b5 100644
--- a/module/os/linux/zfs/zfs_dir.c
+++ b/module/os/linux/zfs/zfs_dir.c
@@ -1066,9 +1066,6 @@ zfs_make_xattrdir(znode_t *zp, vattr_t *vap, znode_t **xzpp, cred_t *cr)
*xzpp = NULL;
- if ((error = zfs_zaccess(zp, ACE_WRITE_NAMED_ATTRS, 0, B_FALSE, cr)))
- return (error);
-
if ((error = zfs_acl_ids_create(zp, IS_XATTR, vap, cr, NULL,
&acl_ids)) != 0)
return (error);
diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c
index 796a86c25..ae0401e60 100644
--- a/module/os/linux/zfs/zfs_vnops_os.c
+++ b/module/os/linux/zfs/zfs_vnops_os.c
@@ -579,6 +579,7 @@ zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
boolean_t fuid_dirtied;
boolean_t have_acl = B_FALSE;
boolean_t waited = B_FALSE;
+ boolean_t skip_acl = (flag & ATTR_NOACLCHECK) ? B_TRUE : B_FALSE;
/*
* If we have an ephemeral id, ACL, or XVATTR then
@@ -651,7 +652,7 @@ top:
* Create a new file object and update the directory
* to reference it.
*/
- if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) {
+ if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, skip_acl, cr))) {
if (have_acl)
zfs_acl_ids_free(&acl_ids);
goto out;
diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c
index bd5d5803f..9d758d2d0 100644
--- a/module/os/linux/zfs/zpl_xattr.c
+++ b/module/os/linux/zfs/zpl_xattr.c
@@ -496,7 +496,7 @@ zpl_xattr_set_dir(struct inode *ip, const char *name, const void *value,
vap->va_gid = crgetgid(cr);
error = -zfs_create(dxzp, (char *)name, vap, 0, 0644, &xzp,
- cr, 0, NULL);
+ cr, ATTR_NOACLCHECK, NULL);
if (error)
goto out;
}
diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_004_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_004_pos.ksh
index 6c6b592fb..8aa2cf496 100755
--- a/tests/zfs-tests/tests/functional/acl/posix/posix_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/acl/posix/posix_004_pos.ksh
@@ -35,6 +35,7 @@
# STRATEGY:
# 1. Prepare an appropriate ACL on the test directory
# 2. Change the owner of the directory
+# 3. Reset and set the ACLs for test directory owned by the user
#
verify_runnable "both"
@@ -44,6 +45,8 @@ log_must setfacl -d -m u:$ZFS_ACL_STAFF1:rwx $TESTDIR
log_must setfacl -b $TESTDIR
log_must chown $ZFS_ACL_STAFF1 $TESTDIR
+log_must setfacl -b $TESTDIR
+log_must setfacl -d -m u:$ZFS_ACL_STAFF1:rwx $TESTDIR
log_must chown 0 $TESTDIR
log_pass "chown works with POSIX ACLs"
@@ -0,0 +1,137 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Antonio Russo <aerusso@aerusso.net>
Date: Sat, 31 Dec 2022 07:51:32 -0700
Subject: [PATCH] Linux 6.1 compat: open inside tmpfile()
Linux 863f144 modified the .tmpfile interface to pass a struct file,
rather than a struct dentry, and expect the tmpfile implementation to
open inside of tmpfile().
This patch implements a configuration test that checks for this new API
and appropriately sets a HAVE_TMPFILE_DENTRY flag that tracks this old
API. Contingent on this flag, the appropriate API is implemented.
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #14301
Closes #14343
(cherry picked from commit d27c81847b43584483b5509ff352e7e727b0ce87)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
config/kernel-tmpfile.m4 | 32 +++++++++++++++++++++++++++-----
module/os/linux/zfs/zpl_inode.c | 15 +++++++++++++++
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/config/kernel-tmpfile.m4 b/config/kernel-tmpfile.m4
index 45c2e6cee..acb7ea1e8 100644
--- a/config/kernel-tmpfile.m4
+++ b/config/kernel-tmpfile.m4
@@ -3,11 +3,25 @@ dnl # 3.11 API change
dnl # Add support for i_op->tmpfile
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_TMPFILE], [
+ dnl #
+ dnl # 6.1 API change
+ dnl # use struct file instead of struct dentry
+ dnl #
+ ZFS_LINUX_TEST_SRC([inode_operations_tmpfile], [
+ #include <linux/fs.h>
+ int tmpfile(struct user_namespace *userns,
+ struct inode *inode, struct file *file,
+ umode_t mode) { return 0; }
+ static struct inode_operations
+ iops __attribute__ ((unused)) = {
+ .tmpfile = tmpfile,
+ };
+ ],[])
dnl #
dnl # 5.11 API change
dnl # add support for userns parameter to tmpfile
dnl #
- ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_userns], [
+ ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_dentry_userns], [
#include <linux/fs.h>
int tmpfile(struct user_namespace *userns,
struct inode *inode, struct dentry *dentry,
@@ -17,7 +31,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_TMPFILE], [
.tmpfile = tmpfile,
};
],[])
- ZFS_LINUX_TEST_SRC([inode_operations_tmpfile], [
+ ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_dentry], [
#include <linux/fs.h>
int tmpfile(struct inode *inode, struct dentry *dentry,
umode_t mode) { return 0; }
@@ -30,16 +44,24 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_TMPFILE], [
AC_DEFUN([ZFS_AC_KERNEL_TMPFILE], [
AC_MSG_CHECKING([whether i_op->tmpfile() exists])
- ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_userns], [
+ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists])
AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns])
],[
- ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [
+ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry_userns], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists])
+ AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns])
+ AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature])
],[
- AC_MSG_RESULT(no)
+ ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists])
+ AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
])
])
])
diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c
index a0615af8d..fece7886e 100644
--- a/module/os/linux/zfs/zpl_inode.c
+++ b/module/os/linux/zfs/zpl_inode.c
@@ -224,12 +224,17 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
#ifdef HAVE_TMPFILE
static int
+#ifndef HAVE_TMPFILE_DENTRY
+zpl_tmpfile(struct user_namespace *userns, struct inode *dir,
+ struct file *file, umode_t mode)
+#else
#ifdef HAVE_TMPFILE_USERNS
zpl_tmpfile(struct user_namespace *userns, struct inode *dir,
struct dentry *dentry, umode_t mode)
#else
zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
#endif
+#endif
{
cred_t *cr = CRED();
struct inode *ip;
@@ -252,11 +257,21 @@ zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
if (error == 0) {
/* d_tmpfile will do drop_nlink, so we should set it first */
set_nlink(ip, 1);
+#ifndef HAVE_TMPFILE_DENTRY
+ d_tmpfile(file, ip);
+
+ error = zpl_xattr_security_init(ip, dir,
+ &file->f_path.dentry->d_name);
+#else
d_tmpfile(dentry, ip);
error = zpl_xattr_security_init(ip, dir, &dentry->d_name);
+#endif
if (error == 0)
error = zpl_init_acl(ip, dir);
+#ifndef HAVE_TMPFILE_DENTRY
+ error = finish_open_simple(file, error);
+#endif
/*
* don't need to handle error here, file is already in
* unlinked set.
+4
View File
@@ -9,3 +9,7 @@
0009-Patch-move-manpage-arcstat-1-to-arcstat-8.patch
0010-arcstat-Fix-integer-division-with-python3.patch
0011-arc-stat-summary-guard-access-to-l2arc-MFU-MRU-stats.patch
0012-initramfs-Fix-legacy-mountpoint-rootfs.patch
0013-Add-workaround-for-broken-Linux-pipes.patch
0014-skip-permission-checks-for-extended-attributes.patch
0015-Linux-6.1-compat-open-inside-tmpfile.patch