Kernel doesn't support to drop extent inside an inlined extent. And kernel tends to limit inline extent just below sectorsize, so also limit it in btrfs-progs.
This fixes unexpected -EOPNOTSUPP error from __btrfs_drop_extents() on converted btrfs. Fixes: 806528b8755f ("Add Yan Zheng's ext3->btrfs conversion program") Reported-by: Peter Y. Chuang <peteryuchu...@gmail.com> Signed-off-by: Qu Wenruo <w...@suse.com> --- ctree.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ctree.h b/ctree.h index 17cdac76c58c..0282deef339b 100644 --- a/ctree.h +++ b/ctree.h @@ -20,6 +20,7 @@ #define __BTRFS_CTREE_H__ #include <stdbool.h> +#include "internal.h" #if BTRFS_FLAT_INCLUDES #include "list.h" @@ -1195,8 +1196,14 @@ static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info) (offsetof(struct btrfs_file_extent_item, disk_bytenr)) static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) { - return BTRFS_MAX_ITEM_SIZE(info) - - BTRFS_FILE_EXTENT_INLINE_DATA_START; + /* + * Inline extent larger than pagesize could lead to kernel unexpected + * error when dropping extents, so we need to limit the inline extent + * size to less than sectorsize. + */ + return min_t(u32, info->sectorsize - 1, + BTRFS_MAX_ITEM_SIZE(info) - + BTRFS_FILE_EXTENT_INLINE_DATA_START); } static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html