321
321
strcpy(ns->ns_name, name);
323
323
CFS_INIT_LIST_HEAD(&ns->ns_root_list);
324
CFS_INIT_LIST_HEAD(&ns->ns_list_chain);
324
325
ns->ns_refcount = 0;
325
326
ns->ns_client = client;
326
327
spin_lock_init(&ns->ns_hash_lock);
356
357
at_init(&ns->ns_at_estimate, ldlm_enqueue_min, 0);
358
mutex_down(ldlm_namespace_lock(client));
359
list_add(&ns->ns_list_chain, ldlm_namespace_list(client));
360
atomic_inc(ldlm_namespace_nr(client));
361
mutex_up(ldlm_namespace_lock(client));
358
ldlm_namespace_register(ns, client);
505
502
RETURN(ELDLM_OK);
507
mutex_down(ldlm_namespace_lock(ns->ns_client));
509
* Some asserts and possibly other parts of code still using
510
* list_empty(&ns->ns_list_chain). This is why it is important
511
* to use list_del_init() here.
513
list_del_init(&ns->ns_list_chain);
514
atomic_dec(ldlm_namespace_nr(ns->ns_client));
515
ldlm_pool_fini(&ns->ns_pool);
516
mutex_up(ldlm_namespace_lock(ns->ns_client));
504
/* Remove @ns from its list. */
505
ldlm_namespace_unregister(ns, ns->ns_client);
518
507
/* At shutdown time, don't call the cancellation callback */
519
508
ldlm_namespace_cleanup(ns, 0);
548
537
RETURN(ELDLM_OK);
540
* Fini pool _before_ parent proc dir is removed. This is important as
541
* ldlm_pool_fini() removes own proc dir which is child to @dir. Removing
542
* it after @dir may cause oops.
544
ldlm_pool_fini(&ns->ns_pool);
552
548
struct proc_dir_entry *dir;
604
600
void ldlm_namespace_get(struct ldlm_namespace *ns)
606
602
spin_lock(&ns->ns_hash_lock);
607
ldlm_namespace_get_nolock(ns);
603
ldlm_namespace_get_locked(ns);
608
604
spin_unlock(&ns->ns_hash_lock);
611
void ldlm_namespace_put_nolock(struct ldlm_namespace *ns, int wakeup)
607
void ldlm_namespace_put_locked(struct ldlm_namespace *ns, int wakeup)
613
609
LASSERT(ns->ns_refcount > 0);
614
610
ns->ns_refcount--;
619
615
void ldlm_namespace_put(struct ldlm_namespace *ns, int wakeup)
621
617
spin_lock(&ns->ns_hash_lock);
622
ldlm_namespace_put_nolock(ns, wakeup);
618
ldlm_namespace_put_locked(ns, wakeup);
623
619
spin_unlock(&ns->ns_hash_lock);
622
/* Register @ns in the list of namespaces */
623
void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client)
625
mutex_down(ldlm_namespace_lock(client));
626
LASSERT(list_empty(&ns->ns_list_chain));
627
list_add(&ns->ns_list_chain, ldlm_namespace_list(client));
628
atomic_inc(ldlm_namespace_nr(client));
629
mutex_up(ldlm_namespace_lock(client));
632
/* Unregister @ns from the list of namespaces */
633
void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client)
635
mutex_down(ldlm_namespace_lock(client));
636
LASSERT(!list_empty(&ns->ns_list_chain));
638
* Some asserts and possibly other parts of code still using
639
* list_empty(&ns->ns_list_chain). This is why it is important
640
* to use list_del_init() here.
642
list_del_init(&ns->ns_list_chain);
643
atomic_dec(ldlm_namespace_nr(client));
644
mutex_up(ldlm_namespace_lock(client));
626
647
/* Should be called under ldlm_namespace_lock(client) taken */
627
void ldlm_namespace_move(struct ldlm_namespace *ns, ldlm_side_t client)
648
void ldlm_namespace_move_locked(struct ldlm_namespace *ns, ldlm_side_t client)
629
650
LASSERT(!list_empty(&ns->ns_list_chain));
630
651
LASSERT_SEM_LOCKED(ldlm_namespace_lock(client));
634
655
/* Should be called under ldlm_namespace_lock(client) taken */
635
struct ldlm_namespace *ldlm_namespace_first(ldlm_side_t client)
656
struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client)
637
658
LASSERT_SEM_LOCKED(ldlm_namespace_lock(client));
638
659
LASSERT(!list_empty(ldlm_namespace_list(client)));
747
768
bucket = ns->ns_hash + hash;
748
769
list_add(&res->lr_hash, bucket);
749
770
ns->ns_resources++;
750
ldlm_namespace_get_nolock(ns);
771
ldlm_namespace_get_locked(ns);
752
773
if (parent == NULL) {
753
774
list_add(&res->lr_childof, &ns->ns_root_list);
847
868
/* Pass 0 as second argument to not wake up ->ns_waitq yet, will do it
849
ldlm_namespace_put_nolock(ns, 0);
870
ldlm_namespace_put_locked(ns, 0);
850
871
list_del_init(&res->lr_hash);
851
872
list_del_init(&res->lr_childof);