• Home
  • Raw
  • Download

Lines Matching full:volume

2 /* AFS volume management
15 * Insert a volume into a cell. If there's an existing volume record, that is
19 struct afs_volume *volume) in afs_insert_volume_into_cell() argument
30 if (p->vid < volume->vid) { in afs_insert_volume_into_cell()
32 } else if (p->vid > volume->vid) { in afs_insert_volume_into_cell()
36 volume = p; in afs_insert_volume_into_cell()
40 set_bit(AFS_VOLUME_RM_TREE, &volume->flags); in afs_insert_volume_into_cell()
41 rb_replace_node_rcu(&p->cell_node, &volume->cell_node, &cell->volumes); in afs_insert_volume_into_cell()
45 rb_link_node_rcu(&volume->cell_node, parent, pp); in afs_insert_volume_into_cell()
46 rb_insert_color(&volume->cell_node, &cell->volumes); in afs_insert_volume_into_cell()
47 hlist_add_head_rcu(&volume->proc_link, &cell->proc_volumes); in afs_insert_volume_into_cell()
51 return volume; in afs_insert_volume_into_cell()
55 static void afs_remove_volume_from_cell(struct afs_volume *volume) in afs_remove_volume_from_cell() argument
57 struct afs_cell *cell = volume->cell; in afs_remove_volume_from_cell()
59 if (!hlist_unhashed(&volume->proc_link)) { in afs_remove_volume_from_cell()
60 trace_afs_volume(volume->vid, refcount_read(&cell->ref), in afs_remove_volume_from_cell()
63 hlist_del_rcu(&volume->proc_link); in afs_remove_volume_from_cell()
64 if (!test_and_set_bit(AFS_VOLUME_RM_TREE, &volume->flags)) in afs_remove_volume_from_cell()
65 rb_erase(&volume->cell_node, &cell->volumes); in afs_remove_volume_from_cell()
71 * Allocate a volume record and load it up from a vldb record.
78 struct afs_volume *volume; in afs_alloc_volume() local
81 volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL); in afs_alloc_volume()
82 if (!volume) in afs_alloc_volume()
85 volume->vid = vldb->vid[params->type]; in afs_alloc_volume()
86 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_alloc_volume()
87 volume->cell = afs_get_cell(params->cell, afs_cell_trace_get_vol); in afs_alloc_volume()
88 volume->type = params->type; in afs_alloc_volume()
89 volume->type_force = params->force; in afs_alloc_volume()
90 volume->name_len = vldb->name_len; in afs_alloc_volume()
92 refcount_set(&volume->ref, 1); in afs_alloc_volume()
93 INIT_HLIST_NODE(&volume->proc_link); in afs_alloc_volume()
94 rwlock_init(&volume->servers_lock); in afs_alloc_volume()
95 rwlock_init(&volume->cb_v_break_lock); in afs_alloc_volume()
96 memcpy(volume->name, vldb->name, vldb->name_len + 1); in afs_alloc_volume()
99 volume->vids[i] = vldb->vid[i]; in afs_alloc_volume()
101 slist = afs_alloc_server_list(volume, params->key, vldb); in afs_alloc_volume()
108 rcu_assign_pointer(volume->servers, slist); in afs_alloc_volume()
109 trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc); in afs_alloc_volume()
110 return volume; in afs_alloc_volume()
113 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_alloc_volume()
114 kfree(volume); in afs_alloc_volume()
120 * Look up or allocate a volume record.
126 struct afs_volume *candidate, *volume; in afs_lookup_volume() local
132 volume = afs_insert_volume_into_cell(params->cell, candidate); in afs_lookup_volume()
133 if (volume == candidate) in afs_lookup_volume()
134 afs_attach_volume_to_servers(volume, slist); in afs_lookup_volume()
137 return volume; in afs_lookup_volume()
141 * Look up a VLDB record for a volume.
164 * Look up a volume in the VL server and create a candidate volume record for
167 * The volume name can be one of the following:
168 * "%[cell:]volume[.]" R/W volume
169 * "#[cell:]volume[.]" R/O or R/W volume (rwparent=0),
170 * or R/W (rwparent=1) volume
171 * "%[cell:]volume.readonly" R/O volume
172 * "#[cell:]volume.readonly" R/O volume
173 * "%[cell:]volume.backup" Backup volume
174 * "#[cell:]volume.backup" Backup volume
182 * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W
184 * - Rule 3: If parent volume is R/W, then only mount R/W volume unless
190 struct afs_volume *volume; in afs_create_volume() local
199 volume = ERR_PTR(vldb->error); in afs_create_volume()
204 volume = ERR_PTR(-ENOMEDIUM); in afs_create_volume()
216 volume = afs_lookup_volume(params, vldb); in afs_create_volume()
220 return volume; in afs_create_volume()
224 * Destroy a volume record
226 static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume) in afs_destroy_volume() argument
228 struct afs_server_list *slist = rcu_access_pointer(volume->servers); in afs_destroy_volume()
230 _enter("%p", volume); in afs_destroy_volume()
233 ASSERTCMP(volume->cache, ==, NULL); in afs_destroy_volume()
236 afs_detach_volume_from_servers(volume, slist); in afs_destroy_volume()
237 afs_remove_volume_from_cell(volume); in afs_destroy_volume()
239 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_destroy_volume()
240 trace_afs_volume(volume->vid, refcount_read(&volume->ref), in afs_destroy_volume()
242 kfree_rcu(volume, rcu); in afs_destroy_volume()
248 * Try to get a reference on a volume record.
250 bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason) in afs_try_get_volume() argument
254 if (__refcount_inc_not_zero(&volume->ref, &r)) { in afs_try_get_volume()
255 trace_afs_volume(volume->vid, r + 1, reason); in afs_try_get_volume()
262 * Get a reference on a volume record.
264 struct afs_volume *afs_get_volume(struct afs_volume *volume, in afs_get_volume() argument
267 if (volume) { in afs_get_volume()
270 __refcount_inc(&volume->ref, &r); in afs_get_volume()
271 trace_afs_volume(volume->vid, r + 1, reason); in afs_get_volume()
273 return volume; in afs_get_volume()
278 * Drop a reference on a volume record.
280 void afs_put_volume(struct afs_net *net, struct afs_volume *volume, in afs_put_volume() argument
283 if (volume) { in afs_put_volume()
284 afs_volid_t vid = volume->vid; in afs_put_volume()
288 zero = __refcount_dec_and_test(&volume->ref, &r); in afs_put_volume()
291 afs_destroy_volume(net, volume); in afs_put_volume()
296 * Activate a volume.
298 int afs_activate_volume(struct afs_volume *volume) in afs_activate_volume() argument
305 volume->cell->name, volume->vid); in afs_activate_volume()
315 pr_err("AFS: Cache volume key already in use (%s)\n", name); in afs_activate_volume()
318 volume->cache = vcookie; in afs_activate_volume()
325 * Deactivate a volume.
327 void afs_deactivate_volume(struct afs_volume *volume) in afs_deactivate_volume() argument
329 _enter("%s", volume->name); in afs_deactivate_volume()
332 fscache_relinquish_volume(volume->cache, NULL, in afs_deactivate_volume()
333 test_bit(AFS_VOLUME_DELETED, &volume->flags)); in afs_deactivate_volume()
334 volume->cache = NULL; in afs_deactivate_volume()
341 * Query the VL service to update the volume status.
343 static int afs_update_volume_status(struct afs_volume *volume, struct key *key) in afs_update_volume_status() argument
355 idsz = snprintf(idbuf, sizeof(idbuf), "%llu", volume->vid); in afs_update_volume_status()
357 vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz); in afs_update_volume_status()
363 /* See if the volume got renamed. */ in afs_update_volume_status()
364 if (vldb->name_len != volume->name_len || in afs_update_volume_status()
365 memcmp(vldb->name, volume->name, vldb->name_len) != 0) { in afs_update_volume_status()
367 memcpy(volume->name, vldb->name, AFS_MAXVOLNAME); in afs_update_volume_status()
368 volume->name_len = vldb->name_len; in afs_update_volume_status()
371 /* See if the volume's server list got updated. */ in afs_update_volume_status()
372 new = afs_alloc_server_list(volume, key, vldb); in afs_update_volume_status()
378 write_lock(&volume->servers_lock); in afs_update_volume_status()
381 old = rcu_dereference_protected(volume->servers, in afs_update_volume_status()
382 lockdep_is_held(&volume->servers_lock)); in afs_update_volume_status()
384 new->seq = volume->servers_seq + 1; in afs_update_volume_status()
385 rcu_assign_pointer(volume->servers, new); in afs_update_volume_status()
387 volume->servers_seq++; in afs_update_volume_status()
391 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_update_volume_status()
392 write_unlock(&volume->servers_lock); in afs_update_volume_status()
395 afs_reattach_volume_to_servers(volume, new, old); in afs_update_volume_status()
396 afs_put_serverlist(volume->cell->net, discard); in afs_update_volume_status()
406 * Make sure the volume record is up to date.
408 int afs_check_volume_status(struct afs_volume *volume, struct afs_operation *op) in afs_check_volume_status() argument
415 if (test_bit(AFS_VOLUME_WAIT, &volume->flags)) in afs_check_volume_status()
417 if (volume->update_at <= ktime_get_real_seconds() || in afs_check_volume_status()
418 test_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags)) in afs_check_volume_status()
424 if (!test_and_set_bit_lock(AFS_VOLUME_UPDATING, &volume->flags)) { in afs_check_volume_status()
425 clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
426 ret = afs_update_volume_status(volume, op->key); in afs_check_volume_status()
428 set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
429 clear_bit_unlock(AFS_VOLUME_WAIT, &volume->flags); in afs_check_volume_status()
430 clear_bit_unlock(AFS_VOLUME_UPDATING, &volume->flags); in afs_check_volume_status()
431 wake_up_bit(&volume->flags, AFS_VOLUME_WAIT); in afs_check_volume_status()
437 if (!test_bit(AFS_VOLUME_WAIT, &volume->flags)) { in afs_check_volume_status()
442 ret = wait_on_bit(&volume->flags, AFS_VOLUME_WAIT, in afs_check_volume_status()