From patchwork Thu Mar 1 02:47:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10250273 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 BC47060365 for ; Thu, 1 Mar 2018 02:48:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABCA728A87 for ; Thu, 1 Mar 2018 02:48:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A053128ADA; Thu, 1 Mar 2018 02:48:09 +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 45A5528A87 for ; Thu, 1 Mar 2018 02:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965515AbeCACsH (ORCPT ); Wed, 28 Feb 2018 21:48:07 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:34360 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965488AbeCACsB (ORCPT ); Wed, 28 Feb 2018 21:48:01 -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:56 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, peteryuchuang@gmail.com Subject: [PATCH 2/4] btrfs-progs: check/original mode: Check inline extent size Date: Thu, 1 Mar 2018 10:47:45 +0800 Message-Id: <20180301024747.26192-3-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 allow inline extent equal or larger than 4K. And for inline extent larger than 4K, __btrfs_drop_extents() can return -EOPNOTSUPP and cause unexpected error. Check it in original mode. Signed-off-by: Qu Wenruo Reviewed-by: Su Yue --- check/main.c | 4 ++++ check/mode-original.h | 1 + 2 files changed, 5 insertions(+) diff --git a/check/main.c b/check/main.c index 97baae583f04..ce41550ab16a 100644 --- a/check/main.c +++ b/check/main.c @@ -560,6 +560,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec) fprintf(stderr, ", bad file extent"); if (errors & I_ERR_FILE_EXTENT_OVERLAP) fprintf(stderr, ", file extent overlap"); + if (errors & I_ERR_FILE_EXTENT_TOO_LARGE) + fprintf(stderr, ", inline file extent too large"); if (errors & I_ERR_FILE_EXTENT_DISCOUNT) fprintf(stderr, ", file extent discount"); if (errors & I_ERR_DIR_ISIZE_WRONG) @@ -1461,6 +1463,8 @@ static int process_file_extent(struct btrfs_root *root, num_bytes = btrfs_file_extent_inline_len(eb, slot, fi); if (num_bytes == 0) rec->errors |= I_ERR_BAD_FILE_EXTENT; + if (num_bytes > BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) + rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE; rec->found_size += num_bytes; num_bytes = (num_bytes + mask) & ~mask; } else if (extent_type == BTRFS_FILE_EXTENT_REG || diff --git a/check/mode-original.h b/check/mode-original.h index f859af478f0f..368de692fdd1 100644 --- a/check/mode-original.h +++ b/check/mode-original.h @@ -185,6 +185,7 @@ struct file_extent_hole { #define I_ERR_SOME_CSUM_MISSING (1 << 12) #define I_ERR_LINK_COUNT_WRONG (1 << 13) #define I_ERR_FILE_EXTENT_ORPHAN (1 << 14) +#define I_ERR_FILE_EXTENT_TOO_LARGE (1 << 15) struct inode_record { struct list_head backrefs;