From patchwork Fri Feb 24 10:06:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunlong Song X-Patchwork-Id: 9589807 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 24F01601AE for ; Fri, 24 Feb 2017 09:59:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14E56287AF for ; Fri, 24 Feb 2017 09:59:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 098DB287B3; Fri, 24 Feb 2017 09:59:14 +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 E7B70287AF for ; Fri, 24 Feb 2017 09:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751282AbdBXJ7L (ORCPT ); Fri, 24 Feb 2017 04:59:11 -0500 Received: from szxga02-in.huawei.com ([45.249.212.188]:2897 "EHLO dggrg02-dlp.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751173AbdBXJ7K (ORCPT ); Fri, 24 Feb 2017 04:59:10 -0500 Received: from 172.30.72.54 (EHLO DGGEMM404-HUB.china.huawei.com) ([172.30.72.54]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AIY41739; Fri, 24 Feb 2017 17:54:08 +0800 (CST) Received: from DGGEML401-HUB.china.huawei.com (10.3.17.32) by DGGEMM404-HUB.china.huawei.com (10.3.20.212) with Microsoft SMTP Server (TLS) id 14.3.301.0; Fri, 24 Feb 2017 17:54:07 +0800 Received: from s00293685.huawei.com (10.108.111.190) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Fri, 24 Feb 2017 17:53:52 +0800 From: Yunlong Song To: , , , , , , CC: , , , Subject: [PATCH] f2fs: change the codes of checking CP_CRC_RECOVERY_FLAG to macro Date: Fri, 24 Feb 2017 18:06:11 +0800 Message-ID: <1487930771-14491-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 X-Originating-IP: [10.108.111.190] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0206.58B002C1.01F1, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 4b710f353ee1a4ae2e087b224d578c51 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 No need to check the "if" condition each time, just change it to macro codes. Signed-off-by: Yunlong Song --- fs/f2fs/node.h | 20 ++++++++++---------- fs/f2fs/segment.c | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index 3fc9c4b..3e5a58b 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h @@ -303,11 +303,11 @@ static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr) size_t crc_offset = le32_to_cpu(ckpt->checksum_offset); __u64 cp_ver = le64_to_cpu(ckpt->checkpoint_ver); - if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) { - __u64 crc = le32_to_cpu(*((__le32 *) - ((unsigned char *)ckpt + crc_offset))); - cp_ver |= (crc << 32); - } +#ifdef CP_CRC_RECOVERY_FLAG + __u64 crc = le32_to_cpu(*((__le32 *) + ((unsigned char *)ckpt + crc_offset))); + cp_ver |= (crc << 32); +#endif rn->footer.cp_ver = cpu_to_le64(cp_ver); rn->footer.next_blkaddr = cpu_to_le32(blkaddr); } @@ -318,11 +318,11 @@ static inline bool is_recoverable_dnode(struct page *page) size_t crc_offset = le32_to_cpu(ckpt->checksum_offset); __u64 cp_ver = cur_cp_version(ckpt); - if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) { - __u64 crc = le32_to_cpu(*((__le32 *) - ((unsigned char *)ckpt + crc_offset))); - cp_ver |= (crc << 32); - } +#ifdef CP_CRC_RECOVERY_FLAG + __u64 crc = le32_to_cpu(*((__le32 *) + ((unsigned char *)ckpt + crc_offset))); + cp_ver |= (crc << 32); +#endif return cp_ver == cpver_of_node(page); } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9eb6d89..6c2e1ee 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1573,9 +1573,10 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi, { if (force) new_curseg(sbi, type, true); - else if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) && - type == CURSEG_WARM_NODE) +#ifndef CP_CRC_RECOVERY_FLAG + else if (type == CURSEG_WARM_NODE) new_curseg(sbi, type, false); +#endif else if (need_SSR(sbi) && get_ssr_segment(sbi, type)) change_curseg(sbi, type, true); else