From patchwork Sun Jan 21 03:32:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524483 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D81014A86 for ; Sun, 21 Jan 2024 03:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808011; cv=none; b=J1I/bNNjWPSCCdxYhkdstmB6zOlhobRDQy06lzj7umHR3KINh5oALVHj3Zj8Li/mAoCIkAcIaTMSaO+hLQPc/C0K77mb+2tF9R458vvCpaBJtNhdt01eQKsAnaZ5zAUhMKch8ssXpqq705kJzcwBumQjwERxGZHpFcnarZpn/Kc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808011; c=relaxed/simple; bh=uqDbmFSByVvRNeTTZHSXk4I5Gv8FrqP+WbBAk4QwjIM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Xvfm4ad2JFXA3L2ofJWLQzfmn1b3DAJB+H0BHTzFEY0Bqrcaeawi6R2YDfmTU4dVM9oOO0M0Ijqcru2X2x3NK1DGu6ID5U4hN2gYZHVtQ+6/8YSp6kYWbYRS38/DDhsQGzXff3uHrXSP1oyQnXUmx4JkCKYqBebObh0Q2YxfuUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FgT+j4YF; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FgT+j4YF" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d711d7a940so18109505ad.1 for ; Sat, 20 Jan 2024 19:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808008; x=1706412808; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mQY07eVENXJvJY2t9RANhSsCrPeLpydJswtQ+6Z2+y8=; b=FgT+j4YFQKzdTOITb3XFfBQS86MYDt7znQmB0Q1qyJXOrAWmCkkiKLhcslHOtmy9pu ZE34A5UGkfeY02NUFYDaQjXyqmxJ3tQpwRo1WeHmPyzav4pmr0xD1m5y7gYOuQ6tX9JG xD2SNLDqW+/nhoTCfSXKnwlYP8jT37+Dkq+EazeiUWlhypcDGRwB3W/X1ErqHZvSgxR0 4BZN4kPzKsYBlFd6D3tI1feAia8I8iZd1nSvlUNSxFqUynsnS7qra44/anP9jNtDAidR zSAYEUuzs3i52tqETlvADg0BM6wBjYlqK9CoXNkHY2sJopQAj1rCfDz4dAH++ZMwZV2D WCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808008; x=1706412808; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mQY07eVENXJvJY2t9RANhSsCrPeLpydJswtQ+6Z2+y8=; b=kCzrDlhrJWnSrhRgvHquHV14a2DjN1MB3C/YvaxIiKTHlmtIVQtIJGjRdyLRRwjBBL fmFhDn+LZJZT7u3LAisTwmiiPgWW9GamQu51ilnsipEXhOVHB5Dy0eoWF0Fky4XTe8e0 RPdNJmJ2lifOEiS1jaQuwN9+28PvSeubGh07UuY5eUSMzTrWgMmSpqnbPQGNpZzb4I5f 1ebC00nU9f205yPSEbZkQNvshZs/UXKbm8/mGD4X/TFSqrE4+m8+gTYYj4csF18PNYaR v931iMH7sdYspiwU2C4kv8NNVNpisEyF6ihAhYXS/2uuW0uz1t4qu9XWAQpfjmAhnsz3 IFlQ== X-Gm-Message-State: AOJu0Yxf9+W3g2f4pPdgSkyLWs5RDDXobD2XLguwCw1p+XWhE3VJlII2 WzSuz5PZvy4mRMxHCHWL9ATveQ4r2AxBbvw7+uK87y3PoHNAMln8dt0S1gP9 X-Google-Smtp-Source: AGHT+IGxJHMnHo5be5oP2Ov7u8IwstQ/LVfGweLBPG95I3/Pe0vsxLbOcr33g9M/L6s892TTNeVMHw== X-Received: by 2002:a17:902:ed4d:b0:1d6:ff40:665d with SMTP id y13-20020a170902ed4d00b001d6ff40665dmr2390496plb.93.1705808008385; Sat, 20 Jan 2024 19:33:28 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:27 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 1/7] cifs: handle servers that still advertise multichannel after disabling Date: Sun, 21 Jan 2024 03:32:42 +0000 Message-Id: <20240121033248.125282-1-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N Some servers like Azure SMB servers always advertise multichannel capability in server capabilities list. Such servers return error STATUS_NOT_IMPLEMENTED for ioctl calls to query server interfaces, and expect clients to consider that as a sign that they do not support multichannel. We already handled this at mount time. Soon after the tree connect, we query server interfaces. And when server returned STATUS_NOT_IMPLEMENTED, we kept interface list as empty. When cifs_try_adding_channels gets called, it would not find any interfaces, so will not add channels. For the case where an active multichannel mount exists, and multichannel is disabled by such a server, this change will now allow the client to disable secondary channels on the mount. It will check the return status of query server interfaces call soon after a tree reconnect. If the return status is EOPNOTSUPP, then instead of the check to add more channels, we'll disable the secondary channels instead. For better code reuse, this change also moves the common code for disabling multichannel to a helper function. Signed-off-by: Shyam Prasad N --- fs/smb/client/smb2pdu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 288199f0b987..5126f5f97969 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -167,7 +167,7 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, if (SERVER_IS_CHAN(server)) { cifs_dbg(VFS, - "server %s does not support multichannel anymore. Skip secondary channel\n", + "server %s does not support multichannel anymore. Skip secondary channel\n", ses->server->hostname); spin_lock(&ses->chan_lock); @@ -195,15 +195,13 @@ cifs_chan_skip_or_disable(struct cifs_ses *ses, pserver = server->primary_server; cifs_signal_cifsd_for_reconnect(pserver, false); skip_terminate: - mutex_unlock(&ses->session_mutex); return -EHOSTDOWN; } cifs_server_dbg(VFS, - "server does not support multichannel anymore. Disable all other channels\n"); + "server does not support multichannel anymore. Disable all other channels\n"); cifs_disable_secondary_channels(ses); - return 0; } @@ -441,6 +439,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, } skip_add_channels: +skip_add_channels: if (smb2_command != SMB2_INTERNAL_CMD) mod_delayed_work(cifsiod_wq, &server->reconnect, 0); From patchwork Sun Jan 21 03:32:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524484 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DEC14A86 for ; Sun, 21 Jan 2024 03:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808013; cv=none; b=Halc1lCmXoXgoCEc87QGMlI+kj56lk7le+eX7NnwgLbreXre7FSbKSQCkZtfWBXlICUJgYnngB2eKq4zlY/AMIWFbhVXW+3Jv4XgipaNow1y+atkVPNxVpCg3ooIgMFJo4qdhz6wQJgmUxWLVyiwpoQFoFku+BVZcgHLL0VZ9Oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808013; c=relaxed/simple; bh=d7xOoPr+emIgghq+1AeKqK9EZdJF6HM3+bTGH2FGkpc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UK79M/l4g5+UEsQplEaI2nw+ac7ncC0rqx6YwOUiMbpkZtLdqgSm/+U7iqKgMWAPOKL3zFRS/J9j/MTYZ4twLlHgNhihP9JzSCU8bVAFJvmil0iY2SQT1KxmorEJ4HfaA2AVtpBfDZgzzxOqOmH4I/YElMTIEY9VBTcu1+nlVno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Nlee4Nvd; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Nlee4Nvd" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1d70c3c2212so13939885ad.1 for ; Sat, 20 Jan 2024 19:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808011; x=1706412811; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MyF2ti/xOtbycXy2eQXdfyxSKLKFCqbz6fPNhn1NIO8=; b=Nlee4NvdSJOb1NzBQJa1jqmbh2A9zVPTTDZtVq9qBXRHIVzQ5gQl6BkSgdpTI72Mce 8I9Y78wfbSJFUryyn+ai7EzOjBYLrZrbaKRzcRqt7KjNLuOySTvQHE2bxHgwbdY3QzkO t2SMxJ4+9kCr6Z6dKZuilOMWTnKxpu0xr/84hrIg0eywI2WJPf5M/irmE2T6QegwNLL4 Mc7JnW2fef06YkpIPJIYtP0JFOFm4MBu0OqM/knTUKl6tW/CET+EBPO/PlrlX3V9mFSF LcHKZLZcyWjIxQV0hi20j2sxCAEH4RHH7qLY3/ojwYvFaSaeIK37wWnXtoZHXkk7qj9Z W8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808011; x=1706412811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MyF2ti/xOtbycXy2eQXdfyxSKLKFCqbz6fPNhn1NIO8=; b=RxorWXQpaCqvSdnT043E1pQU+9oYXU9057ivh3AoV0bwFyKh5NHcbocBK6SqW/wX+v h0qUA184xFDVhSdziG+H7SZm1tk5sn2hQ/LWb7KncziXklNZ24RRoATAIzK9KqN5hg3i HDbmgxT3IllsI5a2H5Owq6UkPd6lhvQPD74s3QT5GstMxvOrDVteRdpnEtyDOBRp4Db1 0IDwnqRIajNuvy8FCSukGQhJQroVZri+8STWhdY356fKo3CjKD25ZffwSwExGT4ILIV2 i4OY/CjwXOm4m02BMFlePmUy5kY/22ENvn6hXH1hNqfFzUETRwlRmOEnrWTg8JNr9VdF lHpw== X-Gm-Message-State: AOJu0Yw8Wukqp+AibnU+eIhw1wkEaPsA+UNal9qXEOb+N/GpbQU8MHfw BcNM23v0qitzuJ3fAS6pabkGmy4B6SKTe/NNF70sVCms8q6SC9bFiyZ3fA5I X-Google-Smtp-Source: AGHT+IEEYt2d/omRRZBnR3pVTH8bexj4Zhoj+CVO3R0E1zb7ArdG/ErgdIyQgvcEIQAVc2IdXFac3g== X-Received: by 2002:a17:902:bf0c:b0:1d3:edd9:1f13 with SMTP id bi12-20020a170902bf0c00b001d3edd91f13mr2291504plb.67.1705808011091; Sat, 20 Jan 2024 19:33:31 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:30 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 2/7] cifs: cifs_pick_channel should try selecting active channels Date: Sun, 21 Jan 2024 03:32:43 +0000 Message-Id: <20240121033248.125282-2-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N cifs_pick_channel today just selects a channel based on the policy of least loaded channel. However, it does not take into account if the channel needs reconnect. As a result, we can have failures in send that can be completely avoided. This change doesn't make a channel a candidate for this selection if it needs reconnect. Signed-off-by: Shyam Prasad N --- fs/smb/client/transport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c index 4f717ad7c21b..8695c9961f5a 100644 --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -1026,6 +1026,9 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses) if (!server || server->terminate) continue; + if (CIFS_CHAN_NEEDS_RECONNECT(ses, i)) + continue; + /* * strictly speaking, we should pick up req_lock to read * server->in_flight. But it shouldn't matter much here if we From patchwork Sun Jan 21 03:32:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524485 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 793B514A86 for ; Sun, 21 Jan 2024 03:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808016; cv=none; b=re6KmFhgLMnb6maN3YZUuZ2FZtRGt+q7Yo4SBzAKo4TRSz12xbA1xrKUk8UEh+ASiYarbPcQAQ2655ofG06pTXT9fXZkpSHQKcInYxRrWSqIt+07ax9EVIcfG1xxrrZt8ZjjntBRd4sC1bU5clHnhc0HwsW09LjweOzGYdPbj0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808016; c=relaxed/simple; bh=4F5ClitWe47kq3A29eFByKbVBCQuDDdkDJB88zL0Cs0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ihGwLQNuRXEYU7hd9pYC56t8es8lYV2TBZnxhsIW693wsCQ8hpPFEftCQlhJbxUZGcmcsBTdgybTY7buAXidTXjCMJgEHUVhiKcr5HwEazpBpvbvlfVQ9KC7E5Fd76tK23ZLKdFILqQNKmU58ca9BBzWZdQS9VZpMwU70HHOnCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SBYRNLSz; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SBYRNLSz" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6daf694b439so1338944b3a.1 for ; Sat, 20 Jan 2024 19:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808014; x=1706412814; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZsvZ9wp7r/vrwBrSEVi+y2DE6g0VhzvM7Ta3kQvqaJk=; b=SBYRNLSzNrcA2RJ7viKjoJuESqd44bU5M7nM73R0b2M1aAmS0Y7G5j4DboCzND9HGb L4/oKljMv2deeO63FEYh0+yGDlfXIloK2SSuzagfvxBQaPiQ0m5EL7HSDUOoDneaUECy P9DYtYAluhltyAa3e9PMURf2kdOKEePX1TaDKwC43VrsxKseXxBugh9ADH+SwRMr2j6j BKfyc+oWkEpbF94ssClraw7BZ3HbRkwS6fYY//aRYlCn+vwz+bqcMKHg4rJZHCV/+GW3 ZSfK1ByBGAAZlVSpnwCYhbLaZK9l0cSo1NT7xCH/1nByBlFRK9Wq4pXyPZP7FLZeBlVL LDQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808014; x=1706412814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZsvZ9wp7r/vrwBrSEVi+y2DE6g0VhzvM7Ta3kQvqaJk=; b=LjAYLN2R7KkOkQx03h6aLZOFaNZvj9xhvLADW/gUguFwmLgllIeyhLHbh3y6jgiK4a YiDb4Hs0735p9mcwYBW4jGcPAxh6FtB9b2rruzRPdBAiI0mimMRKmcEeHUPco9GvqxeK NKp5VRkO8WZ/jvqTEumGmUsPA9OKnqhGb03xA4asv6exwM9vyqXpmrkTPdLRsX0qmKE5 +87iN/dA/6qSQ13yODl4DGEsIgimeJ9wqGuUDLVUYqRg4hOL2fBm0qcRAf3GivcR9kVi OdwWZTkkzA4TwOAxsj48xPZJDxR5RQHBRkbxe1OmXluDkrBGMdFXdZ3HyuYT2fR3b6RJ Zr/g== X-Gm-Message-State: AOJu0YyCEpueNtTcR6wjpTyNdjcVfOZJ5E3qTuwlr4WuWojP13Z/gzIB /W99H56uyeGlDgelbsygcnYhqsoVttWqt/d1C5O8wOOCfAlM0/iiu7HeivW4 X-Google-Smtp-Source: AGHT+IEvTwjJAgcDviOjlYp+eDZrNzV+o9imrBndSWbZ/+HZNJY7c21rfReppB2qalsS3ufKvQoDrQ== X-Received: by 2002:a05:6a20:2d29:b0:19b:ffea:43f4 with SMTP id g41-20020a056a202d2900b0019bffea43f4mr570135pzl.103.1705808013794; Sat, 20 Jan 2024 19:33:33 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:33 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 3/7] cifs: smb2_close_getattr should also update i_size Date: Sun, 21 Jan 2024 03:32:44 +0000 Message-Id: <20240121033248.125282-3-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N SMB2 CLOSE command with SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB flag set is already used by the code for SMB3+. smb2_close_getattr is the function that uses this to update the inode attributes. However, we were skipping the EndOfFile info that's returned by the server. There is a small chance that the file size may have been changed in the small window between the client sending the close request (thereby giving up lease if it had) to the point that the server returns the response. This change uses the field to update the inode size. Also, it is a valid case for a zero AllocationSize to be returned by the server for the file. We were discarding such values, thereby resulting in stale i_blocks value. Fixed that here too. Signed-off-by: Shyam Prasad N --- fs/smb/client/smb2ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index d9553c2556a2..e23577584ed6 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -1433,9 +1433,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon, * but instead 512 byte (2**9) size is required for * calculating num blocks. */ - if (le64_to_cpu(file_inf.AllocationSize) > 4096) - inode->i_blocks = - (512 - 1 + le64_to_cpu(file_inf.AllocationSize)) >> 9; + inode->i_blocks = (512 - 1 + le64_to_cpu(file_inf.AllocationSize)) >> 9; + + inode->i_size = le64_to_cpu(file_inf.EndOfFile); /* End of file and Attributes should not have to be updated on close */ spin_unlock(&inode->i_lock); From patchwork Sun Jan 21 03:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524486 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2374014A86 for ; Sun, 21 Jan 2024 03:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808019; cv=none; b=QCbnJtntxeci9vYNyqYVt6sSQTWTgJZU2h/HZd0KULkfnhbmPVVapvDYeVFP/dir3C9ot3wfWoPaYtH/5s37DG1GGszs9Sd20amNQ1GLhB/AwZZXHaUEbaPeAnUBk6LEjh/N7he7JD0dsZ6akJpHf2Mfg4OfJU6VRmCmRfdSKnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808019; c=relaxed/simple; bh=i61PuFh/wQd+kXhI4UUBpYJWFFE3nBkckJ8tFi9JYHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q6yC3gXDYQliBjh5VVj8KzxHJ+rVWcNOFRmhjhhrQJfPkTG2Oue4Jcnf3h9JhcPHXwSGxQYrhndgoKCtU3hF0R0M2YHvvsvfSlmHKtuOYW0F4r6kqzswvLw2xWxBpu7JvM1NGCFJd/iuemxBVg+54zsHPITl8hYSdGLkU/dtY7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PIveEs13; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PIveEs13" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d50d0c98c3so24948655ad.1 for ; Sat, 20 Jan 2024 19:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808016; x=1706412816; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EST9085IKoYTHTEDL2YdtVvlycK0/tJ49SC7HqvCQM0=; b=PIveEs13IVHDNqzEYR76bYbPFh1WniZKUR5zwRy9OZ0f2Bo2U9TDGQ1xoNLhpyvC/A hRFRBMK+Vf1A5KrtCpiCeLx7Ej84K9AWOk+Gu5AfIvw1prm10EOKN2giMpaGeKoY8d59 cQ/ofyzBDcyRycLwkrlZHCJCWZu0a5s+JXi9ZS3BDj6z4QkieErG3GrD0+/8lgu2XGi4 CRk2QXhroKSnGyMMTxyQ66af9j5w2sCYWpkjFRw0wQOswU+/9NogObLXZBLaznAg0Y3z nUKLcxEHQumz8KkKRAD8CDhzEyLt5hYxH96PvWTcK6FErzfUnesdzt2UpRC6QIMiIHBU r3kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808016; x=1706412816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EST9085IKoYTHTEDL2YdtVvlycK0/tJ49SC7HqvCQM0=; b=QfX+2VuZDAS+64p7+4zkK6jviIkoJmHeQ8hPjiEFtqGnWzdts7qdN4N5ohaWLcwj2X jrNdtvaY517pgX775FRwR13n6/b27kM9o544KIXwP3jiBjvTV7EzquGT1MpxsFlfUWL5 KsiIy07itnlmVPlGDmgEEiQA5r8/RRTh0/46fxHP/VSHRHlVRMHiy+ApyslUTLY9tVRn jj1uMJWrKOia0Yycseig0fW3NHy0+7efeBESnbhb1pX8i3Nr7fhOIPS0cZCGl6Xq9ueM EWt7/CEcRhmuujDirA+kHIZdkLi7VIxwv1DGp2WDUoO3SPtzAigwUs6g2IcMwA6520EO JwrA== X-Gm-Message-State: AOJu0YzD15Fv0a6hhznWZeYOF82wHxJQPG0cSgoF8nQOz16qFdaxjY5D gwdAyIOa/FhFXvX6eryzNIO1Ne1Ch7LkMdmkvdt1ylhm9lALZp7jHTObkIiZ X-Google-Smtp-Source: AGHT+IHKSku4zCmHXp8q229sKRSYzHiRP/Udfyn7rIgZvJLODv3i0iJyMlfLrvGdKcGQH6UQKypCMw== X-Received: by 2002:a17:902:ec06:b0:1d7:271f:b15f with SMTP id l6-20020a170902ec0600b001d7271fb15fmr2972158pld.25.1705808016534; Sat, 20 Jan 2024 19:33:36 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:36 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 4/7] cifs: translate network errors on send to -ECONNABORTED Date: Sun, 21 Jan 2024 03:32:45 +0000 Message-Id: <20240121033248.125282-4-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N When the network stack returns various errors, we today bubble up the error to the user (in case of soft mounts). This change translates all network errors except -EINTR and -EAGAIN to -ECONNABORTED. A similar approach is taken when we receive network errors when reading from the socket. The change also forces the cifsd thread to reconnect during it's next activity. Signed-off-by: Shyam Prasad N --- fs/smb/client/transport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c index 8695c9961f5a..e00278fcfa4f 100644 --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -400,10 +400,17 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, server->conn_id, server->hostname); } smbd_done: - if (rc < 0 && rc != -EINTR) + /* + * there's hardly any use for the layers above to know the + * actual error code here. All they should do at this point is + * to retry the connection and hope it goes away. + */ + if (rc < 0 && rc != -EINTR && rc != -EAGAIN) { cifs_server_dbg(VFS, "Error %d sending data on socket to server\n", rc); - else if (rc > 0) + rc = -ECONNABORTED; + cifs_signal_cifsd_for_reconnect(server, false); + } else if (rc > 0) rc = 0; out: cifs_in_send_dec(server); From patchwork Sun Jan 21 03:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524487 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D15FE14A86 for ; Sun, 21 Jan 2024 03:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808022; cv=none; b=oGocPSYhYf2sTMNjQU8/jxw+yg4Vlu34hy9UhI1rsGiZOXHlsWkM9rcKUVxqSrRMAjqExktRvcMCKvOShLwL3b5j3wyoq1I7R5THL2fAvSPd6vxM9swdq88hJ1rhgtiT6e/5iQozDVWy5d7mQsDCXiCCrjqXXg3R3l01I6JTKuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808022; c=relaxed/simple; bh=ezL4tFtj37vizPg8VDCsPn5VQNBt17K7UfRKtptiuQg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H++xp1D0T3aeivl3AW6ybCB9atGo11uNP0cCaNDGp+G+edzkqsyVHgLx8YIHcEvJCIywB3BCOqelqBgNcQYbeQbIuMsCRTwQ0QpZOZuL+bI9t3Ab+NwzAmNAC0WDqdOtPwI/p4B0pgy0uHKGmqGTNF+js0Qw+fVOC6/7mY7815g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YGCObl84; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YGCObl84" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d51ba18e1bso18597275ad.0 for ; Sat, 20 Jan 2024 19:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808019; x=1706412819; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KKSAYhZIbcehbrlijLijLmeT7Q+zPuIM/lOAGoSkaas=; b=YGCObl84MFD+oatonuEsMzOfVh/9xrCik7FiFys7J25h+6dwkm4FtYGFqhIXPqzvnk Q6hTpz/9X6JqYpJjWngu4SqKZgNaFEqe+yetLseiWTVBB3IASEJXbpFfyfCY/J1AmyOT qapaigqmY8jrd6iUkqGFKOQGSSYCF9VfWu4SP6NLc5Mwl1KakgE5ESAIZl9a9UMSDBek sNXR1eT0rRNEs3EvQOrWO2+WC4r+tf4RM1vrXIBQSCXFKqs+DxOhR11jW7vqE5pulvoz 6oGFf1OvBzPzvlyfEFTB9d7h8eA+6oCIHHUeeKTbsz0agb3wegM1wb9SFqWPSWCbgsPW STAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808019; x=1706412819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KKSAYhZIbcehbrlijLijLmeT7Q+zPuIM/lOAGoSkaas=; b=I4fwjye7gl7/ctpKv78KKhZB7C8J3YYG6fpRMcFYwccovp95mjmlq+cCRJBqQBjhX9 Ff9aJB9r5w0psryCSPGTFcN8NqPlRuXFXABHe6Cu2IP1MTK3XZXmVyaQRQHL9M+0eTRL kT9LtMPUGNqipOK+I1coZbOYh/rm4PEyAOj9P7x4mNYy7wknyCFx455fMt8K9qTcfVpm 3fuhw/TLM8x1JVB218rlxh3bXbPoB4SxaYGkX+NBYxmNRnzYYRqhUGLSL3jIfpe/dN1V 7RhgUDv89PdoZ1Nv2iEdxnbQnTgIDcnuXqmuSbBFVPf/kMf9WkIoSMX2F2w7YnokWVbP GAMQ== X-Gm-Message-State: AOJu0YzCaMSvPMEG9swK9JZ4hk4UwB2G6lsisWz4R9NuRuc95+NEarSQ q1nGvyzwuScf39UT1SEPurbrS8A+z+aQL5ogHbeGOPw0jIKLh82MK/wMQD00 X-Google-Smtp-Source: AGHT+IFvSIAnu7ubFbPyTZmnILpr47eAFwYi81QGR0V31Unmv36WLLbWpEzNmuYxnrM/4VfB0Y3jcw== X-Received: by 2002:a17:902:dac6:b0:1d7:215a:8065 with SMTP id q6-20020a170902dac600b001d7215a8065mr3559860plx.34.1705808019236; Sat, 20 Jan 2024 19:33:39 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:38 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 5/7] cifs: helper function to check replayable error codes Date: Sun, 21 Jan 2024 03:32:46 +0000 Message-Id: <20240121033248.125282-5-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N The code to check for replay is not just -EAGAIN. In some cases, the send request or receive response may result in network errors, which we're now mapping to -ECONNABORTED. This change introduces a helper function which checks if the error returned in one of the above two errors. And all checks for replays will now use this helper. Signed-off-by: Shyam Prasad N --- fs/smb/client/cached_dir.c | 1 + fs/smb/client/cifsglob.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 971892620504..5730c65ffb40 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -367,6 +367,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, atomic_inc(&tcon->num_remote_opens); } kfree(utf16_path); + return rc; } diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 20036fb16cec..6e4cfaec98e3 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1831,6 +1831,13 @@ static inline bool is_retryable_error(int error) return false; } +static inline bool is_replayable_error(int error) +{ + if (error == -EAGAIN || error == -ECONNABORTED) + return true; + return false; +} + /* cifs_get_writable_file() flags */ #define FIND_WR_ANY 0 From patchwork Sun Jan 21 03:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524488 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A2AD14A86 for ; Sun, 21 Jan 2024 03:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808025; cv=none; b=sgruGOO0VuAA9FeWRR+XRU4kitnvedGv2ZpXfQEYhFxxDm8gi1UxRUM2RK1/OkK1VyNHQdxR6PF2+pJVql+TFVMUZQi5p+Mzq23jGZEtfhLyh2TNflkkSe3Ua0q2cxGziuJijVT9MngXo3nQIdJC/IVwnTRHsFVIo+pKTEx7AuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808025; c=relaxed/simple; bh=ACUKW61VnFCKrGirXbbh16DNdV4WxTJVl68UVrTgkaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=efHQokOF8MINJ8qmLPv/9rGdJlMf8pPmD/7LSJ5RCvLWtSyR95yUUweGsGJXy7ss+qhJwnHNEYaedv+uhW6jlofO51sH6FEn2+nUIcUB8O4HRZ8qSGO9iHS56Ldt1hIkO4CyGGZ4lfX7EpfnkH3vF0oz8DOb5xDKsuIqBZvPM9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A07fmKVC; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A07fmKVC" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d71b62fa87so11904015ad.0 for ; Sat, 20 Jan 2024 19:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808022; x=1706412822; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8J1zc9ROEEswjbAYhC6JG1/9upIrapKab842HdC4SkY=; b=A07fmKVCeGggUkN28SBsT2BzpMg3oVw44gCszuOsAxsVj29klI0n3i8ihq1L6bxCwP ncWN8b+F0BYDhd4rqBL2m766ohH9nACEHMXvLtP1I2Ch+bCt3Jcs4UMtIlqElL3enQls mu0NL++IvMWGH/efnlUzFAhMhRjizNJsFsDi7B0y4rjv5Hb6MfWu7FqgORDCeEXV80KN dCeiiFXxfpeGKSUwffI+tuOANlIvbVGXOgMKW9esaM/yao9yrdp1pFCawSum2UHs5cQ9 rzWbH4Jm7d/p8cqJnqiPjUKKTWY31Tk4rsDT7amFvVBbU4vgH13BOVwDOidGy11Lrj6F PXnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808022; x=1706412822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8J1zc9ROEEswjbAYhC6JG1/9upIrapKab842HdC4SkY=; b=dReoCeCXc/lyabZ4IQyX2SeRN27sI06qJAn8opVQJHGHW7O4xrGxDH+b8A5h1vK3no 26GKAEqXZQ5CWVe4kHfO2KXedSXjNYRYPY/K1+YLbpOBms6rNaW8UkTQDSFq9eLx1qJm yXoaUO1/xVKznwYZfcQmMsXMd57AeJg6rMN7o+IEeDwLJgj3gM1KTwRum1Ro4AoFgPjo IdLkB3i2AFYDvFAUWi8hgxDMMZWF71nI+ZCc42ibcr0PZL6378XSEgpNmqChLC9wKqgV KU66Vm67S/VMEkpenBxp7Hqk2Z9bN+A1Q3QtPg/mo+5gF82napQLWWAIxHPGr5rhG/8x x/9Q== X-Gm-Message-State: AOJu0Yz/bRIhc5J0ieVjfLkaUco4DjvLCkcMutSEw8XDgfWfDvLxzwIB CcN6xm6KG83sJHy03GGbsSpCccILA4O/7jURVRQuva3srAo/Vjbq0r7SvdqX X-Google-Smtp-Source: AGHT+IEh6P60T1kLGz1xRJdWtQEJBDZ/Zbn20SnoziSeYhkVhHAEY/E2kT81W6mxq/+eFwCY2Jjqgg== X-Received: by 2002:a17:902:c40e:b0:1d7:2337:9ff4 with SMTP id k14-20020a170902c40e00b001d723379ff4mr3364010plk.46.1705808022079; Sat, 20 Jan 2024 19:33:42 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:41 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 6/7] cifs: commands that are retried should have replay flag set Date: Sun, 21 Jan 2024 03:32:47 +0000 Message-Id: <20240121033248.125282-6-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N MS-SMB2 states that the header flag SMB2_FLAGS_REPLAY_OPERATION needs to be set when a command needs to be retried, so that the server is aware that this is a replay for an operation that appeared before. This can be very important, for example, for state changing operations and opens which get retried following a reconnect; since the client maybe unaware of the status of the previous open. This is particularly important for multichannel scenario, since disconnection of one connection does not mean that the session is lost. The requests can be replayed on another channel. This change also makes use of exponential back-off before replays and also limits the number of retries to "retrans" mount option value. Also, this change does not modify the read/write codepath. Signed-off-by: Shyam Prasad N --- fs/smb/client/cached_dir.c | 23 +++- fs/smb/client/cifsglob.h | 5 + fs/smb/client/smb2inode.c | 33 ++++- fs/smb/client/smb2ops.c | 123 ++++++++++++++++-- fs/smb/client/smb2pdu.c | 260 +++++++++++++++++++++++++++++++++---- fs/smb/client/smb2proto.h | 5 + 6 files changed, 404 insertions(+), 45 deletions(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index 5730c65ffb40..1daeb5714faa 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -145,21 +145,27 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, struct cached_fid *cfid; struct cached_fids *cfids; const char *npath; + int retries = 0, cur_sleep = 1; if (tcon == NULL || tcon->cfids == NULL || tcon->nohandlecache || is_smb1_server(tcon->ses->server) || (dir_cache_timeout == 0)) return -EOPNOTSUPP; ses = tcon->ses; - server = cifs_pick_channel(ses); cfids = tcon->cfids; - if (!server->ops->new_lease_key) - return -EIO; - if (cifs_sb->root == NULL) return -ENOENT; +replay_again: + /* reinitialize for possible replay */ + flags = 0; + oplock = SMB2_OPLOCK_LEVEL_II; + server = cifs_pick_channel(ses); + + if (!server->ops->new_lease_key) + return -EIO; + utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); if (!utf16_path) return -ENOMEM; @@ -268,6 +274,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, */ cfid->has_lease = true; + if (retries) { + smb2_set_replay(server, &rqst[0]); + smb2_set_replay(server, &rqst[1]); + } + rc = compound_send_recv(xid, ses, server, flags, 2, rqst, resp_buftype, rsp_iov); @@ -368,6 +379,10 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, } kfree(utf16_path); + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 6e4cfaec98e3..b5abe4d6f478 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -49,6 +49,11 @@ */ #define CIFS_DEF_ACTIMEO (1 * HZ) +/* + * max sleep time before retry to server + */ +#define CIFS_MAX_SLEEP 2000 + /* * max attribute cache timeout (jiffies) - 2^30 */ diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c index a652200540c8..05818cd6d932 100644 --- a/fs/smb/client/smb2inode.c +++ b/fs/smb/client/smb2inode.c @@ -120,6 +120,14 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, unsigned int size[2]; void *data[2]; int len; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + oplock = SMB2_OPLOCK_LEVEL_NONE; + num_rqst = 0; + server = cifs_pick_channel(ses); vars = kzalloc(sizeof(*vars), GFP_ATOMIC); if (vars == NULL) @@ -127,8 +135,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, rqst = &vars->rqst[0]; rsp_iov = &vars->rsp_iov[0]; - server = cifs_pick_channel(ses); - if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; @@ -463,15 +469,24 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, num_rqst++; if (cfile) { + if (retries) + for (i = 1; i < num_rqst - 2; i++) + smb2_set_replay(server, &rqst[i]); + rc = compound_send_recv(xid, ses, server, flags, num_rqst - 2, &rqst[1], &resp_buftype[1], &rsp_iov[1]); - } else + } else { + if (retries) + for (i = 0; i < num_rqst; i++) + smb2_set_replay(server, &rqst[i]); + rc = compound_send_recv(xid, ses, server, flags, num_rqst, rqst, resp_buftype, rsp_iov); + } finished: num_rqst = 0; @@ -620,9 +635,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, } SMB2_close_free(&rqst[num_rqst]); - if (cfile) - cifsFileInfo_put(cfile); - num_cmds += 2; if (out_iov && out_buftype) { memcpy(out_iov, rsp_iov, num_cmds * sizeof(*out_iov)); @@ -632,7 +644,16 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, for (i = 0; i < num_cmds; i++) free_rsp_buf(resp_buftype[i], rsp_iov[i].iov_base); } + num_cmds -= 2; /* correct num_cmds as there could be a retry */ kfree(vars); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + + if (cfile) + cifsFileInfo_put(cfile); + return rc; } diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index e23577584ed6..17df0cd78698 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -1108,7 +1108,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, { struct smb2_compound_vars *vars; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; struct smb_rqst *rqst; struct kvec *rsp_iov; __le16 *utf16_path = NULL; @@ -1124,6 +1124,13 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, struct smb2_file_full_ea_info *ea = NULL; struct smb2_query_info_rsp *rsp; int rc, used_len = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = CIFS_CP_CREATE_CLOSE_OP; + oplock = SMB2_OPLOCK_LEVEL_NONE; + server = cifs_pick_channel(ses); if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; @@ -1244,6 +1251,12 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, goto sea_exit; smb2_set_related(&rqst[2]); + if (retries) { + smb2_set_replay(server, &rqst[0]); + smb2_set_replay(server, &rqst[1]); + smb2_set_replay(server, &rqst[2]); + } + rc = compound_send_recv(xid, ses, server, flags, 3, rqst, resp_buftype, rsp_iov); @@ -1260,6 +1273,11 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, kfree(vars); out_free_path: kfree(utf16_path); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } #endif @@ -1484,7 +1502,7 @@ smb2_ioctl_query_info(const unsigned int xid, struct smb_rqst *rqst; struct kvec *rsp_iov; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; char __user *arg = (char __user *)p; struct smb_query_info qi; struct smb_query_info __user *pqi; @@ -1501,6 +1519,13 @@ smb2_ioctl_query_info(const unsigned int xid, void *data[2]; int create_options = is_dir ? CREATE_NOT_FILE : CREATE_NOT_DIR; void (*free_req1_func)(struct smb_rqst *r); + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = CIFS_CP_CREATE_CLOSE_OP; + oplock = SMB2_OPLOCK_LEVEL_NONE; + server = cifs_pick_channel(ses); vars = kzalloc(sizeof(*vars), GFP_ATOMIC); if (vars == NULL) @@ -1641,6 +1666,12 @@ smb2_ioctl_query_info(const unsigned int xid, goto free_req_1; smb2_set_related(&rqst[2]); + if (retries) { + smb2_set_replay(server, &rqst[0]); + smb2_set_replay(server, &rqst[1]); + smb2_set_replay(server, &rqst[2]); + } + rc = compound_send_recv(xid, ses, server, flags, 3, rqst, resp_buftype, rsp_iov); @@ -1701,6 +1732,11 @@ smb2_ioctl_query_info(const unsigned int xid, kfree(buffer); free_vars: kfree(vars); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -2227,8 +2263,14 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_open_parms oparms; struct smb2_query_directory_rsp *qd_rsp = NULL; struct smb2_create_rsp *op_rsp = NULL; - struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses); - int retry_count = 0; + struct TCP_Server_Info *server; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + oplock = SMB2_OPLOCK_LEVEL_NONE; + server = cifs_pick_channel(tcon->ses); utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); if (!utf16_path) @@ -2278,14 +2320,15 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, smb2_set_related(&rqst[1]); -again: + if (retries) { + smb2_set_replay(server, &rqst[0]); + smb2_set_replay(server, &rqst[1]); + } + rc = compound_send_recv(xid, tcon->ses, server, flags, 2, rqst, resp_buftype, rsp_iov); - if (rc == -EAGAIN && retry_count++ < 10) - goto again; - /* If the open failed there is nothing to do */ op_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; if (op_rsp == NULL || op_rsp->hdr.Status != STATUS_SUCCESS) { @@ -2333,6 +2376,11 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, SMB2_query_directory_free(&rqst[1]); free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base); free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -2457,6 +2505,22 @@ smb2_oplock_response(struct cifs_tcon *tcon, __u64 persistent_fid, CIFS_CACHE_READ(cinode) ? 1 : 0); } +void +smb2_set_replay(struct TCP_Server_Info *server, struct smb_rqst *rqst) +{ + struct smb2_hdr *shdr; + + if (server->dialect < SMB30_PROT_ID) + return; + + shdr = (struct smb2_hdr *)(rqst->rq_iov[0].iov_base); + if (shdr == NULL) { + cifs_dbg(FYI, "shdr NULL in smb2_set_related\n"); + return; + } + shdr->Flags |= SMB2_FLAGS_REPLAY_OPERATION; +} + void smb2_set_related(struct smb_rqst *rqst) { @@ -2529,6 +2593,27 @@ smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst) shdr->NextCommand = cpu_to_le32(len); } +/* + * helper function for exponential backoff and check if replayable + */ +bool smb2_should_replay(struct cifs_tcon *tcon, + int *pretries, + int *pcur_sleep) +{ + if (!pretries || !pcur_sleep) + return false; + + if (tcon->retry || (*pretries)++ < tcon->ses->server->retrans) { + msleep(*pcur_sleep); + (*pcur_sleep) = ((*pcur_sleep) << 1); + if ((*pcur_sleep) > CIFS_MAX_SLEEP) + (*pcur_sleep) = CIFS_MAX_SLEEP; + return true; + } + + return false; +} + /* * Passes the query info response back to the caller on success. * Caller need to free this with free_rsp_buf(). @@ -2542,7 +2627,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, { struct smb2_compound_vars *vars; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; int flags = CIFS_CP_CREATE_CLOSE_OP; struct smb_rqst *rqst; int resp_buftype[3]; @@ -2553,6 +2638,13 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, int rc; __le16 *utf16_path; struct cached_fid *cfid = NULL; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = CIFS_CP_CREATE_CLOSE_OP; + oplock = SMB2_OPLOCK_LEVEL_NONE; + server = cifs_pick_channel(ses); if (!path) path = ""; @@ -2633,6 +2725,14 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, goto qic_exit; smb2_set_related(&rqst[2]); + if (retries) { + if (!cfid) { + smb2_set_replay(server, &rqst[0]); + smb2_set_replay(server, &rqst[2]); + } + smb2_set_replay(server, &rqst[1]); + } + if (cfid) { rc = compound_send_recv(xid, ses, server, flags, 1, &rqst[1], @@ -2665,6 +2765,11 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, kfree(vars); out_free_path: kfree(utf16_path); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 5126f5f97969..0291482a3f51 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -2764,7 +2764,14 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode, int flags = 0; unsigned int total_len; __le16 *utf16_path = NULL; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + n_iov = 2; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "mkdir\n"); @@ -2868,6 +2875,10 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode, /* no need to inc num_remote_opens because we close it just below */ trace_smb3_posix_mkdir_enter(xid, tcon->tid, ses->Suid, full_path, CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES); + + if (retries) + smb2_set_replay(server, &rqst); + /* resource #4: response buffer */ rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -2905,6 +2916,11 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode, cifs_small_buf_release(req); err_free_path: kfree(utf16_path); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -3100,12 +3116,18 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, struct smb2_create_rsp *rsp = NULL; struct cifs_tcon *tcon = oparms->tcon; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; struct kvec iov[SMB2_CREATE_IOV_SIZE]; struct kvec rsp_iov = {NULL, 0}; int resp_buftype = CIFS_NO_BUFFER; int rc = 0; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "create/open\n"); if (!ses || !server) @@ -3127,6 +3149,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, trace_smb3_open_enter(xid, tcon->tid, tcon->ses->Suid, oparms->path, oparms->create_options, oparms->desired_access); + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -3180,6 +3205,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, creat_exit: SMB2_open_free(&rqst); free_rsp_buf(resp_buftype, rsp); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -3304,15 +3334,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, int resp_buftype = CIFS_NO_BUFFER; int rc = 0; int flags = 0; - - cifs_dbg(FYI, "SMB2 IOCTL\n"); - - if (out_data != NULL) - *out_data = NULL; - - /* zero out returned data len, in case of error */ - if (plen) - *plen = 0; + int retries = 0, cur_sleep = 1; if (!tcon) return -EIO; @@ -3321,10 +3343,23 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, if (!ses) return -EIO; +replay_again: + /* reinitialize for possible replay */ + flags = 0; server = cifs_pick_channel(ses); + if (!server) return -EIO; + cifs_dbg(FYI, "SMB2 IOCTL\n"); + + if (out_data != NULL) + *out_data = NULL; + + /* zero out returned data len, in case of error */ + if (plen) + *plen = 0; + if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; @@ -3339,6 +3374,9 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, if (rc) goto ioctl_exit; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -3408,6 +3446,11 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, ioctl_exit: SMB2_ioctl_free(&rqst); free_rsp_buf(resp_buftype, rsp); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -3479,13 +3522,20 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, struct smb_rqst rqst; struct smb2_close_rsp *rsp = NULL; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; struct kvec iov[1]; struct kvec rsp_iov; int resp_buftype = CIFS_NO_BUFFER; int rc = 0; int flags = 0; bool query_attrs = false; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + query_attrs = false; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "Close\n"); @@ -3511,6 +3561,9 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, if (rc) goto close_exit; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; @@ -3544,6 +3597,11 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, cifs_dbg(VFS, "handle cancelled close fid 0x%llx returned error %d\n", persistent_fid, tmp_rc); } + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -3674,12 +3732,19 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, struct TCP_Server_Info *server; int flags = 0; bool allocated = false; + int retries = 0, cur_sleep = 1; cifs_dbg(FYI, "Query Info\n"); if (!ses) return -EIO; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + allocated = false; server = cifs_pick_channel(ses); + if (!server) return -EIO; @@ -3701,6 +3766,9 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, trace_smb3_query_info_enter(xid, persistent_fid, tcon->tid, ses->Suid, info_class, (__u32)info_type); + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; @@ -3743,6 +3811,11 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, qinf_exit: SMB2_query_info_free(&rqst); free_rsp_buf(resp_buftype, rsp); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -3843,7 +3916,7 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon, u32 *plen /* returned data len */) { struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; struct smb_rqst rqst; struct smb2_change_notify_rsp *smb_rsp; struct kvec iov[1]; @@ -3851,6 +3924,12 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon, int resp_buftype = CIFS_NO_BUFFER; int flags = 0; int rc = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "change notify\n"); if (!ses || !server) @@ -3875,6 +3954,10 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon, trace_smb3_notify_enter(xid, persistent_fid, tcon->tid, ses->Suid, (u8)watch_tree, completion_filter); + + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -3909,6 +3992,11 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon, if (rqst.rq_iov) cifs_small_buf_release(rqst.rq_iov[0].iov_base); /* request */ free_rsp_buf(resp_buftype, rsp_iov.iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -4151,10 +4239,16 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, struct smb_rqst rqst; struct kvec iov[1]; struct kvec rsp_iov = {NULL, 0}; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; int resp_buftype = CIFS_NO_BUFFER; int flags = 0; int rc = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "flush\n"); if (!ses || !(ses->server)) @@ -4174,6 +4268,10 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, goto flush_exit; trace_smb3_flush_enter(xid, persistent_fid, tcon->tid, ses->Suid); + + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -4188,6 +4286,11 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, flush_exit: SMB2_flush_free(&rqst); free_rsp_buf(resp_buftype, rsp_iov.iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -4825,18 +4928,21 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, int flags = 0; unsigned int total_len; struct TCP_Server_Info *server; + int retries = 0, cur_sleep = 1; +replay_again: + /* reinitialize for possible replay */ + flags = 0; *nbytes = 0; - - if (n_vec < 1) - return rc; - if (!io_parms->server) io_parms->server = cifs_pick_channel(io_parms->tcon->ses); server = io_parms->server; if (server == NULL) return -ECONNABORTED; + if (n_vec < 1) + return rc; + rc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, server, (void **) &req, &total_len); if (rc) @@ -4870,6 +4976,9 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, rqst.rq_iov = iov; rqst.rq_nvec = n_vec + 1; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, io_parms->tcon->ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -4894,6 +5003,11 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, cifs_small_buf_release(req); free_rsp_buf(resp_buftype, rsp); + + if (is_replayable_error(rc) && + smb2_should_replay(io_parms->tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5205,8 +5319,14 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, struct kvec rsp_iov; int rc = 0; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); if (!ses || !(ses->server)) return -EIO; @@ -5226,6 +5346,9 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, if (rc) goto qdir_exit; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base; @@ -5260,6 +5383,11 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, qdir_exit: SMB2_query_directory_free(&rqst); free_rsp_buf(resp_buftype, rsp); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5326,8 +5454,14 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, int rc = 0; int resp_buftype; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); if (!ses || !server) return -EIO; @@ -5355,6 +5489,8 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, return rc; } + if (retries) + smb2_set_replay(server, &rqst); rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, @@ -5370,6 +5506,11 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, free_rsp_buf(resp_buftype, rsp); kfree(iov); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5422,12 +5563,18 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, int rc; struct smb2_oplock_break *req = NULL; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; int flags = CIFS_OBREAK_OP; unsigned int total_len; struct kvec iov[1]; struct kvec rsp_iov; int resp_buf_type; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = CIFS_OBREAK_OP; + server = cifs_pick_channel(ses); cifs_dbg(FYI, "SMB2_oplock_break\n"); rc = smb2_plain_req_init(SMB2_OPLOCK_BREAK, tcon, server, @@ -5452,15 +5599,21 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, rqst.rq_iov = iov; rqst.rq_nvec = 1; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buf_type, flags, &rsp_iov); cifs_small_buf_release(req); - if (rc) { cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE); cifs_dbg(FYI, "Send error in Oplock Break = %d\n", rc); } + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5546,9 +5699,15 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon, int rc = 0; int resp_buftype; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; FILE_SYSTEM_POSIX_INFO *info = NULL; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); rc = build_qfs_info_req(&iov, tcon, server, FS_POSIX_INFORMATION, @@ -5564,6 +5723,9 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon, rqst.rq_iov = &iov; rqst.rq_nvec = 1; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); free_qfs_info_req(&iov); @@ -5583,6 +5745,11 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon, posix_qfsinf_exit: free_rsp_buf(resp_buftype, rsp_iov.iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5597,9 +5764,15 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, int rc = 0; int resp_buftype; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; struct smb2_fs_full_size_info *info = NULL; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); rc = build_qfs_info_req(&iov, tcon, server, FS_FULL_SIZE_INFORMATION, @@ -5615,6 +5788,9 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, rqst.rq_iov = &iov; rqst.rq_nvec = 1; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); free_qfs_info_req(&iov); @@ -5634,6 +5810,11 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, qfsinf_exit: free_rsp_buf(resp_buftype, rsp_iov.iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5648,9 +5829,15 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, int rc = 0; int resp_buftype, max_len, min_len; struct cifs_ses *ses = tcon->ses; - struct TCP_Server_Info *server = cifs_pick_channel(ses); + struct TCP_Server_Info *server; unsigned int rsp_len, offset; int flags = 0; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = 0; + server = cifs_pick_channel(ses); if (level == FS_DEVICE_INFORMATION) { max_len = sizeof(FILE_SYSTEM_DEVICE_INFO); @@ -5682,6 +5869,9 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, rqst.rq_iov = &iov; rqst.rq_nvec = 1; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); free_qfs_info_req(&iov); @@ -5719,6 +5909,11 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, qfsattr_exit: free_rsp_buf(resp_buftype, rsp_iov.iov_base); + + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } @@ -5736,7 +5931,13 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, unsigned int count; int flags = CIFS_NO_RSP_BUF; unsigned int total_len; - struct TCP_Server_Info *server = cifs_pick_channel(tcon->ses); + struct TCP_Server_Info *server; + int retries = 0, cur_sleep = 1; + +replay_again: + /* reinitialize for possible replay */ + flags = CIFS_NO_RSP_BUF; + server = cifs_pick_channel(tcon->ses); cifs_dbg(FYI, "smb2_lockv num lock %d\n", num_lock); @@ -5767,6 +5968,9 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, rqst.rq_iov = iov; rqst.rq_nvec = 2; + if (retries) + smb2_set_replay(server, &rqst); + rc = cifs_send_recv(xid, tcon->ses, server, &rqst, &resp_buf_type, flags, &rsp_iov); @@ -5778,6 +5982,10 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, tcon->ses->Suid, rc); } + if (is_replayable_error(rc) && + smb2_should_replay(tcon, &retries, &cur_sleep)) + goto replay_again; + return rc; } diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h index 0034b537b0b3..b3069911e9dd 100644 --- a/fs/smb/client/smb2proto.h +++ b/fs/smb/client/smb2proto.h @@ -122,6 +122,11 @@ extern unsigned long smb_rqst_len(struct TCP_Server_Info *server, extern void smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst); extern void smb2_set_related(struct smb_rqst *rqst); +extern void smb2_set_replay(struct TCP_Server_Info *server, + struct smb_rqst *rqst); +extern bool smb2_should_replay(struct cifs_tcon *tcon, + int *pretries, + int *pcur_sleep); /* * SMB2 Worker functions - most of protocol specific implementation details From patchwork Sun Jan 21 03:32:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13524489 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41E4914A86 for ; Sun, 21 Jan 2024 03:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808027; cv=none; b=sH5bQpwDjdwVjp9in9Zhfwf5G7GWJ/qeiXovn74F1rO5/R/Et9vK4gLXRFggRFz5TYpo8NzUar2yjKJctlVaatFQm4VK2esS5FG31Rcuw+ISV/WlVTA5Pmvpvgl0X+CmmYSfB7K53Se4csYxEUe7NitQKrkgOBWUqONPVt4+BN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705808027; c=relaxed/simple; bh=90fIssesruBejQk3fFAKmnKOfLRqH9XQjd2pio6C4fo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tvAEi98d3OhS081HGT8L9dYjFP4e/idhAINhjvtWevSYP0777UYmZ7kHWzh8ZEbIbrNmRaGB1yMdaXn+5g9bD/JrHRvnhtMhEIMxNu8q+cAlbt72JgmrS1sl9IVQayVEDOjNrz9kt2cKXrw3dicBiIFfeXA7y4Y8VgAE6NEFRtE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LYFLS+pt; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LYFLS+pt" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-29065efa06fso722656a91.1 for ; Sat, 20 Jan 2024 19:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705808025; x=1706412825; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l5VoHQ53gbjaawVnEnn5BrKaSO5fVnuv3DA0TA0OWPI=; b=LYFLS+ptCKq92v5NRLYsoUYBR0Qgcf5a7twV6wV0oY9bgeX8nn1jUdnNxl7mYcvCk7 FoBiFiXr66sk/Axfnznnl0kzL24kWPJwwbCY/LZDfM1X5G8LEi6c7oWHDeBmH+WxyhlJ kyOIUmjs34jqveEM+91ewhpks7eUbRBU1mYWhAUdhM0iHpUxKQRGClM1CCLEa+q6F8GT bu2Xhl72HTAtfXgIFiy+d2UbbG6c/Oe7fB1vYaZb5pKJMIxWqDghdaNMEakan0EHzH8o K0LoUKyl1LuQj01W5DHc+L7+hJO8Yh2ncAF9aH+RextQ56glNnfJbaqmE/C+2UiSVMst 6SxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705808025; x=1706412825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5VoHQ53gbjaawVnEnn5BrKaSO5fVnuv3DA0TA0OWPI=; b=fGmZtYTVmH8UL2wjYwG2SRaWyajY/NuBwKZROrQAiJUX1IwAC0nsMYHxCpXDne/9g4 qvO1mymQk1OvFufc44KCvu8OJaSP5E2Z5GEETAti6Bx6/Vm6rqj41M6AZPN/ZwUgJ6FX oCc+OKOWNZ4sIr7A4MPdEOzwcheg7js7lrw4mF/iCqfNx+qesDXzvZK69W1iuSx1T6Za iAjVtu1qzrxeiQ74dPf64eql5Djsv/vkpa3tmPrguEPDdzv6UKpNy+fU9DVxWZwH2A43 JADVCby3wPWrRwH0tiqzS/e/ykG+6etiuin5iHcYtC2SUjVVagz/W268lMwCHLaqzp43 BKLA== X-Gm-Message-State: AOJu0YyQDkSowJeZEuAigEsc0SNi2sNLNu1B1eBks7lke+kjEukb6Eci QPKCZ/7Kb5lCZodsyHNIcknypSrx/lqtuGNs2oPlFgWeeQZF1Z4RyFgm6iVA X-Google-Smtp-Source: AGHT+IHJDWzVBxu2dNGeQuDIwTx+f1+RcoX9VOShnL2F63w2Svcrb888YV475Xb/LqUdr+fhsW5JvQ== X-Received: by 2002:a17:902:db02:b0:1d7:467b:f488 with SMTP id m2-20020a170902db0200b001d7467bf488mr594599plx.114.1705808024785; Sat, 20 Jan 2024 19:33:44 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id lg14-20020a170902fb8e00b001d058ad8770sm5193166plb.306.2024.01.20.19.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 19:33:44 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 7/7] cifs: set replay flag for retries of write command Date: Sun, 21 Jan 2024 03:32:48 +0000 Message-Id: <20240121033248.125282-7-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121033248.125282-1-sprasad@microsoft.com> References: <20240121033248.125282-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N Similar to the rest of the commands, this is a change to add replay flags on retry. This one does not add a back-off, considering that we may want to flush a write ASAP to the server. Considering that this will be a flush of cached pages, the retrans value is also not honoured. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifsglob.h | 1 + fs/smb/client/file.c | 1 + fs/smb/client/smb2pdu.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index b5abe4d6f478..acda357e1dfd 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1506,6 +1506,7 @@ struct cifs_writedata { struct smbd_mr *mr; #endif struct cifs_credits credits; + bool replay; }; /* diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 1b4262aff8fa..49d262d1df5f 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -3300,6 +3300,7 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, if (wdata->cfile->invalidHandle) rc = -EAGAIN; else { + wdata->replay = true; #ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) { wdata->mr->need_invalidate = true; diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 0291482a3f51..a8ac9240a854 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -4770,7 +4770,7 @@ smb2_async_writev(struct cifs_writedata *wdata, struct cifs_io_parms *io_parms = NULL; int credit_request; - if (!wdata->server) + if (!wdata->server || wdata->replay) server = wdata->server = cifs_pick_channel(tcon->ses); /* @@ -4855,6 +4855,8 @@ smb2_async_writev(struct cifs_writedata *wdata, rqst.rq_nvec = 1; rqst.rq_iter = wdata->iter; rqst.rq_iter_size = iov_iter_count(&rqst.rq_iter); + if (wdata->replay) + smb2_set_replay(server, &rqst); #ifdef CONFIG_CIFS_SMB_DIRECT if (wdata->mr) iov[0].iov_len += sizeof(struct smbd_buffer_descriptor_v1);