From patchwork Tue Mar 13 01:56:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10277715 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 52F36603B5 for ; Tue, 13 Mar 2018 01:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3596A28EE1 for ; Tue, 13 Mar 2018 01:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A28128EE5; Tue, 13 Mar 2018 01:56:46 +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 B44EE28EE1 for ; Tue, 13 Mar 2018 01:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932434AbeCMB4n (ORCPT ); Mon, 12 Mar 2018 21:56:43 -0400 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:38247 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932242AbeCMB43 (ORCPT ); Mon, 12 Mar 2018 21:56:29 -0400 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); Mon, 12 Mar 2018 19:56:23 -0600 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v2 3/7] btrfs-progs: mkfs/rootdir: Fix inline extent creation check Date: Tue, 13 Mar 2018 09:56:12 +0800 Message-Id: <20180313015616.6574-4-wqu@suse.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313015616.6574-1-wqu@suse.com> References: <20180313015616.6574-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 Just like convert, we need extra check against sector size for creating inline extent. Signed-off-by: Qu Wenruo --- mkfs/rootdir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index e06b65ac13e4..a1d223a2408a 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -139,7 +139,8 @@ static int fill_inode_item(struct btrfs_trans_handle *trans, } if (S_ISREG(src->st_mode)) { btrfs_set_stack_inode_size(dst, (u64)src->st_size); - if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) + if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) && + src->st_size < sectorsize) btrfs_set_stack_inode_nbytes(dst, src->st_size); else { blocks = src->st_size / sectorsize; @@ -327,7 +328,8 @@ static int add_file_items(struct btrfs_trans_handle *trans, if (st->st_size % sectorsize) blocks += 1; - if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) { + if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) && + st->st_size < sectorsize) { char *buffer = malloc(st->st_size); if (!buffer) {