Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1250907pxx; Tue, 27 Oct 2020 11:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdF4OwSTIJvU2WIVt4qKnNqW7EflEQCcd5/iayDmc9xqOtYCDkL2jEdZHN7n4IcYq6q0JE X-Received: by 2002:a17:906:cc8b:: with SMTP id oq11mr4066797ejb.116.1603824666905; Tue, 27 Oct 2020 11:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603824666; cv=none; d=google.com; s=arc-20160816; b=W3x0fRsfIKbYlanI0C+WxUNvMaoVW5h8tGT4RCsI1oKlxeQ8nGXekNj5V+OTEXW2P7 3bad+oKg1wz/8KRWgsLe6rIzAaaZZXH5er9fimSYVo7xbWQYiiags5yFpSaGKeTlnnID xHBZcDy2Qd9rMzzsy1QMr1x8oXFZKkOIFLeLyt+YyVp1qPY69jaLW9Xz9RrWgqXRQ3kA g4tOL3l3DrpsXIxAIEbGjPd7VqAUwKa7vj0ZVodYqHyt0Psj0EW5/hYJAaq8RnTTdQXF AEdGVgRhSWyKtXGAak9+3/vtmF4H//vg1BbWc4bUAEvIarR9CjUzFwhXs7LqNYL5fS7O AzKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=he3oon2by4geBjv3yPjcEOEK6PEWLhgFX8iTe+QX+ZU=; b=HUkC5dHnStw63JiCIlBglQE4v/xY5EVJdesIIaINLamF7W3pimAHViyeqtrDnfQjox 2vxTU3SXIZWVZC7AEwc1gEff7ypSXA3CeRDxglU8+TAQ3Hx4c/fZhEsKgF83wKbDxPvg syEWDa296Rqg9b3XEfC7YB9Js1TKN9t8BwB0IxYSyK1O5BqzrSyZx8umMFfIq6BT2DTf b1HkvRvAIgVywrAcz9149a51PZXDlCw37pDTeRd30zAr1V89keKl4+A/G/oVvAExIrse SHIEpJK8++nLmBf0MH1IDSjnL+d6RrztB4ferhFPdXvpm0pgTcIfBkwd66+KGrgihws5 WPmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="JqT3/9+E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e2si1379609edc.604.2020.10.27.11.50.42; Tue, 27 Oct 2020 11:51:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="JqT3/9+E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2443695AbgJ0Abj (ORCPT + 99 others); Mon, 26 Oct 2020 20:31:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:52900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409502AbgJZXvm (ORCPT ); Mon, 26 Oct 2020 19:51:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB571218AC; Mon, 26 Oct 2020 23:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756301; bh=JpmxqkTpz4rmZAhfSnLc7BAVnmAQ2s5MIs2tFP4TLQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqT3/9+Ev5GqI/Y+JraH4R03b5yh95osudjct0W0aGAnNkLHxsVom8U8lBXbaVo/3 dV9zkmG3eVImLd4TeDATvmzehFzBlBjqDXb9KR/Mg4PqJWvLsatzRGuJt3n4IwSby8 qlxAK1WhakNOBXFHzETvAXmFYL+tc5Lu6Jbc2odk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rohith Surabattula , Aurelien Aptel , Pavel Shilovsky , Steve French , Sasha Levin , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 5.9 127/147] Handle STATUS_IO_TIMEOUT gracefully Date: Mon, 26 Oct 2020 19:48:45 -0400 Message-Id: <20201026234905.1022767-127-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rohith Surabattula [ Upstream commit 8e670f77c4a55013db6d23b962f9bf6673a5e7b6 ] Currently STATUS_IO_TIMEOUT is not treated as retriable error. It is currently mapped to ETIMEDOUT and returned to userspace for most system calls. STATUS_IO_TIMEOUT is returned by server in case of unavailability or throttling errors. This patch will map the STATUS_IO_TIMEOUT to EAGAIN, so that it can be retried. Also, added a check to drop the connection to not overload the server in case of ongoing unavailability. Signed-off-by: Rohith Surabattula Reviewed-by: Aurelien Aptel Reviewed-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/cifsglob.h | 2 ++ fs/cifs/connect.c | 15 ++++++++++++++- fs/cifs/smb2maperror.c | 2 +- fs/cifs/smb2ops.c | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index b565d83ba89ed..5a491afafacc7 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -510,6 +510,8 @@ struct smb_version_operations { struct fiemap_extent_info *, u64, u64); /* version specific llseek implementation */ loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int); + /* Check for STATUS_IO_TIMEOUT */ + bool (*is_status_io_timeout)(char *buf); }; struct smb_version_values { diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index a5731dd6e6566..1a3b7793095e4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -69,6 +69,9 @@ extern bool disable_legacy_dialects; #define TLINK_ERROR_EXPIRE (1 * HZ) #define TLINK_IDLE_EXPIRE (600 * HZ) +/* Drop the connection to not overload the server */ +#define NUM_STATUS_IO_TIMEOUT 5 + enum { /* Mount options that take no arguments */ Opt_user_xattr, Opt_nouser_xattr, @@ -1117,7 +1120,7 @@ cifs_demultiplex_thread(void *p) struct task_struct *task_to_wake = NULL; struct mid_q_entry *mids[MAX_COMPOUND]; char *bufs[MAX_COMPOUND]; - unsigned int noreclaim_flag; + unsigned int noreclaim_flag, num_io_timeout = 0; noreclaim_flag = memalloc_noreclaim_save(); cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current)); @@ -1213,6 +1216,16 @@ cifs_demultiplex_thread(void *p) continue; } + if (server->ops->is_status_io_timeout && + server->ops->is_status_io_timeout(buf)) { + num_io_timeout++; + if (num_io_timeout > NUM_STATUS_IO_TIMEOUT) { + cifs_reconnect(server); + num_io_timeout = 0; + continue; + } + } + server->lstrp = jiffies; for (i = 0; i < num_mids; i++) { diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c index 7fde3775cb574..b004cf87692a7 100644 --- a/fs/cifs/smb2maperror.c +++ b/fs/cifs/smb2maperror.c @@ -488,7 +488,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = { {STATUS_PIPE_CONNECTED, -EIO, "STATUS_PIPE_CONNECTED"}, {STATUS_PIPE_LISTENING, -EIO, "STATUS_PIPE_LISTENING"}, {STATUS_INVALID_READ_MODE, -EIO, "STATUS_INVALID_READ_MODE"}, - {STATUS_IO_TIMEOUT, -ETIMEDOUT, "STATUS_IO_TIMEOUT"}, + {STATUS_IO_TIMEOUT, -EAGAIN, "STATUS_IO_TIMEOUT"}, {STATUS_FILE_FORCED_CLOSED, -EIO, "STATUS_FILE_FORCED_CLOSED"}, {STATUS_PROFILING_NOT_STARTED, -EIO, "STATUS_PROFILING_NOT_STARTED"}, {STATUS_PROFILING_NOT_STOPPED, -EIO, "STATUS_PROFILING_NOT_STOPPED"}, diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index d44df8f95bcd4..8c3b997e718a0 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2346,6 +2346,17 @@ smb2_is_session_expired(char *buf) return true; } +static bool +smb2_is_status_io_timeout(char *buf) +{ + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; + + if (shdr->Status == STATUS_IO_TIMEOUT) + return true; + else + return false; +} + static int smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, struct cifsInodeInfo *cinode) @@ -4809,6 +4820,7 @@ struct smb_version_operations smb20_operations = { .make_node = smb2_make_node, .fiemap = smb3_fiemap, .llseek = smb3_llseek, + .is_status_io_timeout = smb2_is_status_io_timeout, }; struct smb_version_operations smb21_operations = { @@ -4909,6 +4921,7 @@ struct smb_version_operations smb21_operations = { .make_node = smb2_make_node, .fiemap = smb3_fiemap, .llseek = smb3_llseek, + .is_status_io_timeout = smb2_is_status_io_timeout, }; struct smb_version_operations smb30_operations = { @@ -5019,6 +5032,7 @@ struct smb_version_operations smb30_operations = { .make_node = smb2_make_node, .fiemap = smb3_fiemap, .llseek = smb3_llseek, + .is_status_io_timeout = smb2_is_status_io_timeout, }; struct smb_version_operations smb311_operations = { @@ -5130,6 +5144,7 @@ struct smb_version_operations smb311_operations = { .make_node = smb2_make_node, .fiemap = smb3_fiemap, .llseek = smb3_llseek, + .is_status_io_timeout = smb2_is_status_io_timeout, }; struct smb_version_values smb20_values = { -- 2.25.1