From patchwork Tue Jan 3 21:30:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 9495701 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 0E570606A9 for ; Tue, 3 Jan 2017 21:30:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 012F427C2D for ; Tue, 3 Jan 2017 21:30:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA12727D45; Tue, 3 Jan 2017 21:30:38 +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 6E93B27C2D for ; Tue, 3 Jan 2017 21:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934895AbdACVaf (ORCPT ); Tue, 3 Jan 2017 16:30:35 -0500 Received: from mailrelay109.isp.belgacom.be ([195.238.20.136]:23487 "EHLO mailrelay109.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933251AbdACVab (ORCPT ); Tue, 3 Jan 2017 16:30:31 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2C9AgDEFmxY/2ZisVteHQEFAQsBgzcBA?= =?us-ascii?q?QEBAR+Ba41XcpN6AZJlgg+CCIYigU1AFAECAQEBAQEBAWIohRYvIykmSyQTiGM?= =?us-ascii?q?RsTg6il2GRY8IBZp9kT4CkFOSPR84gSqDQgFOHIFfPTSGEiuCEAEBAQ?= X-IPAS-Result: =?us-ascii?q?A2C9AgDEFmxY/2ZisVteHQEFAQsBgzcBAQEBAR+Ba41XcpN?= =?us-ascii?q?6AZJlgg+CCIYigU1AFAECAQEBAQEBAWIohRYvIykmSyQTiGMRsTg6il2GRY8IB?= =?us-ascii?q?Zp9kT4CkFOSPR84gSqDQgFOHIFfPTSGEiuCEAEBAQ?= Received: from 102.98-177-91.adsl-dyn.isp.belgacom.be (HELO inkjet2.lan) ([91.177.98.102]) by relay.skynet.be with ESMTP; 03 Jan 2017 22:30:21 +0100 From: Fabian Frederick To: Andrew Morton Cc: Jan Kara , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 2/6 linux-next] fs/affs: add validation block function Date: Tue, 3 Jan 2017 22:30:20 +0100 Message-Id: <1483479020-5204-1-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.7.4 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 avoid repeating 4 times the same calculation. Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 899256b..efe6839 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -212,6 +212,12 @@ extern const struct address_space_operations affs_aops_ofs; extern const struct dentry_operations affs_dentry_operations; extern const struct dentry_operations affs_intl_dentry_operations; +static inline bool affs_validblock(struct super_block *sb, int block) +{ + return(block >= AFFS_SB(sb)->s_reserved && + block < AFFS_SB(sb)->s_partition_size); +} + static inline void affs_set_blocksize(struct super_block *sb, int size) { @@ -221,7 +227,7 @@ static inline struct buffer_head * affs_bread(struct super_block *sb, int block) { pr_debug("%s: %d\n", __func__, block); - if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) + if (affs_validblock(sb, block)) return sb_bread(sb, block); return NULL; } @@ -229,7 +235,7 @@ static inline struct buffer_head * affs_getblk(struct super_block *sb, int block) { pr_debug("%s: %d\n", __func__, block); - if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) + if (affs_validblock(sb, block)) return sb_getblk(sb, block); return NULL; } @@ -238,7 +244,7 @@ affs_getzeroblk(struct super_block *sb, int block) { struct buffer_head *bh; pr_debug("%s: %d\n", __func__, block); - if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { + if (affs_validblock(sb, block)) { bh = sb_getblk(sb, block); lock_buffer(bh); memset(bh->b_data, 0 , sb->s_blocksize); @@ -253,7 +259,7 @@ affs_getemptyblk(struct super_block *sb, int block) { struct buffer_head *bh; pr_debug("%s: %d\n", __func__, block); - if (block >= AFFS_SB(sb)->s_reserved && block < AFFS_SB(sb)->s_partition_size) { + if (affs_validblock(sb, block)) { bh = sb_getblk(sb, block); wait_on_buffer(bh); set_buffer_uptodate(bh);