From patchwork Fri Dec 22 04:20:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 10128787 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 F08E86019D for ; Fri, 22 Dec 2017 04:21:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E250A28842 for ; Fri, 22 Dec 2017 04:21:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D69ED28DD1; Fri, 22 Dec 2017 04:21:27 +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 5C71028BF4 for ; Fri, 22 Dec 2017 04:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755386AbdLVEV0 convert rfc822-to-8bit (ORCPT ); Thu, 21 Dec 2017 23:21:26 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:43606 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755152AbdLVEVZ (ORCPT ); Thu, 21 Dec 2017 23:21:25 -0500 Received: from dggemi406-hub.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 8DC6BF2404688; Fri, 22 Dec 2017 12:21:22 +0800 (CST) Received: from DGGEMI424-HUB.china.huawei.com (10.1.199.153) by dggemi406-hub.china.huawei.com (10.3.17.144) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 22 Dec 2017 12:21:06 +0800 Received: from DGGEMI505-MBS.china.huawei.com ([169.254.2.37]) by DGGEMI424-HUB.china.huawei.com ([10.1.199.153]) with mapi id 14.03.0361.001; Fri, 22 Dec 2017 12:20:58 +0800 From: "Gaoxiang (OS)" To: Jaegeuk Kim , "chao@kernel.org" , "Yuchao (T)" CC: "linux-f2fs-devel@lists.sourceforge.net" , "linux-fsdevel@vger.kernel.org" , "Duwei (Device OS)" Subject: [f2fs-dev] [PATCH v2] resize.f2fs: fix max_nat_bitmap_size miscalculatation Thread-Topic: [f2fs-dev] [PATCH v2] resize.f2fs: fix max_nat_bitmap_size miscalculatation Thread-Index: AdN629SFlgvGwLXhSC2XFxfYFbdV9g== Date: Fri, 22 Dec 2017 04:20:58 +0000 Message-ID: <9047C53C18267742AB12E43B65C7F9F70BCB8BD4@dggemi505-mbs.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-imapappendstamp: dggemi304-cas.china.huawei.com (14.03.0336.000) x-originating-ip: [10.151.23.176] MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For the same reason as "mkfs.f2fs: fix to calculate left space of checkpoint page correctly", this patch also fixes miscalculatation in resize.f2fs. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu --- fsck/resize.c | 3 +-- include/f2fs_fs.h | 3 +++ mkfs/f2fs_format.c | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fsck/resize.c b/fsck/resize.c index 6c3eeab..143ad5d 100644 --- a/fsck/resize.c +++ b/fsck/resize.c @@ -60,8 +60,7 @@ static int get_new_sb(struct f2fs_super_block *sb) * It should be reserved minimum 1 segment for nat. * When sit is too large, we should expand cp area. It requires more pages for cp. */ - if (max_sit_bitmap_size > - (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 65)) { + if (max_sit_bitmap_size > MAX_SIT_BITMAP_SIZE_IN_CKPT) { max_nat_bitmap_size = CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1; set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size)); } else { diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index d8d199f..d429a6f 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -651,6 +651,9 @@ struct f2fs_checkpoint { unsigned char sit_nat_version_bitmap[1]; } __attribute__((packed)); +#define MAX_SIT_BITMAP_SIZE_IN_CKPT \ + (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64) + /* * For orphan inode management */ diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 583b17f..a130001 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -291,9 +291,7 @@ static int f2fs_prepare_super_block(void) * When sit is too large, we should expand cp area. It requires more * pages for cp. */ - if (max_sit_bitmap_size > - (CHECKSUM_OFFSET - - sizeof(struct f2fs_checkpoint) + 1 - 64)) { + if (max_sit_bitmap_size > MAX_SIT_BITMAP_SIZE_IN_CKPT) { max_nat_bitmap_size = CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1; set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size));