DISCARD support in kernel driver
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described on http://tracker.ceph.com/issues/190
This first (easy) step was to add at the end of drivers/block/rbd.c:rbd_init_disk
/* Advertise discard support for aligned blocks */
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
disk->queue->limits.discard_granularity = segment_size;
disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Next step was to add support on rbd_request_fn which I did (sort of). But here I'm stuck. If I understood well FS drivers uses REQ_DISCARD flag of rq->cmd_flags to notify the driver of the discard operation. But the problem is that (rq->cmd_flags & REQ_DISCARD) never appears to be set.
I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't manage to find what ? Do you have any clue what could be wrong ?
Thanks,
Signature · 1 line
Jean-Tiare, shared-hosting team
Quoted 16 lines · Jean-Tiare LE BIGOT
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described on http://tracker.ceph.com/issues/190
This first (easy) step was to add at the end of
drivers/block/rbd.c:rbd_init_disk/* Advertise discard support for aligned blocks */ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); disk->queue->limits.discard_granularity = segment_size; disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Quoted 8 lines
Next step was to add support on
rbd_request_fnwhich I did (sort of). But here I'm stuck. If I understood well FS drivers usesREQ_DISCARDflag ofrq->cmd_flagsto notify the driver of the discard operation. But the problem is that (rq->cmd_flags&REQ_DISCARD) never appears to be set.I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't manage to find what ? Do you have any clue what could be wrong ?
I don't know anything about the relevant kernel internal interfaces here, but don't most FSes need to be told explicitly to do trimming? Did you do that?
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com
Hi Greg,
Thanks for your answer. I did
$ mount -t ext4 -o discard /dev/rbd1 /mnt # did not see any DISCARD op after that $ fstrim /mnt # neither
Maybe missing something there ? I expected '-o discard' to be enough ?
Quoted 33 lines · Gregory Farnum
Quoted 16 lines · Jean-Tiare LE BIGOT
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described on http://tracker.ceph.com/issues/190
This first (easy) step was to add at the end of
drivers/block/rbd.c:rbd_init_disk/* Advertise discard support for aligned blocks */ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); disk->queue->limits.discard_granularity = segment_size; disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Quoted 8 lines
Next step was to add support on
rbd_request_fnwhich I did (sort of). But here I'm stuck. If I understood well FS drivers usesREQ_DISCARDflag ofrq->cmd_flagsto notify the driver of the discard operation. But the problem is that (rq->cmd_flags&REQ_DISCARD) never appears to be set.I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't manage to find what ? Do you have any clue what could be wrong ?
I don't know anything about the relevant kernel internal interfaces here, but don't most FSes need to be told explicitly to do trimming? Did you do that?
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com
Signature · 1 line
Jean-Tiare, shared-hosting team
My quick Google says that should be enough, but I haven't done it myself...sorry. :(
Quoted 58 lines · Jean-Tiare LE BIGOT
Hi Greg,
Thanks for your answer. I did
$ mount -t ext4 -o discard /dev/rbd1 /mnt # did not see any DISCARD op after that $ fstrim /mnt # neitherMaybe missing something there ? I expected '-o discard' to be enough ?
Quoted 34 lines · Gregory Farnum
Quoted 25 lines · Jean-Tiare LE BIGOT
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described
on http://tracker.ceph.com/issues/190This first (easy) step was to add at the end of
drivers/block/rbd.c:rbd_init_disk/* Advertise discard support for aligned blocks */ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); disk->queue->limits.discard_granularity = segment_size; disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Next step was to add support on
rbd_request_fnwhich I did (sort of). But
here I'm stuck. If I understood well FS drivers usesREQ_DISCARDflag ofrq->cmd_flagsto notify the driver of the discard operation. But the problem is that (rq->cmd_flags&REQ_DISCARD) never appears to be set.Quoted 4 lines
I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't
manage to find what ? Do you have any clue what could be wrong ?Quoted 6 lines
I don't know anything about the relevant kernel internal interfaces here, but don't most FSes need to be told explicitly to do trimming? Did you do that?
-Greg
Software Engineer #42 @ http://inktank.com | http://ceph.com--
Jean-Tiare, shared-hosting team
Quoted 22 lines · Jean-Tiare LE BIGOT
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described on http://tracker.ceph.com/issues/190
This first (easy) step was to add at the end of
drivers/block/rbd.c:rbd_init_disk/* Advertise discard support for aligned blocks */ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); disk->queue->limits.discard_granularity = segment_size; disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Next step was to add support on
rbd_request_fnwhich I did (sort of). But here I'm stuck. If I understood well FS drivers usesREQ_DISCARDflag ofrq->cmd_flagsto notify the driver of the discard operation. But the problem is that (rq->cmd_flags&REQ_DISCARD) never appears to be set.
Quoted 6 lines
I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't manage to find what ? Do you have any clue what could be wrong ?
Thanks,
Well, you can use the "blkdiscard" command to force a discard of an arbitrary portion of a block device directly. You can used dd or ddrescue to copy test patterns (maybe 0xFF) to and from RBD device, and use blkdiscard to trim parts of that.
If that doesn't work, then the error must be elsewhere.
Hi Jean-Tiare,
How is this going?
sage
Quoted 36 lines · Jean-Tiare LE BIGOT
Hi,
I started to implement 'DISCARD' support in RBD kernel driver as described on
http://tracker.ceph.com/issues/190This first (easy) step was to add at the end of
drivers/block/rbd.c:rbd_init_disk/* Advertise discard support for aligned blocks */ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); disk->queue->limits.discard_granularity = segment_size; disk->queue->limits.discard_alignment = segment_size;With this both 'mount -o discard' and 'fstrim' stopped to complain about missing 'DISCARD' support. Good !
Next step was to add support on
rbd_request_fnwhich I did (sort of). But here I'm stuck. If I understood well FS drivers usesREQ_DISCARDflag ofrq->cmd_flagsto notify the driver of the discard operation. But the problem is that (rq->cmd_flags&REQ_DISCARD) never appears to be set.I tried copying then removing large files, lots of small files, forcing fstrim. But I never got it. I must be missing something obvious but I can't manage to find what ? Do you have any clue what could be wrong ?
Thanks,
Signature · 6 lines
Jean-Tiare, shared-hosting team -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html