fs/ocfs2/cluster/tcp.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/cluster/tcp.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/cluster/tcp.c- Extension
.c- Size
- 59753 bytes
- Lines
- 2151
- 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
linux/kernel.hlinux/sched/mm.hlinux/jiffies.hlinux/slab.hlinux/idr.hlinux/kref.hlinux/net.hlinux/export.hnet/tcp.htrace/events/sock.hlinux/uaccess.hheartbeat.htcp.hnodemanager.hmasklog.hquorum.htcp_internal.h
Detected Declarations
function o2net_init_nstfunction o2net_set_nst_sock_timefunction o2net_set_nst_send_timefunction o2net_set_nst_status_timefunction o2net_set_nst_sock_containerfunction o2net_set_nst_msg_idfunction o2net_set_sock_timerfunction o2net_set_data_ready_timefunction o2net_set_advance_start_timefunction o2net_set_advance_stop_timefunction o2net_set_func_start_timefunction o2net_set_func_stop_timefunction o2net_get_func_run_timefunction o2net_update_send_statsfunction o2net_update_recv_statsfunction o2net_reconnect_delayfunction o2net_keepalive_delayfunction o2net_idle_timeoutfunction o2net_sys_err_to_errnofunction o2net_nn_from_numfunction o2net_num_from_nnfunction o2net_prep_nswfunction o2net_complete_nsw_lockedfunction o2net_complete_nswfunction o2net_complete_nodes_nswfunction list_for_each_entry_safefunction o2net_nsw_completedfunction sc_kref_releasefunction sc_putfunction sc_getfunction o2net_sc_queue_workfunction o2net_sc_queue_delayed_workfunction o2net_sc_cancel_delayed_workfunction o2net_num_connected_peersfunction o2net_set_nn_statefunction o2net_data_readyfunction o2net_state_changefunction o2net_register_callbacksfunction o2net_unregister_callbacksfunction o2net_ensure_shutdownfunction o2net_shutdown_scfunction o2net_handler_cmpfunction o2net_handler_tree_lookupfunction o2net_handler_kref_releasefunction o2net_handler_putfunction o2net_register_handlerfunction o2net_unregister_handler_listfunction o2net_recv_tcp_msg
Annotated Snippet
* sock_create allocates the sock with GFP_KERNEL. We must
* prevent the filesystem from being reentered by memory reclaim.
*/
nofs_flag = memalloc_nofs_save();
/* if we're greater we initiate tx, otherwise we accept */
if (o2nm_this_node() <= o2net_num_from_nn(nn))
goto out;
/* watch for racing with tearing a node down */
node = o2nm_get_node_by_num(o2net_num_from_nn(nn));
if (node == NULL)
goto out;
mynode = o2nm_get_node_by_num(o2nm_this_node());
if (mynode == NULL)
goto out;
spin_lock(&nn->nn_lock);
/*
* see if we already have one pending or have given up.
* For nn_timeout, it is set when we close the connection
* because of the idle time out. So it means that we have
* at least connected to that node successfully once,
* now try to connect to it again.
*/
timeout = atomic_read(&nn->nn_timeout);
stop = (nn->nn_sc ||
(nn->nn_persistent_error &&
(nn->nn_persistent_error != -ENOTCONN || timeout == 0)));
spin_unlock(&nn->nn_lock);
if (stop)
goto out;
nn->nn_last_connect_attempt = jiffies;
sc = sc_alloc(node);
if (sc == NULL) {
mlog(0, "couldn't allocate sc\n");
ret = -ENOMEM;
goto out;
}
ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
if (ret < 0) {
mlog(0, "can't create socket: %d\n", ret);
goto out;
}
sc->sc_sock = sock; /* freed by sc_kref_release */
sock->sk->sk_allocation = GFP_ATOMIC;
sock->sk->sk_use_task_frag = false;
myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = mynode->nd_ipv4_address;
myaddr.sin_port = htons(0); /* any port */
ret = sock->ops->bind(sock, (struct sockaddr_unsized *)&myaddr,
sizeof(myaddr));
if (ret) {
mlog(ML_ERROR, "bind failed with %d at address %pI4\n",
ret, &mynode->nd_ipv4_address);
goto out;
}
tcp_sock_set_nodelay(sc->sc_sock->sk);
tcp_sock_set_user_timeout(sock->sk, O2NET_TCP_USER_TIMEOUT);
o2net_register_callbacks(sc->sc_sock->sk, sc);
spin_lock(&nn->nn_lock);
/* handshake completion will set nn->nn_sc_valid */
o2net_set_nn_state(nn, sc, 0, 0);
spin_unlock(&nn->nn_lock);
remoteaddr.sin_family = AF_INET;
remoteaddr.sin_addr.s_addr = node->nd_ipv4_address;
remoteaddr.sin_port = node->nd_ipv4_port;
ret = sc->sc_sock->ops->connect(sc->sc_sock,
(struct sockaddr_unsized *)&remoteaddr,
sizeof(remoteaddr),
O_NONBLOCK);
if (ret == -EINPROGRESS)
ret = 0;
out:
if (ret && sc) {
printk(KERN_NOTICE "o2net: Connect attempt to " SC_NODEF_FMT
" failed with errno %d\n", SC_NODEF_ARGS(sc), ret);
/* 0 err so that another will be queued and attempted
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched/mm.h`, `linux/jiffies.h`, `linux/slab.h`, `linux/idr.h`, `linux/kref.h`, `linux/net.h`, `linux/export.h`.
- Detected declarations: `function o2net_init_nst`, `function o2net_set_nst_sock_time`, `function o2net_set_nst_send_time`, `function o2net_set_nst_status_time`, `function o2net_set_nst_sock_container`, `function o2net_set_nst_msg_id`, `function o2net_set_sock_timer`, `function o2net_set_data_ready_time`, `function o2net_set_advance_start_time`, `function o2net_set_advance_stop_time`.
- 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.