diff mbox

[2/9] block: update chunk_sectors in blk_stack_limits()

Message ID 1459764020-126038-3-git-send-email-hare@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Hannes Reinecke April 4, 2016, 10 a.m. UTC
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 block/blk-settings.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Bart Van Assche April 15, 2016, 3:41 a.m. UTC | #1
On 04/04/16 03:00, Hannes Reinecke wrote:
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index c7bb666..29fa900 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -630,6 +630,9 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
>   			t->discard_granularity;
>   	}
>
> +	if (b->chunk_sectors)
> +		t->chunk_sectors = max(t->chunk_sectors, b->chunk_sectors);
> +
>   	return ret;
>   }
>   EXPORT_SYMBOL(blk_stack_limits);

Hello Hannes,

My understanding is that a non-zero chunk_sectors value defines a 
maximum I/O size. Shouldn't max() be changed into min_not_zero()? From 
include/linux/blkdev.h:

static inline unsigned int blk_max_size_offset(struct request_queue *q,
					       sector_t offset)
{
	if (!q->limits.chunk_sectors)
		return q->limits.max_sectors;

	return q->limits.chunk_sectors -
			(offset & (q->limits.chunk_sectors - 1));
}

Bart.

--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Reinecke April 15, 2016, 6:05 a.m. UTC | #2
On 04/15/2016 05:41 AM, Bart Van Assche wrote:
> On 04/04/16 03:00, Hannes Reinecke wrote:
>> diff --git a/block/blk-settings.c b/block/blk-settings.c
>> index c7bb666..29fa900 100644
>> --- a/block/blk-settings.c
>> +++ b/block/blk-settings.c
>> @@ -630,6 +630,9 @@ int blk_stack_limits(struct queue_limits *t,
>> struct queue_limits *b,
>>               t->discard_granularity;
>>       }
>>
>> +    if (b->chunk_sectors)
>> +        t->chunk_sectors = max(t->chunk_sectors, b->chunk_sectors);
>> +
>>       return ret;
>>   }
>>   EXPORT_SYMBOL(blk_stack_limits);
> 
> Hello Hannes,
> 
> My understanding is that a non-zero chunk_sectors value defines a
> maximum I/O size. Shouldn't max() be changed into min_not_zero()?
> From include/linux/blkdev.h:
> 
> static inline unsigned int blk_max_size_offset(struct request_queue *q,
>                            sector_t offset)
> {
>     if (!q->limits.chunk_sectors)
>         return q->limits.max_sectors;
> 
>     return q->limits.chunk_sectors -
>             (offset & (q->limits.chunk_sectors - 1));
> }
> 
Hmm.

_Actually_ it should be the least common denominator, me thinks...
Have to think it through a bit more.

Cheers,

Hannes
diff mbox

Patch

diff --git a/block/blk-settings.c b/block/blk-settings.c
index c7bb666..29fa900 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -630,6 +630,9 @@  int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 			t->discard_granularity;
 	}
 
+	if (b->chunk_sectors)
+		t->chunk_sectors = max(t->chunk_sectors, b->chunk_sectors);
+
 	return ret;
 }
 EXPORT_SYMBOL(blk_stack_limits);