]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 06:34:20 +0000 (08:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 06:34:20 +0000 (08:34 +0200)
added patches:
f2fs-fix-to-do-sanity-check-on-extent-cache-correctly.patch
f2fs-inode-fix-to-do-sanity-check-on-extent-cache-correctly.patch

queue-6.1/f2fs-fix-to-do-sanity-check-on-extent-cache-correctly.patch [new file with mode: 0644]
queue-6.1/f2fs-inode-fix-to-do-sanity-check-on-extent-cache-correctly.patch [new file with mode: 0644]
queue-6.1/series

diff --git a/queue-6.1/f2fs-fix-to-do-sanity-check-on-extent-cache-correctly.patch b/queue-6.1/f2fs-fix-to-do-sanity-check-on-extent-cache-correctly.patch
new file mode 100644 (file)
index 0000000..46a1a97
--- /dev/null
@@ -0,0 +1,48 @@
+From d48a7b3a72f121655d95b5157c32c7d555e44c05 Mon Sep 17 00:00:00 2001
+From: Chao Yu <chao@kernel.org>
+Date: Mon, 9 Jan 2023 11:49:20 +0800
+Subject: f2fs: fix to do sanity check on extent cache correctly
+
+From: Chao Yu <chao@kernel.org>
+
+commit d48a7b3a72f121655d95b5157c32c7d555e44c05 upstream.
+
+In do_read_inode(), sanity_check_inode() should be called after
+f2fs_init_read_extent_tree(), fix it.
+
+Fixes: 72840cccc0a1 ("f2fs: allocate the extent_cache by default")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/f2fs/inode.c |   12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/fs/f2fs/inode.c
++++ b/fs/f2fs/inode.c
+@@ -413,12 +413,6 @@ static int do_read_inode(struct inode *i
+               fi->i_inline_xattr_size = 0;
+       }
+-      if (!sanity_check_inode(inode, node_page)) {
+-              f2fs_put_page(node_page, 1);
+-              f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
+-              return -EFSCORRUPTED;
+-      }
+-
+       /* check data exist */
+       if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode))
+               __recover_inline_status(inode, node_page);
+@@ -481,6 +475,12 @@ static int do_read_inode(struct inode *i
+       /* Need all the flag bits */
+       f2fs_init_read_extent_tree(inode, node_page);
++      if (!sanity_check_inode(inode, node_page)) {
++              f2fs_put_page(node_page, 1);
++              f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
++              return -EFSCORRUPTED;
++      }
++
+       f2fs_put_page(node_page, 1);
+       stat_inc_inline_xattr(inode);
diff --git a/queue-6.1/f2fs-inode-fix-to-do-sanity-check-on-extent-cache-correctly.patch b/queue-6.1/f2fs-inode-fix-to-do-sanity-check-on-extent-cache-correctly.patch
new file mode 100644 (file)
index 0000000..c62fd62
--- /dev/null
@@ -0,0 +1,104 @@
+From 269d119481008cd725ce32553332593c0ecfc91c Mon Sep 17 00:00:00 2001
+From: Chao Yu <chao@kernel.org>
+Date: Tue, 7 Feb 2023 21:48:08 +0800
+Subject: f2fs: inode: fix to do sanity check on extent cache correctly
+
+From: Chao Yu <chao@kernel.org>
+
+commit 269d119481008cd725ce32553332593c0ecfc91c upstream.
+
+In do_read_inode(), sanity check for extent cache should be called after
+f2fs_init_read_extent_tree(), fix it.
+
+Fixes: 72840cccc0a1 ("f2fs: allocate the extent_cache by default")
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/f2fs/extent_cache.c |   25 +++++++++++++++++++++++++
+ fs/f2fs/f2fs.h         |    1 +
+ fs/f2fs/inode.c        |   22 ++++++----------------
+ 3 files changed, 32 insertions(+), 16 deletions(-)
+
+--- a/fs/f2fs/extent_cache.c
++++ b/fs/f2fs/extent_cache.c
+@@ -15,6 +15,31 @@
+ #include "node.h"
+ #include <trace/events/f2fs.h>
++bool sanity_check_extent_cache(struct inode *inode)
++{
++      struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
++      struct f2fs_inode_info *fi = F2FS_I(inode);
++      struct extent_info *ei;
++
++      if (!fi->extent_tree[EX_READ])
++              return true;
++
++      ei = &fi->extent_tree[EX_READ]->largest;
++
++      if (ei->len &&
++              (!f2fs_is_valid_blkaddr(sbi, ei->blk,
++                                      DATA_GENERIC_ENHANCE) ||
++              !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
++                                      DATA_GENERIC_ENHANCE))) {
++              set_sbi_flag(sbi, SBI_NEED_FSCK);
++              f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
++                        __func__, inode->i_ino,
++                        ei->blk, ei->fofs, ei->len);
++              return false;
++      }
++      return true;
++}
++
+ static void __set_extent_info(struct extent_info *ei,
+                               unsigned int fofs, unsigned int len,
+                               block_t blk, bool keep_clen,
+--- a/fs/f2fs/f2fs.h
++++ b/fs/f2fs/f2fs.h
+@@ -4125,6 +4125,7 @@ void f2fs_leave_shrinker(struct f2fs_sb_
+ /*
+  * extent_cache.c
+  */
++bool sanity_check_extent_cache(struct inode *inode);
+ struct rb_entry *f2fs_lookup_rb_tree(struct rb_root_cached *root,
+                               struct rb_entry *cached_re, unsigned int ofs);
+ struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
+--- a/fs/f2fs/inode.c
++++ b/fs/f2fs/inode.c
+@@ -262,22 +262,6 @@ static bool sanity_check_inode(struct in
+               return false;
+       }
+-      if (fi->extent_tree[EX_READ]) {
+-              struct extent_info *ei = &fi->extent_tree[EX_READ]->largest;
+-
+-              if (ei->len &&
+-                      (!f2fs_is_valid_blkaddr(sbi, ei->blk,
+-                                              DATA_GENERIC_ENHANCE) ||
+-                      !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
+-                                              DATA_GENERIC_ENHANCE))) {
+-                      set_sbi_flag(sbi, SBI_NEED_FSCK);
+-                      f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
+-                                __func__, inode->i_ino,
+-                                ei->blk, ei->fofs, ei->len);
+-                      return false;
+-              }
+-      }
+-
+       if (f2fs_sanity_check_inline_data(inode)) {
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               f2fs_warn(sbi, "%s: inode (ino=%lx, mode=%u) should not have inline_data, run fsck to fix",
+@@ -479,6 +463,12 @@ static int do_read_inode(struct inode *i
+               f2fs_put_page(node_page, 1);
+               f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
+               return -EFSCORRUPTED;
++      }
++
++      if (!sanity_check_extent_cache(inode)) {
++              f2fs_put_page(node_page, 1);
++              f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE);
++              return -EFSCORRUPTED;
+       }
+       f2fs_put_page(node_page, 1);
index 6cc452c0e70a37f158606fb401a50b8f62be4197..552381db959f147ac7ce6766a62a9eba0e740834 100644 (file)
@@ -230,3 +230,5 @@ ext4-fix-lockdep-warning-when-enabling-mmp.patch
 ext4-remove-a-bug_on-in-ext4_mb_release_group_pa.patch
 ext4-fix-invalid-free-tracking-in-ext4_xattr_move_to_block.patch
 drm-dsc-fix-dp_dsc_max_bpp_delta_-macro-values.patch
+f2fs-fix-to-do-sanity-check-on-extent-cache-correctly.patch
+f2fs-inode-fix-to-do-sanity-check-on-extent-cache-correctly.patch