From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67220302143 for ; Mon, 1 Dec 2025 09:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764582583; cv=none; b=OYZ3QUr8bXwUsDDanKeO4fAtP/PJQ7K1ostY1o41TMr2Wd6KMGiSjFXlG5USsrc7mh+SHmqCijqFAI2Bdh0KkQLtumhI38JRaZNmcDiezacIyzX/nGR527s15T/ru8HsG3BpHto1yLnpgVfxlKLzETvUjVkg04cfAqCEq8j4IA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764582583; c=relaxed/simple; bh=xQ3rQQJCI2Mb/1KeXN3rI/JhisQpHT35Wxc5bQlX1Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWT/jRpHIyzvaq+nYAYbC76R8VsAPIC7QxSNrXbh0mwIOKdbYGljhXJ+NSjHbvnk3FwdzCuhTYmDB430tnnYwhTb+WIxzMyqCGDo+QpdIyLjzTvZSNOi0TV7S3nxscvNmR97D0JKmFP+K1UDPy91qujgbMUbHv4OnZEKjJAnxtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QV6+RH2d; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QV6+RH2d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764582580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SMt6xu3touysp3/PLveCAViALoZvDw84eRo9iS++sQQ=; b=QV6+RH2dNnZOiebZmosYBuVUYCRf9V28bwwYOLCLN3wBw7iCTYkASH1ch9G/M3OWl1RWZr ff85CZNHrSNwm+wuUxqF7vW+r1phdfZhrmBzG8KjsuwUEMqCwHLTLqFUo25k5+J9zhEeHl hAOlHD654AjjoYNYE76VS0G+jV1/z/4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-304-Q-6qLxOsM1Ohvu0HJPpyxg-1; Mon, 01 Dec 2025 04:49:38 -0500 X-MC-Unique: Q-6qLxOsM1Ohvu0HJPpyxg-1 X-Mimecast-MFC-AGG-ID: Q-6qLxOsM1Ohvu0HJPpyxg_1764582576 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B41EB1956050; Mon, 1 Dec 2025 09:49:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0FAE7180047F; Mon, 1 Dec 2025 09:49:33 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Paulo Alcantara , Shyam Prasad N , Stefan Metzmacher , linux-cifs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Talpey Subject: [PATCH v5 3/9] cifs: Make smb1's SendReceive() wrap cifs_send_recv() Date: Mon, 1 Dec 2025 09:49:07 +0000 Message-ID: <20251201094916.1418415-4-dhowells@redhat.com> In-Reply-To: <20251201094916.1418415-1-dhowells@redhat.com> References: <20251201094916.1418415-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Make the smb1 transport's SendReceive() simply wrap cifs_send_recv() as does SendReceive2(). This will then allow that to pick up the transport changes there. Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Shyam Prasad N cc: Tom Talpey cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/smb/client/cifstransport.c | 83 +++++------------------------------ 1 file changed, 10 insertions(+), 73 deletions(-) diff --git a/fs/smb/client/cifstransport.c b/fs/smb/client/cifstransport.c index 94f43c8df07a..fb8b34944c02 100644 --- a/fs/smb/client/cifstransport.c +++ b/fs/smb/client/cifstransport.c @@ -236,12 +236,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, struct smb_hdr *in_buf, unsigned int in_len, struct smb_hdr *out_buf, int *pbytes_returned, const int flags) { - int rc = 0; - struct smb_message *smb; + struct TCP_Server_Info *server; + struct kvec resp_iov = {}; struct kvec iov = { .iov_base = in_buf, .iov_len = in_len }; struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 }; - struct cifs_credits credits = { .value = 1, .instance = 0 }; - struct TCP_Server_Info *server; + int resp_buf_type; + int rc = 0; if (WARN_ON_ONCE(in_len > 0xffffff)) return -EIO; @@ -272,78 +272,15 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, return -EIO; } - rc = wait_for_free_request(server, flags, &credits.instance); - if (rc) - return rc; - - /* make sure that we sign in the same order that we send on this socket - and avoid races inside tcp sendmsg code that could cause corruption - of smb data */ - - cifs_server_lock(server); - - rc = allocate_mid(ses, in_buf, &smb); - if (rc) { - cifs_server_unlock(server); - /* Update # of requests on wire to server */ - add_credits(server, &credits, 0); - return rc; - } - - rc = cifs_sign_smb(in_buf, in_len, server, &smb->sequence_number); - if (rc) { - cifs_server_unlock(server); - goto out; - } - - smb->mid_state = MID_REQUEST_SUBMITTED; - - rc = smb_send(server, in_buf, in_len); - cifs_save_when_sent(smb); - - if (rc < 0) - server->sequence_number -= 2; - - cifs_server_unlock(server); - + rc = cifs_send_recv(xid, ses, ses->server, + &rqst, &resp_buf_type, flags, &resp_iov); if (rc < 0) - goto out; - - rc = wait_for_response(server, smb); - if (rc != 0) { - send_cancel(server, &rqst, smb); - spin_lock(&smb->mid_lock); - if (smb->mid_state == MID_REQUEST_SUBMITTED || - smb->mid_state == MID_RESPONSE_RECEIVED) { - /* no longer considered to be "in-flight" */ - smb->callback = release_mid; - spin_unlock(&smb->mid_lock); - add_credits(server, &credits, 0); - return rc; - } - spin_unlock(&smb->mid_lock); - } - - rc = cifs_sync_mid_result(smb, server); - if (rc != 0) { - add_credits(server, &credits, 0); return rc; - } - - if (!smb->resp_buf || !out_buf || - smb->mid_state != MID_RESPONSE_READY) { - rc = -EIO; - cifs_server_dbg(VFS, "Bad MID state?\n"); - goto out; - } - - *pbytes_returned = smb->response_pdu_len; - memcpy(out_buf, smb->resp_buf, *pbytes_returned); - rc = cifs_check_receive(smb, server, 0); -out: - delete_mid(smb); - add_credits(server, &credits, 0); + *pbytes_returned = resp_iov.iov_len; + if (resp_iov.iov_len) + memcpy(out_buf, resp_iov.iov_base, resp_iov.iov_len); + free_rsp_buf(resp_buf_type, resp_iov.iov_base); return rc; }