Lines Matching +full:2 +full:- +full:cell

1 // SPDX-License-Identifier: GPL-2.0-or-later
15 * Insert a volume into a cell. If there's an existing volume record, that is
18 static struct afs_volume *afs_insert_volume_into_cell(struct afs_cell *cell, in afs_insert_volume_into_cell() argument
24 write_seqlock(&cell->volume_lock); in afs_insert_volume_into_cell()
26 pp = &cell->volumes.rb_node; in afs_insert_volume_into_cell()
30 if (p->vid < volume->vid) { in afs_insert_volume_into_cell()
31 pp = &(*pp)->rb_left; in afs_insert_volume_into_cell()
32 } else if (p->vid > volume->vid) { in afs_insert_volume_into_cell()
33 pp = &(*pp)->rb_right; in afs_insert_volume_into_cell()
40 rb_link_node_rcu(&volume->cell_node, parent, pp); in afs_insert_volume_into_cell()
41 rb_insert_color(&volume->cell_node, &cell->volumes); in afs_insert_volume_into_cell()
42 hlist_add_head_rcu(&volume->proc_link, &cell->proc_volumes); in afs_insert_volume_into_cell()
45 write_sequnlock(&cell->volume_lock); in afs_insert_volume_into_cell()
52 struct afs_cell *cell = volume->cell; in afs_remove_volume_from_cell() local
54 if (!hlist_unhashed(&volume->proc_link)) { in afs_remove_volume_from_cell()
55 trace_afs_volume(volume->vid, refcount_read(&cell->ref), in afs_remove_volume_from_cell()
57 write_seqlock(&cell->volume_lock); in afs_remove_volume_from_cell()
58 hlist_del_rcu(&volume->proc_link); in afs_remove_volume_from_cell()
59 rb_erase(&volume->cell_node, &cell->volumes); in afs_remove_volume_from_cell()
60 write_sequnlock(&cell->volume_lock); in afs_remove_volume_from_cell()
73 int ret = -ENOMEM, nr_servers = 0, i; in afs_alloc_volume()
75 for (i = 0; i < vldb->nr_servers; i++) in afs_alloc_volume()
76 if (vldb->fs_mask[i] & type_mask) in afs_alloc_volume()
83 volume->vid = vldb->vid[params->type]; in afs_alloc_volume()
84 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_alloc_volume()
85 volume->cell = afs_get_cell(params->cell, afs_cell_trace_get_vol); in afs_alloc_volume()
86 volume->type = params->type; in afs_alloc_volume()
87 volume->type_force = params->force; in afs_alloc_volume()
88 volume->name_len = vldb->name_len; in afs_alloc_volume()
90 refcount_set(&volume->ref, 1); in afs_alloc_volume()
91 INIT_HLIST_NODE(&volume->proc_link); in afs_alloc_volume()
92 rwlock_init(&volume->servers_lock); in afs_alloc_volume()
93 rwlock_init(&volume->cb_v_break_lock); in afs_alloc_volume()
94 memcpy(volume->name, vldb->name, vldb->name_len + 1); in afs_alloc_volume()
96 slist = afs_alloc_server_list(params->cell, params->key, vldb, type_mask); in afs_alloc_volume()
102 refcount_set(&slist->usage, 1); in afs_alloc_volume()
103 rcu_assign_pointer(volume->servers, slist); in afs_alloc_volume()
104 trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc); in afs_alloc_volume()
108 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_alloc_volume()
127 volume = afs_insert_volume_into_cell(params->cell, candidate); in afs_lookup_volume()
129 afs_put_volume(params->net, candidate, afs_volume_trace_put_cell_dup); in afs_lookup_volume()
136 static struct afs_vldb_entry *afs_vl_lookup_vldb(struct afs_cell *cell, in afs_vl_lookup_vldb() argument
141 struct afs_vldb_entry *vldb = ERR_PTR(-EDESTADDRREQ); in afs_vl_lookup_vldb()
145 if (!afs_begin_vlserver_operation(&vc, cell, key)) in afs_vl_lookup_vldb()
146 return ERR_PTR(-ERESTARTSYS); in afs_vl_lookup_vldb()
161 * "%[cell:]volume[.]" R/W volume
162 * "#[cell:]volume[.]" R/O or R/W volume (rwparent=0),
164 * "%[cell:]volume.readonly" R/O volume
165 * "#[cell:]volume.readonly" R/O volume
166 * "%[cell:]volume.backup" Backup volume
167 * "#[cell:]volume.backup" Backup volume
169 * The cell name is optional, and defaults to the current cell.
173 * - Rule 1: Explicit type suffix forces access of that type or nothing
174 * (no suffix, then use Rule 2 & 3)
175 * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W
177 * - Rule 3: If parent volume is R/W, then only mount R/W volume unless
184 unsigned long type_mask = 1UL << params->type; in afs_create_volume()
186 vldb = afs_vl_lookup_vldb(params->cell, params->key, in afs_create_volume()
187 params->volname, params->volnamesz); in afs_create_volume()
191 if (test_bit(AFS_VLDB_QUERY_ERROR, &vldb->flags)) { in afs_create_volume()
192 volume = ERR_PTR(vldb->error); in afs_create_volume()
197 volume = ERR_PTR(-ENOMEDIUM); in afs_create_volume()
198 if (params->force) { in afs_create_volume()
199 if (!(vldb->flags & type_mask)) in afs_create_volume()
201 } else if (test_bit(AFS_VLDB_HAS_RO, &vldb->flags)) { in afs_create_volume()
202 params->type = AFSVL_ROVOL; in afs_create_volume()
203 } else if (test_bit(AFS_VLDB_HAS_RW, &vldb->flags)) { in afs_create_volume()
204 params->type = AFSVL_RWVOL; in afs_create_volume()
209 type_mask = 1UL << params->type; in afs_create_volume()
225 ASSERTCMP(volume->cache, ==, NULL); in afs_destroy_volume()
229 afs_put_serverlist(net, rcu_access_pointer(volume->servers)); in afs_destroy_volume()
230 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_destroy_volume()
231 trace_afs_volume(volume->vid, refcount_read(&volume->ref), in afs_destroy_volume()
247 __refcount_inc(&volume->ref, &r); in afs_get_volume()
248 trace_afs_volume(volume->vid, r + 1, reason); in afs_get_volume()
261 afs_volid_t vid = volume->vid; in afs_put_volume()
265 zero = __refcount_dec_and_test(&volume->ref, &r); in afs_put_volume()
266 trace_afs_volume(vid, r - 1, reason); in afs_put_volume()
282 volume->cell->name, volume->vid); in afs_activate_volume()
284 return -ENOMEM; in afs_activate_volume()
288 if (vcookie != ERR_PTR(-EBUSY)) { in afs_activate_volume()
295 volume->cache = vcookie; in afs_activate_volume()
306 _enter("%s", volume->name); in afs_deactivate_volume()
309 fscache_relinquish_volume(volume->cache, NULL, in afs_deactivate_volume()
310 test_bit(AFS_VOLUME_DELETED, &volume->flags)); in afs_deactivate_volume()
311 volume->cache = NULL; in afs_deactivate_volume()
332 idsz = sprintf(idbuf, "%llu", volume->vid); in afs_update_volume_status()
334 vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz); in afs_update_volume_status()
341 if (vldb->name_len != volume->name_len || in afs_update_volume_status()
342 memcmp(vldb->name, volume->name, vldb->name_len) != 0) { in afs_update_volume_status()
344 memcpy(volume->name, vldb->name, AFS_MAXVOLNAME); in afs_update_volume_status()
345 volume->name_len = vldb->name_len; in afs_update_volume_status()
349 new = afs_alloc_server_list(volume->cell, key, in afs_update_volume_status()
350 vldb, (1 << volume->type)); in afs_update_volume_status()
356 write_lock(&volume->servers_lock); in afs_update_volume_status()
359 old = rcu_dereference_protected(volume->servers, in afs_update_volume_status()
360 lockdep_is_held(&volume->servers_lock)); in afs_update_volume_status()
362 new->seq = volume->servers_seq + 1; in afs_update_volume_status()
363 rcu_assign_pointer(volume->servers, new); in afs_update_volume_status()
365 volume->servers_seq++; in afs_update_volume_status()
369 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_update_volume_status()
370 write_unlock(&volume->servers_lock); in afs_update_volume_status()
373 afs_put_serverlist(volume->cell->net, discard); in afs_update_volume_status()
391 if (test_bit(AFS_VOLUME_WAIT, &volume->flags)) in afs_check_volume_status()
393 if (volume->update_at <= ktime_get_real_seconds() || in afs_check_volume_status()
394 test_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags)) in afs_check_volume_status()
400 if (!test_and_set_bit_lock(AFS_VOLUME_UPDATING, &volume->flags)) { in afs_check_volume_status()
401 clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
402 ret = afs_update_volume_status(volume, op->key); in afs_check_volume_status()
404 set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
405 clear_bit_unlock(AFS_VOLUME_WAIT, &volume->flags); in afs_check_volume_status()
406 clear_bit_unlock(AFS_VOLUME_UPDATING, &volume->flags); in afs_check_volume_status()
407 wake_up_bit(&volume->flags, AFS_VOLUME_WAIT); in afs_check_volume_status()
413 if (!test_bit(AFS_VOLUME_WAIT, &volume->flags)) { in afs_check_volume_status()
418 ret = wait_on_bit(&volume->flags, AFS_VOLUME_WAIT, in afs_check_volume_status()
419 (op->flags & AFS_OPERATION_UNINTR) ? in afs_check_volume_status()
421 if (ret == -ERESTARTSYS) { in afs_check_volume_status()
428 _leave(" = -ESTALE"); in afs_check_volume_status()
429 return -ESTALE; in afs_check_volume_status()