~ubuntu-branches/ubuntu/quantal/lustre/quantal

« back to all changes in this revision

Viewing changes to lustre/ldlm/ldlm_resource.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-10-20 18:16:18 UTC
  • mfrom: (1.1.7 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20081020181618-rpzcecji8p5rghg3
Tags: 1.6.5.1-4
* [673c9e4] Removed obsolete svn-deblayout, since we now use git
* [1923e32] Bump standards version - no other changes needed.
* [089f772] Clean up TODO list
* [57f3006] Fix insanity.sh script which uses functions not available
  in sh
* [92e65fa] Fix two lintian msg about missing magic sh header
* [5214788] Removed unused patch from debian/patches/
* [cd08297] Add override for liblustre not linked against libc
* [e0ab205] Install lintian overrides into the corresponding packages
* [e76c899] Remove make -C $(KSRC) prepare call. (Closes: #501427)

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
        strcpy(ns->ns_name, name);
322
322
 
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);
354
355
        }
355
356
 
356
357
        at_init(&ns->ns_at_estimate, ldlm_enqueue_min, 0);
357
 
 
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);
362
359
 
363
360
        RETURN(ns);
364
361
out_proc:
504
501
        if (!ns)
505
502
                RETURN(ELDLM_OK);
506
503
 
507
 
        mutex_down(ldlm_namespace_lock(ns->ns_client));
508
 
        /*
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.
512
 
         */
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);
517
506
 
518
507
        /* At shutdown time, don't call the cancellation callback */
519
508
        ldlm_namespace_cleanup(ns, 0);
547
536
        if (!ns)
548
537
                RETURN(ELDLM_OK);
549
538
 
 
539
        /* 
 
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.
 
543
         */
 
544
        ldlm_pool_fini(&ns->ns_pool);
 
545
 
550
546
#ifdef LPROCFS
551
547
        {
552
548
                struct proc_dir_entry *dir;
595
591
        return ELDLM_OK;
596
592
}
597
593
 
598
 
void ldlm_namespace_get_nolock(struct ldlm_namespace *ns)
 
594
void ldlm_namespace_get_locked(struct ldlm_namespace *ns)
599
595
{
600
596
        LASSERT(ns->ns_refcount >= 0);
601
597
        ns->ns_refcount++;
604
600
void ldlm_namespace_get(struct ldlm_namespace *ns)
605
601
{
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);
609
605
}
610
606
 
611
 
void ldlm_namespace_put_nolock(struct ldlm_namespace *ns, int wakeup)
 
607
void ldlm_namespace_put_locked(struct ldlm_namespace *ns, int wakeup)
612
608
{
613
609
        LASSERT(ns->ns_refcount > 0);
614
610
        ns->ns_refcount--;
619
615
void ldlm_namespace_put(struct ldlm_namespace *ns, int wakeup)
620
616
{
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);
624
620
}
625
621
 
 
622
/* Register @ns in the list of namespaces */
 
623
void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client)
 
624
{
 
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));
 
630
}
 
631
 
 
632
/* Unregister @ns from the list of namespaces */
 
633
void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client)
 
634
{
 
635
        mutex_down(ldlm_namespace_lock(client));
 
636
        LASSERT(!list_empty(&ns->ns_list_chain));
 
637
        /*
 
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.
 
641
         */
 
642
        list_del_init(&ns->ns_list_chain);
 
643
        atomic_dec(ldlm_namespace_nr(client));
 
644
        mutex_up(ldlm_namespace_lock(client));
 
645
}
 
646
 
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)
628
649
{
629
650
        LASSERT(!list_empty(&ns->ns_list_chain));
630
651
        LASSERT_SEM_LOCKED(ldlm_namespace_lock(client));
632
653
}
633
654
 
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)
636
657
{
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);
751
772
 
752
773
        if (parent == NULL) {
753
774
                list_add(&res->lr_childof, &ns->ns_root_list);
846
867
 
847
868
        /* Pass 0 as second argument to not wake up ->ns_waitq yet, will do it
848
869
         * later. */
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);
852
873