fs/afs/vl_alias.c

Source file repositories/reference/linux-study-clean/fs/afs/vl_alias.c

File Facts

System
Linux kernel
Corpus path
fs/afs/vl_alias.c
Extension
.c
Size
8538 bytes
Lines
341
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source 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

if (diff < 0) {
			a++;
		} else if (diff > 0) {
			b++;
		} else {
			addr_matches++;
			a++;
			b++;
		}
	}

	return addr_matches;
}

/*
 * Compare the fileserver lists of two volumes.  The server lists are sorted in
 * order of ascending UUID.
 */
static int afs_compare_volume_slists(const struct afs_volume *vol_a,
				     const struct afs_volume *vol_b)
{
	const struct afs_server_list *la, *lb;
	int i, a = 0, b = 0, uuid_matches = 0, addr_matches = 0;

	la = rcu_dereference(vol_a->servers);
	lb = rcu_dereference(vol_b->servers);

	for (i = 0; i < AFS_MAXTYPES; i++)
		if (vol_a->vids[i] != vol_b->vids[i])
			return 0;

	while (a < la->nr_servers && b < lb->nr_servers) {
		const struct afs_server *server_a = la->servers[a].server;
		const struct afs_server *server_b = lb->servers[b].server;
		int diff = memcmp(&server_a->uuid, &server_b->uuid, sizeof(uuid_t));

		if (diff < 0) {
			a++;
		} else if (diff > 0) {
			b++;
		} else {
			uuid_matches++;
			addr_matches += afs_compare_fs_alists(server_a, server_b);
			a++;
			b++;
		}
	}

	_leave(" = %d [um %d]", addr_matches, uuid_matches);
	return addr_matches;
}

/*
 * Compare root.cell volumes.
 */
static int afs_compare_cell_roots(struct afs_cell *cell)
{
	struct afs_cell *p;

	_enter("");

	rcu_read_lock();

	hlist_for_each_entry_rcu(p, &cell->net->proc_cells, proc_link) {
		if (p == cell || p->alias_of)
			continue;
		if (!p->root_volume)
			continue; /* Ignore cells that don't have a root.cell volume. */

		if (afs_compare_volume_slists(cell->root_volume, p->root_volume) != 0)
			goto is_alias;
	}

	rcu_read_unlock();
	_leave(" = 0");
	return 0;

is_alias:
	rcu_read_unlock();
	cell->alias_of = afs_use_cell(p, afs_cell_trace_use_alias);
	return 1;
}

/*
 * Query the new cell for a volume from a cell we're already using.
 */
static int afs_query_for_alias_one(struct afs_cell *cell, struct key *key,
				   struct afs_cell *p)
{
	struct afs_volume *volume, *pvol = NULL;

Annotation

Implementation Notes