f2fs: flush error flags in workqueue
Commit Message
In IRQ context, it wakes up workqueue to record errors into on-disk
superblock fields rather than in-memory fields.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/compress.c | 2 +-
fs/f2fs/f2fs.h | 1 +
fs/f2fs/super.c | 26 +++++++++++++++++++++++---
3 files changed, 25 insertions(+), 4 deletions(-)
Comments
Hi Chao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jaegeuk-f2fs/dev-test]
[cannot apply to jaegeuk-f2fs/dev linus/master v6.4-rc2 next-20230516]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link: https://lore.kernel.org/r/20230516072755.3138097-1-chao%40kernel.org
patch subject: [PATCH] f2fs: flush error flags in workqueue
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/874c7ca40fa37e2697f9d2ac271147c5cafdddaa
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
git checkout 874c7ca40fa37e2697f9d2ac271147c5cafdddaa
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash fs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305161802.YzwZE7UE-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/f2fs/super.c:4027:6: warning: no previous prototype for 'f2fs_record_errors' [-Wmissing-prototypes]
4027 | void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
| ^~~~~~~~~~~~~~~~~~
vim +/f2fs_record_errors +4027 fs/f2fs/super.c
4026
> 4027 void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
4028 {
4029 int err;
4030
4031 f2fs_down_write(&sbi->sb_lock);
4032
4033 if (!f2fs_update_errors(sbi))
4034 goto out_unlock;
4035
4036 err = f2fs_commit_super(sbi, false);
4037 if (err)
4038 f2fs_err(sbi, "f2fs_commit_super fails to record errors:%u, err:%d",
4039 error, err);
4040 out_unlock:
4041 f2fs_up_write(&sbi->sb_lock);
4042 }
4043
Hi Chao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jaegeuk-f2fs/dev-test]
[cannot apply to jaegeuk-f2fs/dev linus/master v6.4-rc2 next-20230516]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link: https://lore.kernel.org/r/20230516072755.3138097-1-chao%40kernel.org
patch subject: [PATCH] f2fs: flush error flags in workqueue
config: hexagon-randconfig-r041-20230515
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/874c7ca40fa37e2697f9d2ac271147c5cafdddaa
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
git checkout 874c7ca40fa37e2697f9d2ac271147c5cafdddaa
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash fs/f2fs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305161822.PYax3mhx-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from fs/f2fs/super.c:14:
In file included from include/linux/buffer_head.h:12:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:334:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from fs/f2fs/super.c:14:
In file included from include/linux/buffer_head.h:12:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:334:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from fs/f2fs/super.c:14:
In file included from include/linux/buffer_head.h:12:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:334:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
>> fs/f2fs/super.c:4027:6: warning: no previous prototype for function 'f2fs_record_errors' [-Wmissing-prototypes]
void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
^
fs/f2fs/super.c:4027:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
^
static
7 warnings generated.
vim +/f2fs_record_errors +4027 fs/f2fs/super.c
4026
> 4027 void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
4028 {
4029 int err;
4030
4031 f2fs_down_write(&sbi->sb_lock);
4032
4033 if (!f2fs_update_errors(sbi))
4034 goto out_unlock;
4035
4036 err = f2fs_commit_super(sbi, false);
4037 if (err)
4038 f2fs_err(sbi, "f2fs_commit_super fails to record errors:%u, err:%d",
4039 error, err);
4040 out_unlock:
4041 f2fs_up_write(&sbi->sb_lock);
4042 }
4043
Hi Chao,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jaegeuk-f2fs/dev-test]
[cannot apply to jaegeuk-f2fs/dev linus/master v6.4-rc2 next-20230516]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link: https://lore.kernel.org/r/20230516072755.3138097-1-chao%40kernel.org
patch subject: [PATCH] f2fs: flush error flags in workqueue
config: x86_64-randconfig-s023-20230515
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/874c7ca40fa37e2697f9d2ac271147c5cafdddaa
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chao-Yu/f2fs-flush-error-flags-in-workqueue/20230516-152832
git checkout 874c7ca40fa37e2697f9d2ac271147c5cafdddaa
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 olddefconfig
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/f2fs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305161932.wKgJW993-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
fs/f2fs/super.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/f2fs.h):
include/trace/events/f2fs.h:1035:1: sparse: sparse: cast to restricted blk_opf_t
include/trace/events/f2fs.h:1035:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1035:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1035:1: sparse: sparse: cast to restricted blk_opf_t
include/trace/events/f2fs.h:1035:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1035:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1094:1: sparse: sparse: cast to restricted blk_opf_t
include/trace/events/f2fs.h:1094:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1094:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1094:1: sparse: sparse: cast to restricted blk_opf_t
include/trace/events/f2fs.h:1094:1: sparse: sparse: restricted blk_opf_t degrades to integer
include/trace/events/f2fs.h:1094:1: sparse: sparse: restricted blk_opf_t degrades to integer
>> fs/f2fs/super.c:4027:6: sparse: sparse: symbol 'f2fs_record_errors' was not declared. Should it be static?
fs/f2fs/super.c:1454:35: sparse: sparse: context imbalance in 'f2fs_drop_inode' - unexpected unlock
@@ -744,7 +744,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
/* Avoid f2fs_commit_super in irq context */
if (!in_task)
- f2fs_save_errors(sbi, ERROR_FAIL_DECOMPRESSION);
+ f2fs_handle_error_async(sbi, ERROR_FAIL_DECOMPRESSION);
else
f2fs_handle_error(sbi, ERROR_FAIL_DECOMPRESSION);
goto out_release;
@@ -3563,6 +3563,7 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag);
void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason,
bool irq_context);
void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error);
+void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error);
int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
int f2fs_sync_fs(struct super_block *sb, int sync);
int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi);
@@ -3989,6 +3989,11 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
f2fs_down_write(&sbi->sb_lock);
spin_lock_irqsave(&sbi->error_lock, flags);
+ if (sbi->error_dirty) {
+ memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors,
+ MAX_F2FS_ERRORS);
+ sbi->error_dirty = false;
+ }
memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
spin_unlock_irqrestore(&sbi->error_lock, flags);
@@ -4028,12 +4033,10 @@ static bool f2fs_update_errors(struct f2fs_sb_info *sbi)
return need_update;
}
-void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
+void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error)
{
int err;
- f2fs_save_errors(sbi, error);
-
f2fs_down_write(&sbi->sb_lock);
if (!f2fs_update_errors(sbi))
@@ -4047,6 +4050,23 @@ void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
f2fs_up_write(&sbi->sb_lock);
}
+void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)
+{
+ f2fs_save_errors(sbi, error);
+ f2fs_record_errors(sbi, error);
+}
+
+void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error)
+{
+ f2fs_save_errors(sbi, error);
+
+ if (!sbi->error_dirty)
+ return;
+ if (!test_bit(error, (unsigned long *)sbi->errors))
+ return;
+ schedule_work(&sbi->s_error_work);
+}
+
static bool system_going_down(void)
{
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF