From patchwork Sun Dec 16 22:41:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10732593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1FAC14E5 for ; Sun, 16 Dec 2018 22:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C25AC29B4B for ; Sun, 16 Dec 2018 22:42:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFB9129B2D; Sun, 16 Dec 2018 22:42:27 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 77CDA29B5C for ; Sun, 16 Dec 2018 22:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731028AbeLPWmR (ORCPT ); Sun, 16 Dec 2018 17:42:17 -0500 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:52220 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730758AbeLPWmR (ORCPT ); Sun, 16 Dec 2018 17:42:17 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with ESMTP id Yf62geg8gThUeYf62gg634; Sun, 16 Dec 2018 15:41:15 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1gYf62-0004DS-PW; Sun, 16 Dec 2018 15:41:14 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li , stable@vger.kernel.org, Murphy Zhou Subject: [PATCH] CIFS: return correct errors when pinning memory failed for direct I/O Date: Sun, 16 Dec 2018 22:41:07 +0000 Message-Id: <20181216224107.16164-1-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfEe15opoqopfTRBJopBEjQextT9kIvKHLmYcxa2cjXKOGgaQ1Gk76SaDsG8K53H4v2VExPcKlQEO8E5qHDTURnh3q2S7qdLhBxv+nlhaxde6oCCCy4i+ WlS+myf6QtxJD9siqgHzQqXjWhY/wm5UOb6V1uOAZsM4eb4VNbYp+p9c+4w8hEWF6peYQnV6eYxgO0HYkRzut1auoVN2wAojo/LIftoooGhYwDqj5X67Rgd2 RdG5U7jyJvjt7H1WJi8CEGUUfENpX+o/a4sBaEAKe3VHMu9vPww/5anedhHcSahK7Kw4nfwhPYmMj8YcYHBJW9UD66EfZNyb5jBlHlAQo8HVpXBdZPRmobsJ J8jHVhciF8LiP/KYnJN9Q6/lwtzrDhZFD4xUJX5Gn3eQpW8c7dsEtCtbM1B3HvKoJIFF2M3TZJ/3MM/QDFJpQwaicj8gA08/ddB4o3GVnWNeT5p4wAzK8+kc 7krW/RcwJRUiWegf Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li When pinning memory failed, we should return the correct error code and rewind the SMB credits. Reported-by: Murphy Zhou Signed-off-by: Long Li Cc: stable@vger.kernel.org Cc: Murphy Zhou --- fs/cifs/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index c9bc56b..3467351 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2630,6 +2630,9 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, result, from->type, from->iov_offset, from->count); dump_stack(); + + rc = result; + add_credits_and_wake_if(server, credits, 0); break; } cur_len = (size_t)result; @@ -3313,13 +3316,16 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, cur_len, &start); if (result < 0) { cifs_dbg(VFS, - "couldn't get user pages (cur_len=%zd)" + "couldn't get user pages (rc=%zd)" " iter type %d" " iov_offset %zd count %zd\n", result, direct_iov.type, direct_iov.iov_offset, direct_iov.count); dump_stack(); + + rc = result; + add_credits_and_wake_if(server, credits, 0); break; } cur_len = (size_t)result;