From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailrelay103.isp.belgacom.be ([195.238.20.130]:9700 "EHLO mailrelay103.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935226AbdAITMR (ORCPT ); Mon, 9 Jan 2017 14:12:17 -0500 From: Fabian Frederick To: Andrew Morton Cc: Jan Kara , Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, fabf@skynet.be Subject: [PATCH V2 2/7 linux-next] fs/affs: add validation block function Date: Mon, 9 Jan 2017 20:12:03 +0100 Message-Id: <20170109191208.6085-3-fabf@skynet.be> In-Reply-To: <20170109191208.6085-1-fabf@skynet.be> References: <20170109191208.6085-1-fabf@skynet.be> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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); -- 2.9.3