btrfs-progs/convert
Qu Wenruo e02049d964 btrfs-progs: convert: Fix inline file extent creation condition
[Bug]
On btrfs converted from ext*, one user reported the following kernel
warning:
 ------------[ cut here ]------------
 BTRFS: Transaction aborted (error -95)
 WARNING: CPU: 0 PID: 324 at fs/btrfs/inode.c:3042 btrfs_finish_ordered_io+0x7ab/0x850 [btrfs]
 Workqueue: btrfs-endio-write btrfs_endio_write_helper [btrfs]
 RIP: 0010:btrfs_finish_ordered_io+0x7ab/0x850 [btrfs]
 ...
 Call Trace:
  normal_work_helper+0x39/0x370 [btrfs]
  process_one_work+0x1ce/0x410
  worker_thread+0x2b/0x3d0
  ? process_one_work+0x410/0x410
  kthread+0x113/0x130
  ? kthread_create_on_node+0x70/0x70
  ? do_syscall_64+0x74/0x190
  ? SyS_exit_group+0x10/0x10
  ret_from_fork+0x35/0x40
 ---[ end trace c8ed62ff6a525901 ]---
 BTRFS: error (device dm-2) in
btrfs_finish_ordered_io:3042: errno=-95 unknown
 BTRFS info (device dm-2): forced readonly
 BTRFS error (device dm-2): pending csums is 6447104

[Cause]
The call trace and the unique return value points to
__btrfs_drop_extents(), when we tries to drop pages of an inline extent,
we will trigger such -EOPNOTSUPP.

However kernel has limitation on the size of inline file extent
(sector size for ram size and sector size - 1 for on-disk size),
btrfs-convert doesn't have the same limitation, resulting much larger
file extent.

The lack of correct inline extent size check dates back to 2008 when
btrfs-convert is added into btrfs-progs.

[Fix]
Fix the inline extent creation condition, not only using
BTRFS_MAX_INLINE_DATA_SIZE(), which is only the maximum size of inline
data according to nodesize, but also limit it against sector size.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:54 +02:00
..
Makefile btrfs-progs: build: add stub makefile to convert 2017-03-08 13:00:46 +01:00
common.c btrfs-progs: Remove deprecated leafsize usage 2017-07-03 13:35:10 +02:00
common.h btrfs-progs: convert: widen int types in convert context 2017-06-26 17:09:53 +02:00
main.c btrfs-progs: Remove unnecessary parameter for btrfs_add_block_group 2018-01-31 15:14:03 +01:00
source-ext2.c btrfs-progs: convert: Fix inline file extent creation condition 2018-03-30 22:15:54 +02:00
source-ext2.h btrfs-progs: convert: move duplicated acl code to common header 2017-09-08 16:15:05 +02:00
source-fs.c btrfs-progs: convert: move and rename dev_t helpers to common file 2017-09-08 16:15:05 +02:00
source-fs.h btrfs-progs: convert: fix build on musl 2018-02-03 01:06:21 +01:00
source-reiserfs.c btrfs-progs: convert: Fix inline file extent creation condition 2018-03-30 22:15:54 +02:00
source-reiserfs.h btrfs-progs: convert: move reiserfs struct definitions to header 2017-09-08 16:15:05 +02:00