From patchwork Thu Mar 1 02:47:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10250271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0CBDF60365 for ; Thu, 1 Mar 2018 02:48:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E28F128A87 for ; Thu, 1 Mar 2018 02:48:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D735A28AB0; Thu, 1 Mar 2018 02:48:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67D1228A87 for ; Thu, 1 Mar 2018 02:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965498AbeCACsC (ORCPT ); Wed, 28 Feb 2018 21:48:02 -0500 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:50445 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965487AbeCACsA (ORCPT ); Wed, 28 Feb 2018 21:48:00 -0500 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Wed, 28 Feb 2018 19:47:54 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, peteryuchuang@gmail.com Subject: [PATCH 1/4] btrfs-progs: Limit inline extent below page size Date: Thu, 1 Mar 2018 10:47:44 +0800 Message-Id: <20180301024747.26192-2-wqu@suse.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301024747.26192-1-wqu@suse.com> References: <20180301024747.26192-1-wqu@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Qu Wenruo --- 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 +#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)