diff mbox

[v2,2/2] ext4: Ignore a stripe width of 1

Message ID 1310766115-4164-2-git-send-email-dehrenberg@google.com
State Accepted, archived
Headers show

Commit Message

Dan Ehrenberg July 15, 2011, 9:41 p.m. UTC
If the stripe width was set to 1, then this patch will ignore
that stripe width and ext4 will act as if the stripe width
were 0 with respect to optimizing allocations.

Signed-off-by: Dan Ehrenberg <dehrenberg@google.com>
---
 fs/ext4/super.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

Comments

Eric Sandeen July 15, 2011, 9:47 p.m. UTC | #1
On 7/15/11 4:41 PM, Dan Ehrenberg wrote:
> If the stripe width was set to 1, then this patch will ignore
> that stripe width and ext4 will act as if the stripe width
> were 0 with respect to optimizing allocations.
> 
> Signed-off-by: Dan Ehrenberg <dehrenberg@google.com>

Thanks, I think this makes sense.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/ext4/super.c |   22 ++++++++++++++++------
>  1 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 9ea71aa..0a3745b 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2383,17 +2383,27 @@ static unsigned long ext4_get_stripe_size(struct ext4_sb_info *sbi)
>  	unsigned long stride = le16_to_cpu(sbi->s_es->s_raid_stride);
>  	unsigned long stripe_width =
>  			le32_to_cpu(sbi->s_es->s_raid_stripe_width);
> +	int ret;
>  
>  	if (sbi->s_stripe && sbi->s_stripe <= sbi->s_blocks_per_group)
> -		return sbi->s_stripe;
> +		ret = sbi->s_stripe;
>  
> -	if (stripe_width <= sbi->s_blocks_per_group)
> -		return stripe_width;
> +	else if (stripe_width <= sbi->s_blocks_per_group)
> +		ret = stripe_width;
>  
> -	if (stride <= sbi->s_blocks_per_group)
> -		return stride;
> +	else if (stride <= sbi->s_blocks_per_group)
> +		ret = stride;
> +	else
> +		ret = 0;
>  
> -	return 0;
> +	/*
> +	 * If the stripe width is 1, this makes no sense and
> +	 * we set it to 0 to turn off stripe handling code.
> +	 */
> +	if (ret <= 1)
> +		ret = 0;
> +
> +	return ret;
>  }
>  
>  /* sysfs supprt */

--
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
Theodore Ts'o July 18, 2011, 1:21 a.m. UTC | #2
On Fri, Jul 15, 2011 at 02:41:55PM -0700, Dan Ehrenberg wrote:
> If the stripe width was set to 1, then this patch will ignore
> that stripe width and ext4 will act as if the stripe width
> were 0 with respect to optimizing allocations.
> 
> Signed-off-by: Dan Ehrenberg <dehrenberg@google.com>

Applied to the ext4 tree.  I did make one formatting change.  Please
don't have blank lines between the if and else clauses, like this:

	if (sbi->s_stripe && sbi->s_stripe <= sbi->s_blocks_per_group)
		ret = sbi->s_stripe;

	else if (stripe_width <= sbi->s_blocks_per_group)
		ret = stripe_width;

	else if (stride <= sbi->s_blocks_per_group)
		ret = stride;

it wastes vertical whitespace and makes the control flow harder to
follow.  Eliminate the blank lines, and it's easier to read, I think.

	if (sbi->s_stripe && sbi->s_stripe <= sbi->s_blocks_per_group)
		ret = sbi->s_stripe;
	else if (stripe_width <= sbi->s_blocks_per_group)
		ret = stripe_width;
	else if (stride <= sbi->s_blocks_per_group)
		ret = stride;

						- Ted
--
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/super.c b/fs/ext4/super.c
index 9ea71aa..0a3745b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2383,17 +2383,27 @@  static unsigned long ext4_get_stripe_size(struct ext4_sb_info *sbi)
 	unsigned long stride = le16_to_cpu(sbi->s_es->s_raid_stride);
 	unsigned long stripe_width =
 			le32_to_cpu(sbi->s_es->s_raid_stripe_width);
+	int ret;
 
 	if (sbi->s_stripe && sbi->s_stripe <= sbi->s_blocks_per_group)
-		return sbi->s_stripe;
+		ret = sbi->s_stripe;
 
-	if (stripe_width <= sbi->s_blocks_per_group)
-		return stripe_width;
+	else if (stripe_width <= sbi->s_blocks_per_group)
+		ret = stripe_width;
 
-	if (stride <= sbi->s_blocks_per_group)
-		return stride;
+	else if (stride <= sbi->s_blocks_per_group)
+		ret = stride;
+	else
+		ret = 0;
 
-	return 0;
+	/*
+	 * If the stripe width is 1, this makes no sense and
+	 * we set it to 0 to turn off stripe handling code.
+	 */
+	if (ret <= 1)
+		ret = 0;
+
+	return ret;
 }
 
 /* sysfs supprt */