From patchwork Wed Dec 13 21:55:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Vagin X-Patchwork-Id: 10110975 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 4950460352 for ; Wed, 13 Dec 2017 21:55:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CADD28F95 for ; Wed, 13 Dec 2017 21:55:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 305AE29294; Wed, 13 Dec 2017 21:55:57 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 E777E28F95 for ; Wed, 13 Dec 2017 21:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753953AbdLMVzn (ORCPT ); Wed, 13 Dec 2017 16:55:43 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45404 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753839AbdLMVzm (ORCPT ); Wed, 13 Dec 2017 16:55:42 -0500 Received: by mail-lf0-f66.google.com with SMTP id f13so4344309lff.12; Wed, 13 Dec 2017 13:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=4obBFeWvdP+8cfe583oFkjFzDSOWezjNwemg2cN6Qe4=; b=qtvxP/O7RnhiWkcPXWvtYC4KsjObfgoQlBtDCWQgI/Z/sT5ERnc/RpUzoVkB8IR5Es jA6jFSiK2Chc5Q455/szTcevBUCyQSvzqz4m3bVQCopXWibZD1qfmuQyJbGtGsD7sltn av2b7o+tCMrfnn2dxdC/Sbu4Lmrdhmdh/lZsEXmb96OTaXrtkZSVYUdnJpFM2cIQXJ4U TvrWOusCNg4CDyy/SJGVoZdmr4JNvoN6jUI0YmN7W47FFNCZOAUrCNdk8k8qsYdJ7NY9 A3xSBkey+2DP/Obxwt6kssHcctDEUrTonlMcLFzojgZqcPu0KAEHp+JATGDia7buXKcA etlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=4obBFeWvdP+8cfe583oFkjFzDSOWezjNwemg2cN6Qe4=; b=Ahjfgfhlo5KjMmO00NsEr8wBurfTd6KR4ZF2UgyehgM/sOsgEhlFvB3K6fLSfsmYTb 05L+2QEnKTD9CvnFVUp41zypWHsLqE8t+LnMhjRCEvde2uGwjbh32PoIL3yt0hBbT28V n1EBG2b49so7MjLtwfDLekFl8ZgT8qs+CdXrxwIjg2878NOYla1lEL3dxItlipT6Q6ct SDKO6Y6bcDezNXU/DreyGWDNRl+9ROjHPz2iqhR2DaKGtwWmWcnL8Tc8JGBwgu/dNI34 vyh1dvXG3CF/JAinqUBMqHGuDecwXNdfDX8pNHyX4D5FxThD+kqiJhooJjhI2Z1FmJ7+ VZJA== X-Gm-Message-State: AKGB3mIudbLFTBhBfh3IjXq9HwIEuPs5JKnvRXtWsDiJRq4NRTEWtx07 2K7yM1+uadOGJuh1EsePkPQNpoHZ X-Google-Smtp-Source: ACJfBovknxwheILLFCzpsRjw+ubtBqd9PfeWT7xAE0yEfQbL+w4QGvg89QEKPiCL0wpKy6B3O3FhOA== X-Received: by 10.25.143.77 with SMTP id r74mr2543011lfd.86.1513202139980; Wed, 13 Dec 2017 13:55:39 -0800 (PST) Received: from laptop.sw.ru ([65.152.152.74]) by smtp.gmail.com with ESMTPSA id g23sm525600lfh.2.2017.12.13.13.55.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2017 13:55:39 -0800 (PST) From: Andrei Vagin To: target-devel@vger.kernel.org, "Nicholas A. Bellinger" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrei Vagin Subject: [PATCH] target: don't call an unmap callback if a range length is zero Date: Wed, 13 Dec 2017 13:55:13 -0800 Message-Id: <20171213215513.26416-1-avagin@openvz.org> X-Mailer: git-send-email 2.13.6 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a length of a range is zero, it means there is nothing to unmap and we can skip this range. Here is one more reason, why we have to skip such ranges. An unmap callback calls file_operations->fallocate(), but the man page for the fallocate syscall says that fallocate(fd, mode, offset, let) returns EINVAL, if len is zero. It means that file_operations->fallocate() isn't obligated to handle zero ranges too. Signed-off-by: Andrei Vagin --- drivers/target/target_core_sbc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 750a04ed0e93..b054682e974f 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1216,9 +1216,11 @@ sbc_execute_unmap(struct se_cmd *cmd) goto err; } - ret = ops->execute_unmap(cmd, lba, range); - if (ret) - goto err; + if (range) { + ret = ops->execute_unmap(cmd, lba, range); + if (ret) + goto err; + } ptr += 16; size -= 16;