From patchwork Tue Dec 19 13:45:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 10123281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 126C56019C for ; Tue, 19 Dec 2017 13:45:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0365828731 for ; Tue, 19 Dec 2017 13:45:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9ECF28739; Tue, 19 Dec 2017 13:45:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65A1C28731 for ; Tue, 19 Dec 2017 13:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935056AbdLSNpf (ORCPT ); Tue, 19 Dec 2017 08:45:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:43695 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934965AbdLSNpe (ORCPT ); Tue, 19 Dec 2017 08:45:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 39C5FAEAA for ; Tue, 19 Dec 2017 13:45:33 +0000 (UTC) From: David Disseldorp To: target-devel@vger.kernel.org Cc: David Disseldorp Subject: [RFC PATCH] target: enable discard if supported by underlying block device Date: Tue, 19 Dec 2017 14:45:17 +0100 Message-Id: <20171219134517.17296-1-ddiss@suse.de> X-Mailer: git-send-email 2.13.6 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The initial commit of LIO (v4.0.0-rc6) came with support for SCSI UNMAP disabled. This was justified in the LIO wiki with: Many SATA SSDs have issues handling UNMAP properly, so it is disabled per default in LIO. Since this time, some critical discard bugs have been fixed, e.g. f3f5da624e0a ("block: Do a full clone when splitting discard bios"). Block layer backed logical units are capable of deferring to the block layer when determining UNMAP attributes, but this logic currently leaves the emulate_tpu (UNMAP) and emulate_tpws (WRITE_SAME with UNMAP=1) flags disabled. With this change, emulate_tpu and emulate_tpws are set for block layer backed logical units based on underlying block device discard support. Signed-off-by: David Disseldorp Reviewed-by: Mike Christie --- drivers/target/target_core_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index e8dd6da164b2..65dab7c2460a 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -856,6 +856,8 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, attrib->unmap_granularity_alignment = q->limits.discard_alignment / block_size; attrib->unmap_zeroes_data = (q->limits.max_write_zeroes_sectors); + attrib->emulate_tpu = 1; + attrib->emulate_tpws = 1; return true; } EXPORT_SYMBOL(target_configure_unmap_from_queue);