Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2501441imm; Mon, 24 Sep 2018 05:32:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aq5XsumV13DG7bljdV+jG8kIe2YGEupCFxocPDAhVL7UI1YAlZ4l0X6FfMXzzGfyueUAN X-Received: by 2002:a63:2c01:: with SMTP id s1-v6mr9191122pgs.367.1537792376166; Mon, 24 Sep 2018 05:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792376; cv=none; d=google.com; s=arc-20160816; b=aXt1arOWw0psmsXXi6gKxNqS/jCyzVCKz1FyUoLhk+SyDtalH4nRCWCa+HzpDKq9LY EDMMrteYbDO/xWudlyJbHipoT4aW8BKN73WTNr3VyLvGByudwPVCM72H0B1cgCu+Enle hilD0d8ggalYbVfEsDPxt3bhxhiZFjgkFCHr3quuJyQzIHYkX2knlP/cv1wJegqp1vq0 deyFqUwXz8shhJvhw9803ni1Bz2L9ZduOVgrFzYkxU3I3+s9xCLrCcOtvNQnPfR+5uQO ZCdrw1ySNruqRWgaErJ+JBndltgBZHeE8upxS3UeDhDTNd+0WZxZfdGQkEPBZvbqr3wq KgsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=v6+VioKjHG2/1GqC1tW8Em409SVgSrz+ui46f7PhJKo=; b=ys9hkMQnn8JswTynskTWQh8G/hAgZj3v8pLWGDY+VquNQLraDa/y+DxHkUerpXbVMH 8mXdSHHQ06M++KeILp9TA1so1ykVOo2QvYpJcZB0qmSaiGr11Ax+P9olqdNIRdhcmZWu 7n+dTPUChoXeAP1md55zv6TvOadd+HgsPkmE96a1zdHxt21XESnxRVhLpXUv7/epQ2O6 LmkEKVNh0jraXpz7CnOA2VGOoGdRdNoISCOD6PFbHuu/Gzf9GIBljkIq0cal6H+aeiI3 4miucKvyJvrgivwDMxjSrDL2vZlDwRLpQ/a3FdLTBFNtMHBVdNXc5d8soolpDiKO8VTE ac+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b190-v6si35967015pfg.94.2018.09.24.05.32.40; Mon, 24 Sep 2018 05:32:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387868AbeIXScO (ORCPT + 99 others); Mon, 24 Sep 2018 14:32:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57790 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730321AbeIXScN (ORCPT ); Mon, 24 Sep 2018 14:32:13 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 38ED81098; Mon, 24 Sep 2018 12:30:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sagi Grimberg , Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.18 061/235] nvmet: fix file discard return status Date: Mon, 24 Sep 2018 13:50:47 +0200 Message-Id: <20180924113111.166599966@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sagi Grimberg [ Upstream commit 1b72b71faccee986e2128a271125177dfe91f7b7 ] If nvmet_copy_from_sgl failed, we falsly return successful completion status. Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support") Signed-off-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/io-cmd-file.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -209,22 +209,24 @@ static void nvmet_file_execute_discard(s { int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; struct nvme_dsm_range range; - loff_t offset; - loff_t len; - int i, ret; + loff_t offset, len; + u16 ret; + int i; for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) { - if (nvmet_copy_from_sgl(req, i * sizeof(range), &range, - sizeof(range))) + ret = nvmet_copy_from_sgl(req, i * sizeof(range), &range, + sizeof(range)); + if (ret) break; offset = le64_to_cpu(range.slba) << req->ns->blksize_shift; len = le32_to_cpu(range.nlb) << req->ns->blksize_shift; - ret = vfs_fallocate(req->ns->file, mode, offset, len); - if (ret) + if (vfs_fallocate(req->ns->file, mode, offset, len)) { + ret = NVME_SC_INTERNAL | NVME_SC_DNR; break; + } } - nvmet_req_complete(req, ret < 0 ? NVME_SC_INTERNAL | NVME_SC_DNR : 0); + nvmet_req_complete(req, ret); } static void nvmet_file_dsm_work(struct work_struct *w)