fs/smb/smbdirect/socket.c
Source file repositories/reference/linux-study-clean/fs/smb/smbdirect/socket.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/smbdirect/socket.c- Extension
.c- Size
- 20784 bytes
- Lines
- 744
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
internal.h
Detected Declarations
function Copyrightfunction smbdirect_socket_rdma_event_handlerfunction smbdirect_socket_init_newfunction smbdirect_socket_create_kernfunction smbdirect_socket_init_acceptingfunction smbdirect_socket_create_acceptingfunction smbdirect_socket_set_initial_parametersfunction smbdirect_socket_get_current_parametersfunction smbdirect_socket_set_kernel_settingsfunction smbdirect_socket_set_loggingfunction smbdirect_socket_wake_up_allfunction __smbdirect_socket_schedule_cleanupfunction smbdirect_socket_cleanup_workfunction smbdirect_socket_destroyfunction smbdirect_socket_destroy_syncfunction smbdirect_socket_bindfunction smbdirect_socket_shutdownfunction smbdirect_socket_release_disconnectfunction smbdirect_socket_release_destroyfunction smbdirect_socket_releasefunction smbdirect_socket_wait_for_creditsexport smbdirect_frwr_is_supportedexport smbdirect_socket_create_kernexport smbdirect_socket_create_acceptingexport smbdirect_socket_set_initial_parametersexport smbdirect_socket_get_current_parametersexport smbdirect_socket_set_kernel_settingsexport smbdirect_socket_set_loggingexport smbdirect_socket_bindexport smbdirect_socket_shutdownexport smbdirect_socket_release
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2017, Microsoft Corporation.
* Copyright (c) 2025, Stefan Metzmacher
*/
#include "internal.h"
bool smbdirect_frwr_is_supported(const struct ib_device_attr *attrs)
{
/*
* Test if FRWR (Fast Registration Work Requests) is supported on the
* device This implementation requires FRWR on RDMA read/write return
* value: true if it is supported
*/
if (!(attrs->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
return false;
if (attrs->max_fast_reg_page_list_len == 0)
return false;
return true;
}
EXPORT_SYMBOL_GPL(smbdirect_frwr_is_supported);
static void smbdirect_socket_cleanup_work(struct work_struct *work);
static int smbdirect_socket_rdma_event_handler(struct rdma_cm_id *id,
struct rdma_cm_event *event)
{
struct smbdirect_socket *sc = id->context;
int ret = -ESTALE;
/*
* This should be replaced before any real work
* starts! So it should never be called!
*/
if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
ret = -ENETDOWN;
if (IS_ERR(SMBDIRECT_DEBUG_ERR_PTR(event->status)))
ret = event->status;
pr_err("%s (first_error=%1pe, expected=%s) => event=%s status=%d => ret=%1pe\n",
smbdirect_socket_status_string(sc->status),
SMBDIRECT_DEBUG_ERR_PTR(sc->first_error),
rdma_event_msg(sc->rdma.expected_event),
rdma_event_msg(event->event),
event->status,
SMBDIRECT_DEBUG_ERR_PTR(ret));
WARN_ONCE(1, "%s should not be called!\n", __func__);
sc->rdma.cm_id = NULL;
return -ESTALE;
}
int smbdirect_socket_init_new(struct net *net, struct smbdirect_socket *sc)
{
struct rdma_cm_id *id;
int ret;
smbdirect_socket_init(sc);
id = rdma_create_id(net,
smbdirect_socket_rdma_event_handler,
sc,
RDMA_PS_TCP,
IB_QPT_RC);
if (IS_ERR(id)) {
pr_err("%s: rdma_create_id() failed %1pe\n", __func__, id);
return PTR_ERR(id);
}
ret = rdma_set_afonly(id, 1);
if (ret) {
rdma_destroy_id(id);
pr_err("%s: rdma_set_afonly() failed %1pe\n",
__func__, SMBDIRECT_DEBUG_ERR_PTR(ret));
return ret;
}
sc->rdma.cm_id = id;
INIT_WORK(&sc->disconnect_work, smbdirect_socket_cleanup_work);
return 0;
}
int smbdirect_socket_create_kern(struct net *net, struct smbdirect_socket **_sc)
{
struct smbdirect_socket *sc;
int ret;
Annotation
- Immediate include surface: `internal.h`.
- Detected declarations: `function Copyright`, `function smbdirect_socket_rdma_event_handler`, `function smbdirect_socket_init_new`, `function smbdirect_socket_create_kern`, `function smbdirect_socket_init_accepting`, `function smbdirect_socket_create_accepting`, `function smbdirect_socket_set_initial_parameters`, `function smbdirect_socket_get_current_parameters`, `function smbdirect_socket_set_kernel_settings`, `function smbdirect_socket_set_logging`.
- 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.
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.