block: Fix discard topology stacking and reporting
In some cases we would end up stacking discard_zeroes_data incorrectly. Fix this by enabling the feature by default for stacking drivers and clearing it for low-level drivers. Incorporating a device that does not support dzd will then cause the feature to be disabled in the stacking driver. Also ensure that the maximum discard value does not overflow when exported in sysfs and return 0 in the alignment and dzd fields for devices that don't support discard. Reported-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Mike Snitzer <snitzer@redhat.com> Cc: stable@kernel.org Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
committed by
Jens Axboe
parent
bbdd304cf6
commit
a934a00a69
@@ -257,7 +257,7 @@ struct queue_limits {
|
||||
unsigned char misaligned;
|
||||
unsigned char discard_misaligned;
|
||||
unsigned char cluster;
|
||||
signed char discard_zeroes_data;
|
||||
unsigned char discard_zeroes_data;
|
||||
};
|
||||
|
||||
struct request_queue
|
||||
@@ -1069,13 +1069,16 @@ static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector
|
||||
{
|
||||
unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1);
|
||||
|
||||
if (!lim->max_discard_sectors)
|
||||
return 0;
|
||||
|
||||
return (lim->discard_granularity + lim->discard_alignment - alignment)
|
||||
& (lim->discard_granularity - 1);
|
||||
}
|
||||
|
||||
static inline unsigned int queue_discard_zeroes_data(struct request_queue *q)
|
||||
{
|
||||
if (q->limits.discard_zeroes_data == 1)
|
||||
if (q->limits.max_discard_sectors && q->limits.discard_zeroes_data == 1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user