From: Greg Kroah-Hartman Date: Mon, 4 Jul 2022 14:43:50 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.9.322~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e09aa48ded607f1fb9e6521358da8f3c45cef15f;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: xfs-ensure-xfs_errortag_random_default-matches-xfs_errtag_max.patch xfs-fix-xfs_reflink_unshare-usage-of-filemap_write_and_wait_range.patch xfs-fix-xfs_trans-slab-cache-name.patch xfs-rename-variable-mp-to-parsing_mp.patch xfs-skip-repetitive-warnings-about-mount-options.patch xfs-update-superblock-counters-correctly-for-lazysbcount.patch xfs-use-current-journal_info-for-detecting-transaction-recursion.patch --- diff --git a/queue-5.10/series b/queue-5.10/series index 13cf63f5851..f259ac69794 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -38,3 +38,10 @@ epic100-fix-use-after-free-on-rmmod.patch io_uring-ensure-that-send-sendmsg-and-recv-recvmsg-check-sqe-ioprio.patch tunnels-do-not-assume-mac-header-is-set-in-skb_tunnel_check_pmtu.patch net-tun-avoid-disabling-napi-twice.patch +xfs-use-current-journal_info-for-detecting-transaction-recursion.patch +xfs-rename-variable-mp-to-parsing_mp.patch +xfs-skip-repetitive-warnings-about-mount-options.patch +xfs-ensure-xfs_errortag_random_default-matches-xfs_errtag_max.patch +xfs-fix-xfs_trans-slab-cache-name.patch +xfs-update-superblock-counters-correctly-for-lazysbcount.patch +xfs-fix-xfs_reflink_unshare-usage-of-filemap_write_and_wait_range.patch diff --git a/queue-5.10/xfs-ensure-xfs_errortag_random_default-matches-xfs_errtag_max.patch b/queue-5.10/xfs-ensure-xfs_errortag_random_default-matches-xfs_errtag_max.patch new file mode 100644 index 00000000000..6514d0f5aaa --- /dev/null +++ b/queue-5.10/xfs-ensure-xfs_errortag_random_default-matches-xfs_errtag_max.patch @@ -0,0 +1,38 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:53 +0300 +Subject: xfs: ensure xfs_errortag_random_default matches XFS_ERRTAG_MAX +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Gao Xiang , Christoph Hellwig +Message-ID: <20220703050456.3222610-5-amir73il@gmail.com> + +From: Gao Xiang + +commit b2c2974b8cdf1eb3ef90ff845eb27b19e2187b7e upstream. + +Add the BUILD_BUG_ON to xfs_errortag_add() in order to make sure that +the length of xfs_errortag_random_default matches XFS_ERRTAG_MAX when +building. + +Signed-off-by: Gao Xiang +Reviewed-by: Christoph Hellwig +Reviewed-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_error.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/fs/xfs/xfs_error.c ++++ b/fs/xfs/xfs_error.c +@@ -293,6 +293,8 @@ xfs_errortag_add( + struct xfs_mount *mp, + unsigned int error_tag) + { ++ BUILD_BUG_ON(ARRAY_SIZE(xfs_errortag_random_default) != XFS_ERRTAG_MAX); ++ + if (error_tag >= XFS_ERRTAG_MAX) + return -EINVAL; + diff --git a/queue-5.10/xfs-fix-xfs_reflink_unshare-usage-of-filemap_write_and_wait_range.patch b/queue-5.10/xfs-fix-xfs_reflink_unshare-usage-of-filemap_write_and_wait_range.patch new file mode 100644 index 00000000000..140a74f2ce9 --- /dev/null +++ b/queue-5.10/xfs-fix-xfs_reflink_unshare-usage-of-filemap_write_and_wait_range.patch @@ -0,0 +1,38 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:56 +0300 +Subject: xfs: fix xfs_reflink_unshare usage of filemap_write_and_wait_range +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Chandan Babu R , Brian Foster +Message-ID: <20220703050456.3222610-8-amir73il@gmail.com> + +From: "Darrick J. Wong" + +commit d4f74e162d238ce00a640af5f0611c3f51dad70e upstream. + +The final parameter of filemap_write_and_wait_range is the end of the +range to flush, not the length of the range to flush. + +Fixes: 46afb0628b86 ("xfs: only flush the unshared range in xfs_reflink_unshare") +Signed-off-by: Darrick J. Wong +Reviewed-by: Chandan Babu R +Reviewed-by: Brian Foster +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_reflink.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/xfs/xfs_reflink.c ++++ b/fs/xfs/xfs_reflink.c +@@ -1503,7 +1503,8 @@ xfs_reflink_unshare( + if (error) + goto out; + +- error = filemap_write_and_wait_range(inode->i_mapping, offset, len); ++ error = filemap_write_and_wait_range(inode->i_mapping, offset, ++ offset + len - 1); + if (error) + goto out; + diff --git a/queue-5.10/xfs-fix-xfs_trans-slab-cache-name.patch b/queue-5.10/xfs-fix-xfs_trans-slab-cache-name.patch new file mode 100644 index 00000000000..31919c6a1a3 --- /dev/null +++ b/queue-5.10/xfs-fix-xfs_trans-slab-cache-name.patch @@ -0,0 +1,38 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:54 +0300 +Subject: xfs: fix xfs_trans slab cache name +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Anthony Iliopoulos +Message-ID: <20220703050456.3222610-6-amir73il@gmail.com> + +From: Anthony Iliopoulos + +commit 25dfa65f814951a33072bcbae795989d817858da upstream. + +Removal of kmem_zone_init wrappers accidentally changed a slab cache +name from "xfs_trans" to "xf_trans". Fix this so that userspace +consumers of /proc/slabinfo and /sys/kernel/slab can find it again. + +Fixes: b1231760e443 ("xfs: Remove slab init wrappers") +Signed-off-by: Anthony Iliopoulos +Reviewed-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/xfs/xfs_super.c ++++ b/fs/xfs/xfs_super.c +@@ -1934,7 +1934,7 @@ xfs_init_zones(void) + if (!xfs_ifork_zone) + goto out_destroy_da_state_zone; + +- xfs_trans_zone = kmem_cache_create("xf_trans", ++ xfs_trans_zone = kmem_cache_create("xfs_trans", + sizeof(struct xfs_trans), + 0, 0, NULL); + if (!xfs_trans_zone) diff --git a/queue-5.10/xfs-rename-variable-mp-to-parsing_mp.patch b/queue-5.10/xfs-rename-variable-mp-to-parsing_mp.patch new file mode 100644 index 00000000000..3f9cfb27721 --- /dev/null +++ b/queue-5.10/xfs-rename-variable-mp-to-parsing_mp.patch @@ -0,0 +1,233 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:51 +0300 +Subject: xfs: rename variable mp to parsing_mp +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Pavel Reichl , Eric Sandeen , Carlos Maiolino +Message-ID: <20220703050456.3222610-3-amir73il@gmail.com> + +From: Pavel Reichl + +commit 0f98b4ece18da9d8287bb4cc4e8f78b8760ea0d0 upstream. + +Rename mp variable to parsisng_mp so it is easy to distinguish +between current mount point handle and handle for mount point +which mount options are being parsed. + +Suggested-by: Eric Sandeen +Signed-off-by: Pavel Reichl + +Reviewed-by: Darrick J. Wong +Reviewed-by: Carlos Maiolino +Signed-off-by: Darrick J. Wong +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_super.c | 102 ++++++++++++++++++++++++++--------------------------- + 1 file changed, 51 insertions(+), 51 deletions(-) + +--- a/fs/xfs/xfs_super.c ++++ b/fs/xfs/xfs_super.c +@@ -1165,7 +1165,7 @@ xfs_fc_parse_param( + struct fs_context *fc, + struct fs_parameter *param) + { +- struct xfs_mount *mp = fc->s_fs_info; ++ struct xfs_mount *parsing_mp = fc->s_fs_info; + struct fs_parse_result result; + int size = 0; + int opt; +@@ -1176,142 +1176,142 @@ xfs_fc_parse_param( + + switch (opt) { + case Opt_logbufs: +- mp->m_logbufs = result.uint_32; ++ parsing_mp->m_logbufs = result.uint_32; + return 0; + case Opt_logbsize: +- if (suffix_kstrtoint(param->string, 10, &mp->m_logbsize)) ++ if (suffix_kstrtoint(param->string, 10, &parsing_mp->m_logbsize)) + return -EINVAL; + return 0; + case Opt_logdev: +- kfree(mp->m_logname); +- mp->m_logname = kstrdup(param->string, GFP_KERNEL); +- if (!mp->m_logname) ++ kfree(parsing_mp->m_logname); ++ parsing_mp->m_logname = kstrdup(param->string, GFP_KERNEL); ++ if (!parsing_mp->m_logname) + return -ENOMEM; + return 0; + case Opt_rtdev: +- kfree(mp->m_rtname); +- mp->m_rtname = kstrdup(param->string, GFP_KERNEL); +- if (!mp->m_rtname) ++ kfree(parsing_mp->m_rtname); ++ parsing_mp->m_rtname = kstrdup(param->string, GFP_KERNEL); ++ if (!parsing_mp->m_rtname) + return -ENOMEM; + return 0; + case Opt_allocsize: + if (suffix_kstrtoint(param->string, 10, &size)) + return -EINVAL; +- mp->m_allocsize_log = ffs(size) - 1; +- mp->m_flags |= XFS_MOUNT_ALLOCSIZE; ++ parsing_mp->m_allocsize_log = ffs(size) - 1; ++ parsing_mp->m_flags |= XFS_MOUNT_ALLOCSIZE; + return 0; + case Opt_grpid: + case Opt_bsdgroups: +- mp->m_flags |= XFS_MOUNT_GRPID; ++ parsing_mp->m_flags |= XFS_MOUNT_GRPID; + return 0; + case Opt_nogrpid: + case Opt_sysvgroups: +- mp->m_flags &= ~XFS_MOUNT_GRPID; ++ parsing_mp->m_flags &= ~XFS_MOUNT_GRPID; + return 0; + case Opt_wsync: +- mp->m_flags |= XFS_MOUNT_WSYNC; ++ parsing_mp->m_flags |= XFS_MOUNT_WSYNC; + return 0; + case Opt_norecovery: +- mp->m_flags |= XFS_MOUNT_NORECOVERY; ++ parsing_mp->m_flags |= XFS_MOUNT_NORECOVERY; + return 0; + case Opt_noalign: +- mp->m_flags |= XFS_MOUNT_NOALIGN; ++ parsing_mp->m_flags |= XFS_MOUNT_NOALIGN; + return 0; + case Opt_swalloc: +- mp->m_flags |= XFS_MOUNT_SWALLOC; ++ parsing_mp->m_flags |= XFS_MOUNT_SWALLOC; + return 0; + case Opt_sunit: +- mp->m_dalign = result.uint_32; ++ parsing_mp->m_dalign = result.uint_32; + return 0; + case Opt_swidth: +- mp->m_swidth = result.uint_32; ++ parsing_mp->m_swidth = result.uint_32; + return 0; + case Opt_inode32: +- mp->m_flags |= XFS_MOUNT_SMALL_INUMS; ++ parsing_mp->m_flags |= XFS_MOUNT_SMALL_INUMS; + return 0; + case Opt_inode64: +- mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; ++ parsing_mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; + return 0; + case Opt_nouuid: +- mp->m_flags |= XFS_MOUNT_NOUUID; ++ parsing_mp->m_flags |= XFS_MOUNT_NOUUID; + return 0; + case Opt_largeio: +- mp->m_flags |= XFS_MOUNT_LARGEIO; ++ parsing_mp->m_flags |= XFS_MOUNT_LARGEIO; + return 0; + case Opt_nolargeio: +- mp->m_flags &= ~XFS_MOUNT_LARGEIO; ++ parsing_mp->m_flags &= ~XFS_MOUNT_LARGEIO; + return 0; + case Opt_filestreams: +- mp->m_flags |= XFS_MOUNT_FILESTREAMS; ++ parsing_mp->m_flags |= XFS_MOUNT_FILESTREAMS; + return 0; + case Opt_noquota: +- mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; +- mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; +- mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE; ++ parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACCT; ++ parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ENFD; ++ parsing_mp->m_qflags &= ~XFS_ALL_QUOTA_ACTIVE; + return 0; + case Opt_quota: + case Opt_uquota: + case Opt_usrquota: +- mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE | ++ parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE | + XFS_UQUOTA_ENFD); + return 0; + case Opt_qnoenforce: + case Opt_uqnoenforce: +- mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); +- mp->m_qflags &= ~XFS_UQUOTA_ENFD; ++ parsing_mp->m_qflags |= (XFS_UQUOTA_ACCT | XFS_UQUOTA_ACTIVE); ++ parsing_mp->m_qflags &= ~XFS_UQUOTA_ENFD; + return 0; + case Opt_pquota: + case Opt_prjquota: +- mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | ++ parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE | + XFS_PQUOTA_ENFD); + return 0; + case Opt_pqnoenforce: +- mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); +- mp->m_qflags &= ~XFS_PQUOTA_ENFD; ++ parsing_mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE); ++ parsing_mp->m_qflags &= ~XFS_PQUOTA_ENFD; + return 0; + case Opt_gquota: + case Opt_grpquota: +- mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | ++ parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE | + XFS_GQUOTA_ENFD); + return 0; + case Opt_gqnoenforce: +- mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); +- mp->m_qflags &= ~XFS_GQUOTA_ENFD; ++ parsing_mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); ++ parsing_mp->m_qflags &= ~XFS_GQUOTA_ENFD; + return 0; + case Opt_discard: +- mp->m_flags |= XFS_MOUNT_DISCARD; ++ parsing_mp->m_flags |= XFS_MOUNT_DISCARD; + return 0; + case Opt_nodiscard: +- mp->m_flags &= ~XFS_MOUNT_DISCARD; ++ parsing_mp->m_flags &= ~XFS_MOUNT_DISCARD; + return 0; + #ifdef CONFIG_FS_DAX + case Opt_dax: +- xfs_mount_set_dax_mode(mp, XFS_DAX_ALWAYS); ++ xfs_mount_set_dax_mode(parsing_mp, XFS_DAX_ALWAYS); + return 0; + case Opt_dax_enum: +- xfs_mount_set_dax_mode(mp, result.uint_32); ++ xfs_mount_set_dax_mode(parsing_mp, result.uint_32); + return 0; + #endif + /* Following mount options will be removed in September 2025 */ + case Opt_ikeep: +- xfs_warn(mp, "%s mount option is deprecated.", param->key); +- mp->m_flags |= XFS_MOUNT_IKEEP; ++ xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ parsing_mp->m_flags |= XFS_MOUNT_IKEEP; + return 0; + case Opt_noikeep: +- xfs_warn(mp, "%s mount option is deprecated.", param->key); +- mp->m_flags &= ~XFS_MOUNT_IKEEP; ++ xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ parsing_mp->m_flags &= ~XFS_MOUNT_IKEEP; + return 0; + case Opt_attr2: +- xfs_warn(mp, "%s mount option is deprecated.", param->key); +- mp->m_flags |= XFS_MOUNT_ATTR2; ++ xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ parsing_mp->m_flags |= XFS_MOUNT_ATTR2; + return 0; + case Opt_noattr2: +- xfs_warn(mp, "%s mount option is deprecated.", param->key); +- mp->m_flags &= ~XFS_MOUNT_ATTR2; +- mp->m_flags |= XFS_MOUNT_NOATTR2; ++ xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ parsing_mp->m_flags &= ~XFS_MOUNT_ATTR2; ++ parsing_mp->m_flags |= XFS_MOUNT_NOATTR2; + return 0; + default: +- xfs_warn(mp, "unknown mount option [%s].", param->key); ++ xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); + return -EINVAL; + } + diff --git a/queue-5.10/xfs-skip-repetitive-warnings-about-mount-options.patch b/queue-5.10/xfs-skip-repetitive-warnings-about-mount-options.patch new file mode 100644 index 00000000000..28da430c6df --- /dev/null +++ b/queue-5.10/xfs-skip-repetitive-warnings-about-mount-options.patch @@ -0,0 +1,78 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:52 +0300 +Subject: xfs: Skip repetitive warnings about mount options +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Pavel Reichl , Eric Sandeen , Carlos Maiolino +Message-ID: <20220703050456.3222610-4-amir73il@gmail.com> + +From: Pavel Reichl + +commit 92cf7d36384b99d5a57bf4422904a3c16dc4527a upstream. + +Skip the warnings about mount option being deprecated if we are +remounting and deprecated option state is not changing. + +Bug: https://bugzilla.kernel.org/show_bug.cgi?id=211605 +Fix-suggested-by: Eric Sandeen +Signed-off-by: Pavel Reichl + +Reviewed-by: Darrick J. Wong +Reviewed-by: Carlos Maiolino +Signed-off-by: Darrick J. Wong +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_super.c | 24 ++++++++++++++++++++---- + 1 file changed, 20 insertions(+), 4 deletions(-) + +--- a/fs/xfs/xfs_super.c ++++ b/fs/xfs/xfs_super.c +@@ -1155,6 +1155,22 @@ suffix_kstrtoint( + return ret; + } + ++static inline void ++xfs_fs_warn_deprecated( ++ struct fs_context *fc, ++ struct fs_parameter *param, ++ uint64_t flag, ++ bool value) ++{ ++ /* Don't print the warning if reconfiguring and current mount point ++ * already had the flag set ++ */ ++ if ((fc->purpose & FS_CONTEXT_FOR_RECONFIGURE) && ++ !!(XFS_M(fc->root->d_sb)->m_flags & flag) == value) ++ return; ++ xfs_warn(fc->s_fs_info, "%s mount option is deprecated.", param->key); ++} ++ + /* + * Set mount state from a mount option. + * +@@ -1294,19 +1310,19 @@ xfs_fc_parse_param( + #endif + /* Following mount options will be removed in September 2025 */ + case Opt_ikeep: +- xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_IKEEP, true); + parsing_mp->m_flags |= XFS_MOUNT_IKEEP; + return 0; + case Opt_noikeep: +- xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_IKEEP, false); + parsing_mp->m_flags &= ~XFS_MOUNT_IKEEP; + return 0; + case Opt_attr2: +- xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_ATTR2, true); + parsing_mp->m_flags |= XFS_MOUNT_ATTR2; + return 0; + case Opt_noattr2: +- xfs_warn(parsing_mp, "%s mount option is deprecated.", param->key); ++ xfs_fs_warn_deprecated(fc, param, XFS_MOUNT_NOATTR2, true); + parsing_mp->m_flags &= ~XFS_MOUNT_ATTR2; + parsing_mp->m_flags |= XFS_MOUNT_NOATTR2; + return 0; diff --git a/queue-5.10/xfs-update-superblock-counters-correctly-for-lazysbcount.patch b/queue-5.10/xfs-update-superblock-counters-correctly-for-lazysbcount.patch new file mode 100644 index 00000000000..da9576e0db8 --- /dev/null +++ b/queue-5.10/xfs-update-superblock-counters-correctly-for-lazysbcount.patch @@ -0,0 +1,76 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:55 +0300 +Subject: xfs: update superblock counters correctly for !lazysbcount +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Dave Chinner , Zorro Lang , Gao Xiang , Brian Foster +Message-ID: <20220703050456.3222610-7-amir73il@gmail.com> + +From: Dave Chinner + +commit 6543990a168acf366f4b6174d7bd46ba15a8a2a6 upstream. + +Keep the mount superblock counters up to date for !lazysbcount +filesystems so that when we log the superblock they do not need +updating in any way because they are already correct. + +It's found by what Zorro reported: +1. mkfs.xfs -f -l lazy-count=0 -m crc=0 $dev +2. mount $dev $mnt +3. fsstress -d $mnt -p 100 -n 1000 (maybe need more or less io load) +4. umount $mnt +5. xfs_repair -n $dev +and I've seen no problem with this patch. + +Signed-off-by: Dave Chinner +Reported-by: Zorro Lang +Reviewed-by: Gao Xiang +Signed-off-by: Gao Xiang +Reviewed-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Reviewed-by: Brian Foster +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/libxfs/xfs_sb.c | 16 +++++++++++++--- + fs/xfs/xfs_trans.c | 3 +++ + 2 files changed, 16 insertions(+), 3 deletions(-) + +--- a/fs/xfs/libxfs/xfs_sb.c ++++ b/fs/xfs/libxfs/xfs_sb.c +@@ -956,9 +956,19 @@ xfs_log_sb( + struct xfs_mount *mp = tp->t_mountp; + struct xfs_buf *bp = xfs_trans_getsb(tp); + +- mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); +- mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); +- mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); ++ /* ++ * Lazy sb counters don't update the in-core superblock so do that now. ++ * If this is at unmount, the counters will be exactly correct, but at ++ * any other time they will only be ballpark correct because of ++ * reservations that have been taken out percpu counters. If we have an ++ * unclean shutdown, this will be corrected by log recovery rebuilding ++ * the counters from the AGF block counts. ++ */ ++ if (xfs_sb_version_haslazysbcount(&mp->m_sb)) { ++ mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); ++ mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); ++ mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); ++ } + + xfs_sb_to_disk(bp->b_addr, &mp->m_sb); + xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); +--- a/fs/xfs/xfs_trans.c ++++ b/fs/xfs/xfs_trans.c +@@ -615,6 +615,9 @@ xfs_trans_unreserve_and_mod_sb( + + /* apply remaining deltas */ + spin_lock(&mp->m_sb_lock); ++ mp->m_sb.sb_fdblocks += tp->t_fdblocks_delta + tp->t_res_fdblocks_delta; ++ mp->m_sb.sb_icount += idelta; ++ mp->m_sb.sb_ifree += ifreedelta; + mp->m_sb.sb_frextents += rtxdelta; + mp->m_sb.sb_dblocks += tp->t_dblocks_delta; + mp->m_sb.sb_agcount += tp->t_agcount_delta; diff --git a/queue-5.10/xfs-use-current-journal_info-for-detecting-transaction-recursion.patch b/queue-5.10/xfs-use-current-journal_info-for-detecting-transaction-recursion.patch new file mode 100644 index 00000000000..83555669592 --- /dev/null +++ b/queue-5.10/xfs-use-current-journal_info-for-detecting-transaction-recursion.patch @@ -0,0 +1,256 @@ +From foo@baz Mon Jul 4 04:42:02 PM CEST 2022 +From: Amir Goldstein +Date: Sun, 3 Jul 2022 08:04:50 +0300 +Subject: xfs: use current->journal_info for detecting transaction recursion +To: Greg Kroah-Hartman +Cc: Sasha Levin , "Darrick J . Wong" , Leah Rumancik , Chandan Babu R , Luis Chamberlain , Adam Manzanares , linux-xfs@vger.kernel.org, stable@vger.kernel.org, Dave Chinner , Christoph Hellwig +Message-ID: <20220703050456.3222610-2-amir73il@gmail.com> + +From: Dave Chinner + +commit 756b1c343333a5aefcc26b0409f3fd16f72281bf upstream. + +Because the iomap code using PF_MEMALLOC_NOFS to detect transaction +recursion in XFS is just wrong. Remove it from the iomap code and +replace it with XFS specific internal checks using +current->journal_info instead. + +[djwong: This change also realigns the lifetime of NOFS flag changes to +match the incore transaction, instead of the inconsistent scheme we have +now.] + +Fixes: 9070733b4efa ("xfs: abstract PF_FSTRANS to PF_MEMALLOC_NOFS") +Signed-off-by: Dave Chinner +Reviewed-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Amir Goldstein +Acked-by: Darrick J. Wong +Signed-off-by: Greg Kroah-Hartman +--- + fs/iomap/buffered-io.c | 7 ------- + fs/xfs/libxfs/xfs_btree.c | 12 ++++++++++-- + fs/xfs/xfs_aops.c | 17 +++++++++++++++-- + fs/xfs/xfs_trans.c | 20 +++++--------------- + fs/xfs/xfs_trans.h | 30 ++++++++++++++++++++++++++++++ + 5 files changed, 60 insertions(+), 26 deletions(-) + +--- a/fs/iomap/buffered-io.c ++++ b/fs/iomap/buffered-io.c +@@ -1461,13 +1461,6 @@ iomap_do_writepage(struct page *page, st + goto redirty; + + /* +- * Given that we do not allow direct reclaim to call us, we should +- * never be called in a recursive filesystem reclaim context. +- */ +- if (WARN_ON_ONCE(current->flags & PF_MEMALLOC_NOFS)) +- goto redirty; +- +- /* + * Is this page beyond the end of the file? + * + * The page index is less than the end_index, adjust the end_offset +--- a/fs/xfs/libxfs/xfs_btree.c ++++ b/fs/xfs/libxfs/xfs_btree.c +@@ -2811,7 +2811,7 @@ xfs_btree_split_worker( + struct xfs_btree_split_args *args = container_of(work, + struct xfs_btree_split_args, work); + unsigned long pflags; +- unsigned long new_pflags = PF_MEMALLOC_NOFS; ++ unsigned long new_pflags = 0; + + /* + * we are in a transaction context here, but may also be doing work +@@ -2823,12 +2823,20 @@ xfs_btree_split_worker( + new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; + + current_set_flags_nested(&pflags, new_pflags); ++ xfs_trans_set_context(args->cur->bc_tp); + + args->result = __xfs_btree_split(args->cur, args->level, args->ptrp, + args->key, args->curp, args->stat); +- complete(args->done); + ++ xfs_trans_clear_context(args->cur->bc_tp); + current_restore_flags_nested(&pflags, new_pflags); ++ ++ /* ++ * Do not access args after complete() has run here. We don't own args ++ * and the owner may run and free args before we return here. ++ */ ++ complete(args->done); ++ + } + + /* +--- a/fs/xfs/xfs_aops.c ++++ b/fs/xfs/xfs_aops.c +@@ -62,7 +62,7 @@ xfs_setfilesize_trans_alloc( + * We hand off the transaction to the completion thread now, so + * clear the flag here. + */ +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); ++ xfs_trans_clear_context(tp); + return 0; + } + +@@ -125,7 +125,7 @@ xfs_setfilesize_ioend( + * thus we need to mark ourselves as being in a transaction manually. + * Similarly for freeze protection. + */ +- current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); ++ xfs_trans_set_context(tp); + __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS); + + /* we abort the update if there was an IO error */ +@@ -577,6 +577,12 @@ xfs_vm_writepage( + { + struct xfs_writepage_ctx wpc = { }; + ++ if (WARN_ON_ONCE(current->journal_info)) { ++ redirty_page_for_writepage(wbc, page); ++ unlock_page(page); ++ return 0; ++ } ++ + return iomap_writepage(page, wbc, &wpc.ctx, &xfs_writeback_ops); + } + +@@ -587,6 +593,13 @@ xfs_vm_writepages( + { + struct xfs_writepage_ctx wpc = { }; + ++ /* ++ * Writing back data in a transaction context can result in recursive ++ * transactions. This is bad, so issue a warning and get out of here. ++ */ ++ if (WARN_ON_ONCE(current->journal_info)) ++ return 0; ++ + xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); + return iomap_writepages(mapping, wbc, &wpc.ctx, &xfs_writeback_ops); + } +--- a/fs/xfs/xfs_trans.c ++++ b/fs/xfs/xfs_trans.c +@@ -68,6 +68,7 @@ xfs_trans_free( + xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false); + + trace_xfs_trans_free(tp, _RET_IP_); ++ xfs_trans_clear_context(tp); + if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) + sb_end_intwrite(tp->t_mountp->m_super); + xfs_trans_free_dqinfo(tp); +@@ -119,7 +120,8 @@ xfs_trans_dup( + + ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; + tp->t_rtx_res = tp->t_rtx_res_used; +- ntp->t_pflags = tp->t_pflags; ++ ++ xfs_trans_switch_context(tp, ntp); + + /* move deferred ops over to the new tp */ + xfs_defer_move(ntp, tp); +@@ -153,9 +155,6 @@ xfs_trans_reserve( + int error = 0; + bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; + +- /* Mark this thread as being in a transaction */ +- current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); +- + /* + * Attempt to reserve the needed disk blocks by decrementing + * the number needed from the number available. This will +@@ -163,10 +162,8 @@ xfs_trans_reserve( + */ + if (blocks > 0) { + error = xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd); +- if (error != 0) { +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); ++ if (error != 0) + return -ENOSPC; +- } + tp->t_blk_res += blocks; + } + +@@ -240,9 +237,6 @@ undo_blocks: + xfs_mod_fdblocks(mp, (int64_t)blocks, rsvd); + tp->t_blk_res = 0; + } +- +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); +- + return error; + } + +@@ -266,6 +260,7 @@ xfs_trans_alloc( + tp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL); + if (!(flags & XFS_TRANS_NO_WRITECOUNT)) + sb_start_intwrite(mp->m_super); ++ xfs_trans_set_context(tp); + + /* + * Zero-reservation ("empty") transactions can't modify anything, so +@@ -878,7 +873,6 @@ __xfs_trans_commit( + + xfs_log_commit_cil(mp, tp, &commit_lsn, regrant); + +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + xfs_trans_free(tp); + + /* +@@ -910,7 +904,6 @@ out_unreserve: + xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); + tp->t_ticket = NULL; + } +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); + xfs_trans_free_items(tp, !!error); + xfs_trans_free(tp); + +@@ -970,9 +963,6 @@ xfs_trans_cancel( + tp->t_ticket = NULL; + } + +- /* mark this thread as no longer being in a transaction */ +- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); +- + xfs_trans_free_items(tp, dirty); + xfs_trans_free(tp); + } +--- a/fs/xfs/xfs_trans.h ++++ b/fs/xfs/xfs_trans.h +@@ -268,4 +268,34 @@ xfs_trans_item_relog( + return lip->li_ops->iop_relog(lip, tp); + } + ++static inline void ++xfs_trans_set_context( ++ struct xfs_trans *tp) ++{ ++ ASSERT(current->journal_info == NULL); ++ tp->t_pflags = memalloc_nofs_save(); ++ current->journal_info = tp; ++} ++ ++static inline void ++xfs_trans_clear_context( ++ struct xfs_trans *tp) ++{ ++ if (current->journal_info == tp) { ++ memalloc_nofs_restore(tp->t_pflags); ++ current->journal_info = NULL; ++ } ++} ++ ++static inline void ++xfs_trans_switch_context( ++ struct xfs_trans *old_tp, ++ struct xfs_trans *new_tp) ++{ ++ ASSERT(current->journal_info == old_tp); ++ new_tp->t_pflags = old_tp->t_pflags; ++ old_tp->t_pflags = 0; ++ current->journal_info = new_tp; ++} ++ + #endif /* __XFS_TRANS_H__ */