Lines Matching refs:volume
20 struct afs_volume *volume) in afs_insert_volume_into_cell() argument
31 if (p->vid < volume->vid) { in afs_insert_volume_into_cell()
33 } else if (p->vid > volume->vid) { in afs_insert_volume_into_cell()
36 volume = afs_get_volume(p, afs_volume_trace_get_cell_insert); in afs_insert_volume_into_cell()
41 rb_link_node_rcu(&volume->cell_node, parent, pp); in afs_insert_volume_into_cell()
42 rb_insert_color(&volume->cell_node, &cell->volumes); in afs_insert_volume_into_cell()
43 hlist_add_head_rcu(&volume->proc_link, &cell->proc_volumes); in afs_insert_volume_into_cell()
47 return volume; in afs_insert_volume_into_cell()
51 static void afs_remove_volume_from_cell(struct afs_volume *volume) in afs_remove_volume_from_cell() argument
53 struct afs_cell *cell = volume->cell; in afs_remove_volume_from_cell()
55 if (!hlist_unhashed(&volume->proc_link)) { in afs_remove_volume_from_cell()
56 trace_afs_volume(volume->vid, atomic_read(&volume->usage), in afs_remove_volume_from_cell()
59 hlist_del_rcu(&volume->proc_link); in afs_remove_volume_from_cell()
60 rb_erase(&volume->cell_node, &cell->volumes); in afs_remove_volume_from_cell()
73 struct afs_volume *volume; in afs_alloc_volume() local
80 volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL); in afs_alloc_volume()
81 if (!volume) in afs_alloc_volume()
84 volume->vid = vldb->vid[params->type]; in afs_alloc_volume()
85 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_alloc_volume()
86 volume->cell = afs_get_cell(params->cell, afs_cell_trace_get_vol); in afs_alloc_volume()
87 volume->type = params->type; in afs_alloc_volume()
88 volume->type_force = params->force; in afs_alloc_volume()
89 volume->name_len = vldb->name_len; in afs_alloc_volume()
91 atomic_set(&volume->usage, 1); in afs_alloc_volume()
92 INIT_HLIST_NODE(&volume->proc_link); in afs_alloc_volume()
93 rwlock_init(&volume->servers_lock); in afs_alloc_volume()
94 rwlock_init(&volume->cb_v_break_lock); in afs_alloc_volume()
95 memcpy(volume->name, vldb->name, vldb->name_len + 1); in afs_alloc_volume()
104 rcu_assign_pointer(volume->servers, slist); in afs_alloc_volume()
105 trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc); in afs_alloc_volume()
106 return volume; in afs_alloc_volume()
109 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_alloc_volume()
110 kfree(volume); in afs_alloc_volume()
122 struct afs_volume *candidate, *volume; in afs_lookup_volume() local
128 volume = afs_insert_volume_into_cell(params->cell, candidate); in afs_lookup_volume()
129 if (volume != candidate) in afs_lookup_volume()
131 return volume; in afs_lookup_volume()
184 struct afs_volume *volume; in afs_create_volume() local
193 volume = ERR_PTR(vldb->error); in afs_create_volume()
198 volume = ERR_PTR(-ENOMEDIUM); in afs_create_volume()
211 volume = afs_lookup_volume(params, vldb, type_mask); in afs_create_volume()
215 return volume; in afs_create_volume()
221 static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume) in afs_destroy_volume() argument
223 _enter("%p", volume); in afs_destroy_volume()
226 ASSERTCMP(volume->cache, ==, NULL); in afs_destroy_volume()
229 afs_remove_volume_from_cell(volume); in afs_destroy_volume()
230 afs_put_serverlist(net, rcu_access_pointer(volume->servers)); in afs_destroy_volume()
231 afs_put_cell(volume->cell, afs_cell_trace_put_vol); in afs_destroy_volume()
232 trace_afs_volume(volume->vid, atomic_read(&volume->usage), in afs_destroy_volume()
234 kfree_rcu(volume, rcu); in afs_destroy_volume()
242 struct afs_volume *afs_get_volume(struct afs_volume *volume, in afs_get_volume() argument
245 if (volume) { in afs_get_volume()
246 int u = atomic_inc_return(&volume->usage); in afs_get_volume()
247 trace_afs_volume(volume->vid, u, reason); in afs_get_volume()
249 return volume; in afs_get_volume()
256 void afs_put_volume(struct afs_net *net, struct afs_volume *volume, in afs_put_volume() argument
259 if (volume) { in afs_put_volume()
260 afs_volid_t vid = volume->vid; in afs_put_volume()
261 int u = atomic_dec_return(&volume->usage); in afs_put_volume()
264 afs_destroy_volume(net, volume); in afs_put_volume()
271 void afs_activate_volume(struct afs_volume *volume) in afs_activate_volume() argument
274 volume->cache = fscache_acquire_cookie(volume->cell->cache, in afs_activate_volume()
276 &volume->vid, sizeof(volume->vid), in afs_activate_volume()
278 volume, 0, true); in afs_activate_volume()
285 void afs_deactivate_volume(struct afs_volume *volume) in afs_deactivate_volume() argument
287 _enter("%s", volume->name); in afs_deactivate_volume()
290 fscache_relinquish_cookie(volume->cache, NULL, in afs_deactivate_volume()
291 test_bit(AFS_VOLUME_DELETED, &volume->flags)); in afs_deactivate_volume()
292 volume->cache = NULL; in afs_deactivate_volume()
301 static int afs_update_volume_status(struct afs_volume *volume, struct key *key) in afs_update_volume_status() argument
313 idsz = sprintf(idbuf, "%llu", volume->vid); in afs_update_volume_status()
315 vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz); in afs_update_volume_status()
322 if (vldb->name_len != volume->name_len || in afs_update_volume_status()
323 memcmp(vldb->name, volume->name, vldb->name_len) != 0) { in afs_update_volume_status()
325 memcpy(volume->name, vldb->name, AFS_MAXVOLNAME); in afs_update_volume_status()
326 volume->name_len = vldb->name_len; in afs_update_volume_status()
330 new = afs_alloc_server_list(volume->cell, key, in afs_update_volume_status()
331 vldb, (1 << volume->type)); in afs_update_volume_status()
337 write_lock(&volume->servers_lock); in afs_update_volume_status()
340 old = rcu_dereference_protected(volume->servers, in afs_update_volume_status()
341 lockdep_is_held(&volume->servers_lock)); in afs_update_volume_status()
343 new->seq = volume->servers_seq + 1; in afs_update_volume_status()
344 rcu_assign_pointer(volume->servers, new); in afs_update_volume_status()
346 volume->servers_seq++; in afs_update_volume_status()
350 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life; in afs_update_volume_status()
351 write_unlock(&volume->servers_lock); in afs_update_volume_status()
354 afs_put_serverlist(volume->cell->net, discard); in afs_update_volume_status()
365 int afs_check_volume_status(struct afs_volume *volume, struct afs_operation *op) in afs_check_volume_status() argument
372 if (test_bit(AFS_VOLUME_WAIT, &volume->flags)) in afs_check_volume_status()
374 if (volume->update_at <= ktime_get_real_seconds() || in afs_check_volume_status()
375 test_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags)) in afs_check_volume_status()
381 if (!test_and_set_bit_lock(AFS_VOLUME_UPDATING, &volume->flags)) { in afs_check_volume_status()
382 clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
383 ret = afs_update_volume_status(volume, op->key); in afs_check_volume_status()
385 set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); in afs_check_volume_status()
386 clear_bit_unlock(AFS_VOLUME_WAIT, &volume->flags); in afs_check_volume_status()
387 clear_bit_unlock(AFS_VOLUME_UPDATING, &volume->flags); in afs_check_volume_status()
388 wake_up_bit(&volume->flags, AFS_VOLUME_WAIT); in afs_check_volume_status()
394 if (!test_bit(AFS_VOLUME_WAIT, &volume->flags)) { in afs_check_volume_status()
399 ret = wait_on_bit(&volume->flags, AFS_VOLUME_WAIT, in afs_check_volume_status()