diff mbox

[V4,01/22] ext4: Move extra inode read to a new function.

Message ID 1329721316-4955-1-git-send-email-tm@tao.ma
State Superseded, archived
Headers show

Commit Message

Tao Ma Feb. 20, 2012, 7:01 a.m. UTC
From: Tao Ma <boyu.mt@taobao.com>

Currently, in ext4_iget we do a simple check to see whether
there does exist some information starting from the end
of i_extra_size. With inline data added, this procedure
is more complicated. So move it to a new function named
ext4_iget_extra_inode.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/ext4/inode.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

Comments

Andreas Dilger Feb. 21, 2012, 6:51 a.m. UTC | #1
On 2012-02-20, at 12:01 AM, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> Currently, in ext4_iget we do a simple check to see whether
> there does exist some information starting from the end
> of i_extra_size. With inline data added, this procedure
> is more complicated. So move it to a new function named
> ext4_iget_extra_inode.
> 
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
> ---
> fs/ext4/inode.c |   19 ++++++++++++-------
> 1 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index feaa82f..0b2d6c1 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3610,6 +3610,16 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
> 	}
> }
> 
> +static inline void ext4_iget_extra_inode(struct inode *inode,
> +					 struct ext4_inode *raw_inode,
> +					 struct ext4_inode_info *ei)
> +{
> +	__le32 *magic = (void *)raw_inode +
> +			EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
> +	if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
> +		ext4_set_inode_state(inode, EXT4_STATE_XATTR);
> +}

The patch looks fine, and is a nice little cleanup, but...

> struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
> {
> 	struct ext4_iloc iloc;
> @@ -3720,13 +3730,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
> 			/* The extra space is currently unused. Use it. */
> 			ei->i_extra_isize = sizeof(struct ext4_inode) -
> 					    EXT4_GOOD_OLD_INODE_SIZE;
> -		} else {
> -			__le32 *magic = (void *)raw_inode +
> -					EXT4_GOOD_OLD_INODE_SIZE +
> -					ei->i_extra_isize;
> -			if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
> -				ext4_set_inode_state(inode, EXT4_STATE_XATTR);
> -		}
> +		} else
> +			ext4_iget_extra_inode(inode, raw_inode, ei);

This does not follow Documentation/CodingStyle - there should be braces around
the "else" clause if it is needed for the "if" clause.  The below code could be
fixed at the same time.

> 	} else
> 		ei->i_extra_isize = 0;
> 
> -- 
> 1.7.0.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas





--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tao Ma Feb. 21, 2012, 8:13 a.m. UTC | #2
On 02/21/2012 02:51 PM, Andreas Dilger wrote:
> On 2012-02-20, at 12:01 AM, Tao Ma wrote:
>> From: Tao Ma <boyu.mt@taobao.com>
>>
>> Currently, in ext4_iget we do a simple check to see whether
>> there does exist some information starting from the end
>> of i_extra_size. With inline data added, this procedure
>> is more complicated. So move it to a new function named
>> ext4_iget_extra_inode.
>>
>> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
>> ---
>> fs/ext4/inode.c |   19 ++++++++++++-------
>> 1 files changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
>> index feaa82f..0b2d6c1 100644
>> --- a/fs/ext4/inode.c
>> +++ b/fs/ext4/inode.c
>> @@ -3610,6 +3610,16 @@ static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
>> 	}
>> }
>>
>> +static inline void ext4_iget_extra_inode(struct inode *inode,
>> +					 struct ext4_inode *raw_inode,
>> +					 struct ext4_inode_info *ei)
>> +{
>> +	__le32 *magic = (void *)raw_inode +
>> +			EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
>> +	if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
>> +		ext4_set_inode_state(inode, EXT4_STATE_XATTR);
>> +}
> 
> The patch looks fine, and is a nice little cleanup, but...
> 
>> struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>> {
>> 	struct ext4_iloc iloc;
>> @@ -3720,13 +3730,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>> 			/* The extra space is currently unused. Use it. */
>> 			ei->i_extra_isize = sizeof(struct ext4_inode) -
>> 					    EXT4_GOOD_OLD_INODE_SIZE;
>> -		} else {
>> -			__le32 *magic = (void *)raw_inode +
>> -					EXT4_GOOD_OLD_INODE_SIZE +
>> -					ei->i_extra_isize;
>> -			if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
>> -				ext4_set_inode_state(inode, EXT4_STATE_XATTR);
>> -		}
>> +		} else
>> +			ext4_iget_extra_inode(inode, raw_inode, ei);
> 
> This does not follow Documentation/CodingStyle - there should be braces around
> the "else" clause if it is needed for the "if" clause.  The below code could be
> fixed at the same time.
OK, I will fix it. Thanks for the review.

Thanks
Tao
> 
>> 	} else
>> 		ei->i_extra_isize = 0;
>>
>> -- 
>> 1.7.0.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> Cheers, Andreas
> 
> 
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index feaa82f..0b2d6c1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3610,6 +3610,16 @@  static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
 	}
 }
 
+static inline void ext4_iget_extra_inode(struct inode *inode,
+					 struct ext4_inode *raw_inode,
+					 struct ext4_inode_info *ei)
+{
+	__le32 *magic = (void *)raw_inode +
+			EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
+	if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
+		ext4_set_inode_state(inode, EXT4_STATE_XATTR);
+}
+
 struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 {
 	struct ext4_iloc iloc;
@@ -3720,13 +3730,8 @@  struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 			/* The extra space is currently unused. Use it. */
 			ei->i_extra_isize = sizeof(struct ext4_inode) -
 					    EXT4_GOOD_OLD_INODE_SIZE;
-		} else {
-			__le32 *magic = (void *)raw_inode +
-					EXT4_GOOD_OLD_INODE_SIZE +
-					ei->i_extra_isize;
-			if (*magic == cpu_to_le32(EXT4_XATTR_MAGIC))
-				ext4_set_inode_state(inode, EXT4_STATE_XATTR);
-		}
+		} else
+			ext4_iget_extra_inode(inode, raw_inode, ei);
 	} else
 		ei->i_extra_isize = 0;