fs/ocfs2/cluster/netdebug.c

Source file repositories/reference/linux-study-clean/fs/ocfs2/cluster/netdebug.c

File Facts

System
Linux kernel
Corpus path
fs/ocfs2/cluster/netdebug.c
Extension
.c
Size
12711 bytes
Lines
507
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations nst_seq_fops = {
	.open = nst_fop_open,
	.read = seq_read,
	.llseek = seq_lseek,
	.release = nst_fop_release,
};

void o2net_debug_add_sc(struct o2net_sock_container *sc)
{
	spin_lock_bh(&o2net_debug_lock);
	list_add(&sc->sc_net_debug_item, &sock_containers);
	spin_unlock_bh(&o2net_debug_lock);
}

void o2net_debug_del_sc(struct o2net_sock_container *sc)
{
	spin_lock_bh(&o2net_debug_lock);
	list_del_init(&sc->sc_net_debug_item);
	spin_unlock_bh(&o2net_debug_lock);
}

struct o2net_sock_debug {
	int dbg_ctxt;
	struct o2net_sock_container *dbg_sock;
};

static struct o2net_sock_container
			*next_sc(struct o2net_sock_container *sc_start)
{
	struct o2net_sock_container *sc, *ret = NULL;

	assert_spin_locked(&o2net_debug_lock);

	list_for_each_entry(sc, &sc_start->sc_net_debug_item,
			    sc_net_debug_item) {
		/* discover the head of the list miscast as a sc */
		if (&sc->sc_net_debug_item == &sock_containers)
			break;

		/* use sc_page to detect real scs in the list */
		if (sc->sc_page != NULL) {
			ret = sc;
			break;
		}
	}

	return ret;
}

static void *sc_seq_start(struct seq_file *seq, loff_t *pos)
{
	struct o2net_sock_debug *sd = seq->private;
	struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock;

	spin_lock_bh(&o2net_debug_lock);
	sc = next_sc(dummy_sc);
	spin_unlock_bh(&o2net_debug_lock);

	return sc;
}

static void *sc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
	struct o2net_sock_debug *sd = seq->private;
	struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock;

	spin_lock_bh(&o2net_debug_lock);
	sc = next_sc(dummy_sc);
	list_del_init(&dummy_sc->sc_net_debug_item);
	if (sc)
		list_add(&dummy_sc->sc_net_debug_item, &sc->sc_net_debug_item);
	spin_unlock_bh(&o2net_debug_lock);

	return sc; /* unused, just needs to be null when done */
}

#ifdef CONFIG_OCFS2_FS_STATS
# define sc_send_count(_s)		((_s)->sc_send_count)
# define sc_recv_count(_s)		((_s)->sc_recv_count)
# define sc_tv_acquiry_total_ns(_s)	(ktime_to_ns((_s)->sc_tv_acquiry_total))
# define sc_tv_send_total_ns(_s)	(ktime_to_ns((_s)->sc_tv_send_total))
# define sc_tv_status_total_ns(_s)	(ktime_to_ns((_s)->sc_tv_status_total))
# define sc_tv_process_total_ns(_s)	(ktime_to_ns((_s)->sc_tv_process_total))
#else
# define sc_send_count(_s)		(0U)
# define sc_recv_count(_s)		(0U)
# define sc_tv_acquiry_total_ns(_s)	(0LL)
# define sc_tv_send_total_ns(_s)	(0LL)
# define sc_tv_status_total_ns(_s)	(0LL)
# define sc_tv_process_total_ns(_s)	(0LL)

Annotation

Implementation Notes