Btrfs: disable online scrub repair on ro cases
diff mbox

Message ID 1449190558-11205-1-git-send-email-bo.li.liu@oracle.com
State New
Headers show

Commit Message

Liu Bo Dec. 4, 2015, 12:55 a.m. UTC
This disables repair process on ro cases as it can cause system
to be unresponsive on the ASSERT() in repair_io_failure().

This can happen when scrub is running and a hardware error pops up,
we should fallback to ro mounts gracefully instead of being unresponsive.

Reported-by: Codebird <codebird@birds-are-nice.me>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/scrub.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

kbuild test robot Dec. 4, 2015, 1:22 p.m. UTC | #1
Hi Liu,

[auto build test ERROR on btrfs/next]
[also build test ERROR on v4.4-rc3 next-20151203]

url:    https://github.com/0day-ci/linux/commits/Liu-Bo/Btrfs-disable-online-scrub-repair-on-ro-cases/20151204-205115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git next
config: powerpc-defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   fs/btrfs/scrub.c: In function 'scrub_fixup_readpage':
>> fs/btrfs/scrub.c:703:10: error: invalid type argument of '->' (have 'u64 {aka long long unsigned int}')
     if (root->fs_info->sb->s_flags & MS_RDONLY)
             ^

vim +703 fs/btrfs/scrub.c

   697		struct inode *inode = NULL;
   698		struct btrfs_fs_info *fs_info;
   699		u64 end = offset + PAGE_SIZE - 1;
   700		struct btrfs_root *local_root;
   701		int srcu_index;
   702	
 > 703		if (root->fs_info->sb->s_flags & MS_RDONLY)
   704			return -EROFS;
   705	
   706		key.objectid = root;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kbuild test robot Dec. 4, 2015, 1:35 p.m. UTC | #2
Hi Liu,

[auto build test WARNING on btrfs/next]
[also build test WARNING on v4.4-rc3 next-20151203]

url:    https://github.com/0day-ci/linux/commits/Liu-Bo/Btrfs-disable-online-scrub-repair-on-ro-cases/20151204-205115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs.git next
config: i386-randconfig-c0-12042053 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/uapi/linux/capability.h:16,
                    from include/linux/capability.h:15,
                    from include/linux/sched.h:15,
                    from include/linux/blkdev.h:4,
                    from fs/btrfs/scrub.c:19:
   fs/btrfs/scrub.c: In function 'scrub_fixup_readpage':
   fs/btrfs/scrub.c:703:10: error: invalid type argument of '->' (have 'u64 {aka long long unsigned int}')
     if (root->fs_info->sb->s_flags & MS_RDONLY)
             ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
     if (__builtin_constant_p((cond)) ? !!(cond) :   \
                               ^
>> fs/btrfs/scrub.c:703:2: note: in expansion of macro 'if'
     if (root->fs_info->sb->s_flags & MS_RDONLY)
     ^
   fs/btrfs/scrub.c:703:10: error: invalid type argument of '->' (have 'u64 {aka long long unsigned int}')
     if (root->fs_info->sb->s_flags & MS_RDONLY)
             ^
   include/linux/compiler.h:147:40: note: in definition of macro '__trace_if'
     if (__builtin_constant_p((cond)) ? !!(cond) :   \
                                           ^
>> fs/btrfs/scrub.c:703:2: note: in expansion of macro 'if'
     if (root->fs_info->sb->s_flags & MS_RDONLY)
     ^
   fs/btrfs/scrub.c:703:10: error: invalid type argument of '->' (have 'u64 {aka long long unsigned int}')
     if (root->fs_info->sb->s_flags & MS_RDONLY)
             ^
   include/linux/compiler.h:158:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^
>> fs/btrfs/scrub.c:703:2: note: in expansion of macro 'if'
     if (root->fs_info->sb->s_flags & MS_RDONLY)
     ^

vim +/if +703 fs/btrfs/scrub.c

   687	}
   688	
   689	static int scrub_fixup_readpage(u64 inum, u64 offset, u64 root, void *fixup_ctx)
   690	{
   691		struct page *page = NULL;
   692		unsigned long index;
   693		struct scrub_fixup_nodatasum *fixup = fixup_ctx;
   694		int ret;
   695		int corrected = 0;
   696		struct btrfs_key key;
   697		struct inode *inode = NULL;
   698		struct btrfs_fs_info *fs_info;
   699		u64 end = offset + PAGE_SIZE - 1;
   700		struct btrfs_root *local_root;
   701		int srcu_index;
   702	
 > 703		if (root->fs_info->sb->s_flags & MS_RDONLY)
   704			return -EROFS;
   705	
   706		key.objectid = root;
   707		key.type = BTRFS_ROOT_ITEM_KEY;
   708		key.offset = (u64)-1;
   709	
   710		fs_info = fixup->root->fs_info;
   711		srcu_index = srcu_read_lock(&fs_info->subvol_srcu);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Patch
diff mbox

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 2907a77..d6dd2f5 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -682,6 +682,9 @@  static int scrub_fixup_readpage(u64 inum, u64 offset, u64 root, void *fixup_ctx)
 	struct btrfs_root *local_root;
 	int srcu_index;
 
+	if (root->fs_info->sb->s_flags & MS_RDONLY)
+		return -EROFS;
+
 	key.objectid = root;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;