fs/smb/smbdirect/connect.c
Source file repositories/reference/linux-study-clean/fs/smb/smbdirect/connect.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/smbdirect/connect.c- Extension
.c- Size
- 28093 bytes
- Lines
- 926
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
internal.h../common/smb2status.h
Detected Declarations
function smbdirect_connectfunction smbdirect_connect_setup_connectionfunction smbdirect_connect_resolve_addrfunction smbdirect_connect_resolve_routefunction smbdirect_connect_rdma_connectfunction smbdirect_connect_rdma_event_handlerfunction devicesfunction smbdirect_connect_negotiate_startfunction smbdirect_connect_negotiate_send_donefunction smbdirect_connect_negotiate_recv_donefunction smbdirect_connect_negotiate_recv_workfunction smbdirect_connect_syncexport smbdirect_connectexport smbdirect_connect_sync
Annotated Snippet
if (rdma_protocol_iwarp(id->device, id->port_num)) {
/*
* iWarp devices report the peer's values
* with the perspective of the peer here.
* Tested with siw and irdma (in iwarp mode)
* We need to change to our perspective here,
* so we need to switch the values.
*/
peer_initiator_depth = event->param.conn.responder_resources;
peer_responder_resources = event->param.conn.initiator_depth;
} else {
/*
* Non iWarp devices report the peer's values
* already changed to our perspective here.
* Tested with rxe and irdma (in roce mode).
*/
peer_initiator_depth = event->param.conn.initiator_depth;
peer_responder_resources = event->param.conn.responder_resources;
}
smbdirect_connection_negotiate_rdma_resources(sc,
peer_initiator_depth,
peer_responder_resources,
&event->param.conn);
ret = smbdirect_connect_negotiate_start(sc);
if (ret)
smbdirect_socket_schedule_cleanup(sc, ret);
return 0;
default:
break;
}
/*
* This is an internal error
*/
WARN_ON_ONCE(sc->rdma.expected_event != RDMA_CM_EVENT_ESTABLISHED);
smbdirect_socket_schedule_cleanup(sc, -ECONNABORTED);
return 0;
}
static int smbdirect_connect_negotiate_start(struct smbdirect_socket *sc)
{
const struct smbdirect_socket_parameters *sp = &sc->parameters;
struct smbdirect_recv_io *recv_io = NULL;
struct smbdirect_send_io *send_io = NULL;
struct smbdirect_negotiate_req *nreq = NULL;
int ret;
if (SMBDIRECT_CHECK_STATUS_DISCONNECT(sc, SMBDIRECT_SOCKET_NEGOTIATE_NEEDED))
return sc->first_error;
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_RUNNING;
ret = smbdirect_connection_create_mem_pools(sc);
if (ret) {
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
"smbdirect_connection_create_mem_pools() failed %1pe\n",
SMBDIRECT_DEBUG_ERR_PTR(ret));
goto create_mem_pools_failed;
}
/*
* There is only a single batch credit
*/
atomic_set(&sc->send_io.bcredits.count, 1);
/*
* Initialize the local credits to post
* IB_WR_SEND[_WITH_INV].
*/
atomic_set(&sc->send_io.lcredits.count, sp->send_credit_target);
recv_io = smbdirect_connection_get_recv_io(sc);
if (WARN_ON_ONCE(!recv_io)) {
ret = -EINVAL;
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
"smbdirect_connection_get_recv_io() failed %1pe\n",
SMBDIRECT_DEBUG_ERR_PTR(ret));
goto get_recv_io_failed;
}
recv_io->cqe.done = smbdirect_connect_negotiate_recv_done;
send_io = smbdirect_connection_alloc_send_io(sc);
if (IS_ERR(send_io)) {
ret = PTR_ERR(send_io);
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_ERR,
"smbdirect_connection_alloc_send_io() failed %1pe\n",
SMBDIRECT_DEBUG_ERR_PTR(ret));
goto alloc_send_io_failed;
}
Annotation
- Immediate include surface: `internal.h`, `../common/smb2status.h`.
- Detected declarations: `function smbdirect_connect`, `function smbdirect_connect_setup_connection`, `function smbdirect_connect_resolve_addr`, `function smbdirect_connect_resolve_route`, `function smbdirect_connect_rdma_connect`, `function smbdirect_connect_rdma_event_handler`, `function devices`, `function smbdirect_connect_negotiate_start`, `function smbdirect_connect_negotiate_send_done`, `function smbdirect_connect_negotiate_recv_done`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.