Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4807865ybi; Mon, 15 Jul 2019 15:18:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9eLfCJYRFoio6WmXeK9AqJ6dI45ZcX/ZgxB/DhjbliwITHYFvez9/q6AeAf10zm0TURy5 X-Received: by 2002:a63:755e:: with SMTP id f30mr29530814pgn.246.1563229134590; Mon, 15 Jul 2019 15:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563229134; cv=none; d=google.com; s=arc-20160816; b=ePQjCn2vNchKndpaycDGuxrNivwfSq7Ow7/xep6hnauAtRfZJYSKdD7JyuvcJ0i4PN TPgBunerzfPPA92VaSuMZQGQ7TPo0R06egm2IlCiJExA0w/M95nkzWvIoJygziC5/L0h SrCM8DhFwdQlbknfZoR4q0REX7iJ8F9batthHpEooO2z0nh4i3m4H/zYAibBwpkKMHtj QX+jytDUxDBNoV/magwP2iJ+B2zQKCvw6O+hRlzf6jXO8xDtmfr1oSFDaLqegqpbwCQD a68jdu3ofQ1Xlt1NqYqWGhkAidrrz+P0zH81h0FUiljiwjJZyVaL52hlIjLfK4ji653O aF0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:message-id:date:cc:to:from; bh=ySN7dqCgYdAgbG0zLigwiWJKhi3q1Au/NjrLJaTQ2Hw=; b=hLRfbA9etGER5feXAXuiJrRFObJlsXqUGkv3vWoRdO/KMZ64M2EGoovI6qs2V16gll CHAsuyNdCozsEdn1YM0e+NgyswRPMPu4v9vNK6gzL4Zt8GR6X29OAcrhSknLCmTG/ee/ P3m+mJXa0SMTVtPZMeO6ewKu+4c63KzKWFR1guNz6qZsMwjAXGCsMz7WyR6YZf1Tf7FC 5gB5YIRhDfbr72F3e/JogRLDxSy+p0W88AMEA/Scwz32/NbhSRxx/+1hydl9Bxi3QrBY dF0XfanPDu0JoJ1pf/pEou5pvqTd1bs/5YY11+yTJ3AmnQrCzYelC2RLVK73vqsWTdZm GTGQ== 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 y134si17307322pfc.285.2019.07.15.15.18.37; Mon, 15 Jul 2019 15:18:54 -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 S1733036AbfGOWRM (ORCPT + 99 others); Mon, 15 Jul 2019 18:17:12 -0400 Received: from ale.deltatee.com ([207.54.116.67]:60782 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbfGOWRM (ORCPT ); Mon, 15 Jul 2019 18:17:12 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hn9HS-0006TZ-ME; Mon, 15 Jul 2019 16:17:11 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1hn9HQ-0000rN-G1; Mon, 15 Jul 2019 16:17:08 -0600 From: Logan Gunthorpe To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Sagi Grimberg , Logan Gunthorpe , Chaitanya Kulkarni Date: Mon, 15 Jul 2019 16:17:07 -0600 Message-Id: <20190715221707.3265-1-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, hch@lst.de, sagi@grimberg.me, logang@deltatee.com, chaitanya.kulkarni@wdc.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v2] nvmet-file: fix nvmet_file_flush() always returning an error X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Presently, nvmet_file_flush() always returns a call to errno_to_nvme_status() but that helper doesn't take into account the case when errno=0. So nvmet_file_flush() always returns an error code. All other callers of errno_to_nvme_status() check for success before calling it. To fix this, ensure errno_to_nvme_status() returns success if the errno is zero. This should prevent future mistakes like this from happening. Fixes: c6aa3542e010 ("nvmet: add error log support for file backend") Signed-off-by: Logan Gunthorpe Cc: Chaitanya Kulkarni --- drivers/nvme/target/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 7734a6acff85..e1f03cfc6675 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -43,6 +43,9 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno) u16 status; switch (errno) { + case 0: + status = NVME_SC_SUCCESS; + break; case -ENOSPC: req->error_loc = offsetof(struct nvme_rw_command, length); status = NVME_SC_CAP_EXCEEDED | NVME_SC_DNR; -- 2.20.1