From nobody Mon Dec 1 22:35:05 2025 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 665BC302169 for ; Mon, 1 Dec 2025 09:49:42 +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=1764582584; cv=none; b=OPO+J6uhu/vkF+8qTxCuWIkxjDtFN3meAmltXAfzcKm9J6OwW0Ww4yxLN4J+vW/9kjlWcHk9Eu6zEOq6U77PExu+2VygPkBXVv6bkgU+wnywqP1o+jzRHmMpghVWGTGMChFx3t9Ws/A1RewU29uAfsDS+mxiWV0hjy9JSxjZEZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764582584; c=relaxed/simple; bh=xQ3rQQJCI2Mb/1KeXN3rI/JhisQpHT35Wxc5bQlX1Mg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KFWsakxIWz9sAWpwQ9rPoih8Ymznqtrm2ALoWTR47X3/gckaA6d/IfKYahRXmg75PQuMU/UdkTuAk6/7mnJuTlwuJWbp2Qmvp9BH63S8qE1vVpmWKg57DroUqRr1lVfLK8rI1lSEoHDeNJosXxNfgDQxC4kv8F63j5EUnIIsGwg= 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=NIN03xLB; 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="NIN03xLB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764582581; 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=NIN03xLBFL5Ddtfnry7rW80ZYGj2UqWX2dQYMYRHJMcJyiYvRauy8ZVP4zhEczm1Oyk7C4 W0Wbgr7QIzTOZla825xplrtcGf8Nqea5th1Gv6qZcYf21dCzpJPaL+/2JvCNDgUmBnJETS 8QEXi+dhOOKeBc+2Lx67rV6VxKTiPC8= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" 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 =3D 0; - struct smb_message *smb; + struct TCP_Server_Info *server; + struct kvec resp_iov =3D {}; struct kvec iov =3D { .iov_base =3D in_buf, .iov_len =3D in_len }; struct smb_rqst rqst =3D { .rq_iov =3D &iov, .rq_nvec =3D 1 }; - struct cifs_credits credits =3D { .value =3D 1, .instance =3D 0 }; - struct TCP_Server_Info *server; + int resp_buf_type; + int rc =3D 0; =20 if (WARN_ON_ONCE(in_len > 0xffffff)) return -EIO; @@ -272,78 +272,15 @@ SendReceive(const unsigned int xid, struct cifs_ses *= ses, return -EIO; } =20 - rc =3D 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 =3D 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 =3D cifs_sign_smb(in_buf, in_len, server, &smb->sequence_number); - if (rc) { - cifs_server_unlock(server); - goto out; - } - - smb->mid_state =3D MID_REQUEST_SUBMITTED; - - rc =3D smb_send(server, in_buf, in_len); - cifs_save_when_sent(smb); - - if (rc < 0) - server->sequence_number -=3D 2; - - cifs_server_unlock(server); - + rc =3D cifs_send_recv(xid, ses, ses->server, + &rqst, &resp_buf_type, flags, &resp_iov); if (rc < 0) - goto out; - - rc =3D wait_for_response(server, smb); - if (rc !=3D 0) { - send_cancel(server, &rqst, smb); - spin_lock(&smb->mid_lock); - if (smb->mid_state =3D=3D MID_REQUEST_SUBMITTED || - smb->mid_state =3D=3D MID_RESPONSE_RECEIVED) { - /* no longer considered to be "in-flight" */ - smb->callback =3D release_mid; - spin_unlock(&smb->mid_lock); - add_credits(server, &credits, 0); - return rc; - } - spin_unlock(&smb->mid_lock); - } - - rc =3D cifs_sync_mid_result(smb, server); - if (rc !=3D 0) { - add_credits(server, &credits, 0); return rc; - } - - if (!smb->resp_buf || !out_buf || - smb->mid_state !=3D MID_RESPONSE_READY) { - rc =3D -EIO; - cifs_server_dbg(VFS, "Bad MID state?\n"); - goto out; - } - - *pbytes_returned =3D smb->response_pdu_len; - memcpy(out_buf, smb->resp_buf, *pbytes_returned); - rc =3D cifs_check_receive(smb, server, 0); -out: - delete_mid(smb); - add_credits(server, &credits, 0); =20 + *pbytes_returned =3D 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; }