Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1554625

[PATCH V2 2/7 linux-next] fs/affs: add validation block function

From Fabian Frederick <fabf@skynet.be>
Newsgroups linux.kernel
Subject [PATCH V2 2/7 linux-next] fs/affs: add validation block function
Date 2017-01-09 20:20 +0100
Message-ID <sXNE6-89F-29@gated-at.bofh.it> (permalink)
References <sXNE5-89F-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


avoid repeating 4 times the same calculation.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 0/7 linux-next] make FS exportable plus some clean-up Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
  [PATCH V2 5/7 linux-next] fs/affs: add prefix to some functions Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
  [PATCH V2 4/7 linux-next] fs/affs: use octal for permissions Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
  [PATCH V2 2/7 linux-next] fs/affs: add validation block function Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
  [PATCH V2 3/7 linux-next] fs/affs: make affs exportable Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
  [PATCH V2 1/7 linux-next] fs/affs: remove reference to affs_parent_ino() Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100

csiph-web