From 1fd28bd8d4e102a4ce5e4910427f612c7cf73e68 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Fri, 21 Jun 2019 09:40:56 -0700 Subject: [PATCH] Add SCSI_PASSTHROUGH to zvols to enable UNMAP support When exporting ZVOLs as SCSI LUNs, by default Windows will not issue them UNMAP commands. This reduces storage efficiency in many cases. We add the SCSI_PASSTHROUGH flag to the zvol's device queue, which lets the SCSI target logic know that it can handle SCSI commands. Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Reviewed-by: John Gallagher Signed-off-by: Paul Dagnelie Closes #8933 --- module/zfs/zvol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index c29f65f676..7c7500dbaa 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -1876,6 +1876,10 @@ zvol_create_minor_impl(const char *name) #ifdef QUEUE_FLAG_ADD_RANDOM blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, zv->zv_queue); #endif + /* This flag was introduced in kernel version 4.12. */ +#ifdef QUEUE_FLAG_SCSI_PASSTHROUGH + blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, zv->zv_queue); +#endif if (spa_writeable(dmu_objset_spa(os))) { if (zil_replay_disable)