* [PATCH] dm-thin: Export proper discard_granularity
@ 2014-06-11 12:32 Lukas Czerner
2014-06-11 21:31 ` Mike Snitzer
2014-06-12 8:54 ` [PATCH] " Joe Thornber
0 siblings, 2 replies; 3+ messages in thread
From: Lukas Czerner @ 2014-06-11 12:32 UTC (permalink / raw)
To: dm-devel; +Cc: Lukas Czerner
Currently if the underlying device is discard capable and the
discard_passdown is enabled, the discard_granularity will be inherited
from that device.
This will pose a problem in the case that the device discard_granularity
is smaller than thin volume chunk size, because in that case discard
requests will not be chunk size aligned so it will be ignored by
dm-thin.
Fix this by setting thin volume discard granularity to the bigger of the
two max(device discard_granularity, thin volume chunk size). Strictly
speaking it is not necessary to get the bigger of the two, because
the thin volume chunk size will always be >= device discard_granularity.
However I believe that the reason for this is only because dm-thin can
not handle discard requests bigger than chunk size which is hopefully
going to change soon. This way it is future proof.
RHBZ: 1106856
Reported-by: Zdenek Kabelac <zkabelac@fedoraproject.org>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
drivers/md/dm-thin.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 242ac2e..fdd7089 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -3068,7 +3068,9 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
*/
if (pt->adjusted_pf.discard_passdown) {
data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
- limits->discard_granularity = data_limits->discard_granularity;
+ limits->discard_granularity =
+ max(data_limits->discard_granularity,
+ pool->sectors_per_block << SECTOR_SHIFT);
} else
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: dm-thin: Export proper discard_granularity
2014-06-11 12:32 [PATCH] dm-thin: Export proper discard_granularity Lukas Czerner
@ 2014-06-11 21:31 ` Mike Snitzer
2014-06-12 8:54 ` [PATCH] " Joe Thornber
1 sibling, 0 replies; 3+ messages in thread
From: Mike Snitzer @ 2014-06-11 21:31 UTC (permalink / raw)
To: Lukas Czerner; +Cc: dm-devel
On Wed, Jun 11 2014 at 8:32am -0400,
Lukas Czerner <lczerner@redhat.com> wrote:
> Currently if the underlying device is discard capable and the
> discard_passdown is enabled, the discard_granularity will be inherited
> from that device.
>
> This will pose a problem in the case that the device discard_granularity
> is smaller than thin volume chunk size, because in that case discard
> requests will not be chunk size aligned so it will be ignored by
> dm-thin.
>
> Fix this by setting thin volume discard granularity to the bigger of the
> two max(device discard_granularity, thin volume chunk size). Strictly
> speaking it is not necessary to get the bigger of the two, because
> the thin volume chunk size will always be >= device discard_granularity.
> However I believe that the reason for this is only because dm-thin can
> not handle discard requests bigger than chunk size which is hopefully
> going to change soon. This way it is future proof.
>
> RHBZ: 1106856
>
> Reported-by: Zdenek Kabelac <zkabelac@fedoraproject.org>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Hi Lukas,
I missed this submission on dm-devel until now. But I had already
picked this patch up earlier from the BZ, see the patch I staged in
linux-next here:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=09869de57ed2728ae3c619803932a86cb0e2c4f8
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dm-thin: Export proper discard_granularity
2014-06-11 12:32 [PATCH] dm-thin: Export proper discard_granularity Lukas Czerner
2014-06-11 21:31 ` Mike Snitzer
@ 2014-06-12 8:54 ` Joe Thornber
1 sibling, 0 replies; 3+ messages in thread
From: Joe Thornber @ 2014-06-12 8:54 UTC (permalink / raw)
To: device-mapper development; +Cc: Lukas Czerner
ack
On Wed, Jun 11, 2014 at 02:32:09PM +0200, Lukas Czerner wrote:
> Currently if the underlying device is discard capable and the
> discard_passdown is enabled, the discard_granularity will be inherited
> from that device.
>
> This will pose a problem in the case that the device discard_granularity
> is smaller than thin volume chunk size, because in that case discard
> requests will not be chunk size aligned so it will be ignored by
> dm-thin.
>
> Fix this by setting thin volume discard granularity to the bigger of the
> two max(device discard_granularity, thin volume chunk size). Strictly
> speaking it is not necessary to get the bigger of the two, because
> the thin volume chunk size will always be >= device discard_granularity.
> However I believe that the reason for this is only because dm-thin can
> not handle discard requests bigger than chunk size which is hopefully
> going to change soon. This way it is future proof.
>
> RHBZ: 1106856
>
> Reported-by: Zdenek Kabelac <zkabelac@fedoraproject.org>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
> drivers/md/dm-thin.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
> index 242ac2e..fdd7089 100644
> --- a/drivers/md/dm-thin.c
> +++ b/drivers/md/dm-thin.c
> @@ -3068,7 +3068,9 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
> */
> if (pt->adjusted_pf.discard_passdown) {
> data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
> - limits->discard_granularity = data_limits->discard_granularity;
> + limits->discard_granularity =
> + max(data_limits->discard_granularity,
> + pool->sectors_per_block << SECTOR_SHIFT);
> } else
> limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
> }
> --
> 1.8.3.1
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-12 8:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-11 12:32 [PATCH] dm-thin: Export proper discard_granularity Lukas Czerner
2014-06-11 21:31 ` Mike Snitzer
2014-06-12 8:54 ` [PATCH] " Joe Thornber
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.