Re: [PATCH v5 09/12] cifs: Cut over to using netfslib

From: Simon Horman
Date: Fri Feb 09 2024 - 05:53:11 EST


On Mon, Feb 05, 2024 at 10:57:21PM +0000, David Howells wrote:

..

> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 84e3675eb41e..b58fdee40755 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -4386,10 +4386,12 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
> req->Length = cpu_to_le32(io_parms->length);
> req->Offset = cpu_to_le64(io_parms->offset);
>
> - trace_smb3_read_enter(0 /* xid */,
> - io_parms->persistent_fid,
> - io_parms->tcon->tid, io_parms->tcon->ses->Suid,
> - io_parms->offset, io_parms->length);
> + trace_smb3_read_enter(rdata ? rdata->rreq->debug_id : 0,
> + rdata ? rdata->subreq.debug_index : 0,
> + rdata ? rdata->xid : 0,
> + io_parms->persistent_fid,
> + io_parms->tcon->tid, io_parms->tcon->ses->Suid,
> + io_parms->offset, io_parms->length);
> #ifdef CONFIG_CIFS_SMB_DIRECT

Hi David,

above some care is taken to handle the case where rdata might be NULL.

However, the code below this hunk, other than being guarded by
smb3_use_rdma_offload(io_parms), uses rdata unconditionally.

Perhaps the guard makes this ok. But Smatch flags this inconsistency.
And I thought I should bring it to your attention.

For reference the code I am referring to looks like this:

#ifdef CONFIG_CIFS_SMB_DIRECT
/*
* If we want to do a RDMA write, fill in and append
* smbd_buffer_descriptor_v1 to the end of read request
*/
if (smb3_use_rdma_offload(io_parms)) {
struct smbd_buffer_descriptor_v1 *v1;
bool need_invalidate = server->dialect == SMB30_PROT_ID;

rdata->mr = smbd_register_mr(server->smbd_conn, &rdata->subreq.io_iter,
true, need_invalidate);
if (!rdata->mr)
return -EAGAIN;


..