Return-Path: Received: from mail-by2nam03on0106.outbound.protection.outlook.com ([104.47.42.106]:32336 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753956AbeARVG2 (ORCPT ); Thu, 18 Jan 2018 16:06:28 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Jiang Yi , Nicholas Bellinger , Sasha Levin Subject: [added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero Date: Thu, 18 Jan 2018 21:01:45 +0000 Message-ID: <20180118205908.3220-264-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jiang Yi This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 594e25e73440863981032d76c9b1e33409ceff6e ] The function fd_execute_unmap() in target_core_file.c calles ret =3D file->f_op->fallocate(file, mode, pos, len); Some filesystems implement fallocate() to return error if length is zero (e.g. btrfs) but according to SCSI Block Commands spec UNMAP should return success for zero length. Signed-off-by: Jiang Yi Signed-off-by: Nicholas Bellinger Signed-off-by: Sasha Levin --- drivers/target/target_core_file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core= _file.c index dee7dfdf203a..5d5e5cd77261 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -539,6 +539,10 @@ fd_do_unmap(struct se_cmd *cmd, void *priv, sector_t l= ba, sector_t nolb) struct inode *inode =3D file->f_mapping->host; int ret; =20 + if (!nolb) { + return 0; + } + if (cmd->se_dev->dev_attrib.pi_prot_type) { ret =3D fd_do_prot_unmap(cmd, lba, nolb); if (ret) --=20 2.11.0