~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/ocfs2/quota_global.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include <linux/writeback.h>
12
12
#include <linux/workqueue.h>
13
13
 
14
 
#define MLOG_MASK_PREFIX ML_QUOTA
15
14
#include <cluster/masklog.h>
16
15
 
17
16
#include "ocfs2_fs.h"
27
26
#include "super.h"
28
27
#include "buffer_head_io.h"
29
28
#include "quota.h"
 
29
#include "ocfs2_trace.h"
30
30
 
31
31
/*
32
32
 * Locking of quotas with OCFS2 is rather complex. Here are rules that
63
63
 *        write to gf
64
64
 */
65
65
 
66
 
static struct workqueue_struct *ocfs2_quota_wq = NULL;
67
 
 
68
66
static void qsync_work_fn(struct work_struct *work);
69
67
 
70
68
static void ocfs2_global_disk2memdqb(struct dquot *dquot, void *dp)
132
130
        struct ocfs2_disk_dqtrailer *dqt =
133
131
                ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data);
134
132
 
135
 
        mlog(0, "Validating quota block %llu\n",
136
 
             (unsigned long long)bh->b_blocknr);
 
133
        trace_ocfs2_validate_quota_block((unsigned long long)bh->b_blocknr);
137
134
 
138
135
        BUG_ON(!buffer_uptodate(bh));
139
136
 
343
340
        u64 pcount;
344
341
        int status;
345
342
 
346
 
        mlog_entry_void();
347
 
 
348
343
        /* Read global header */
349
344
        gqinode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type],
350
345
                        OCFS2_INVALID_SLOT);
400
395
                                                OCFS2_QBLK_RESERVED_SPACE;
401
396
        oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi);
402
397
        INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn);
403
 
        queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
404
 
                           msecs_to_jiffies(oinfo->dqi_syncms));
 
398
        schedule_delayed_work(&oinfo->dqi_sync_work,
 
399
                              msecs_to_jiffies(oinfo->dqi_syncms));
405
400
 
406
401
out_err:
407
 
        mlog_exit(status);
 
402
        if (status)
 
403
                mlog_errno(status);
408
404
        return status;
409
405
out_unlock:
410
406
        ocfs2_unlock_global_qf(oinfo, 0);
510
506
        olditime = dquot->dq_dqb.dqb_itime;
511
507
        oldbtime = dquot->dq_dqb.dqb_btime;
512
508
        ocfs2_global_disk2memdqb(dquot, &dqblk);
513
 
        mlog(0, "Syncing global dquot %u space %lld+%lld, inodes %lld+%lld\n",
514
 
             dquot->dq_id, dquot->dq_dqb.dqb_curspace, (long long)spacechange,
515
 
             dquot->dq_dqb.dqb_curinodes, (long long)inodechange);
 
509
        trace_ocfs2_sync_dquot(dquot->dq_id, dquot->dq_dqb.dqb_curspace,
 
510
                               (long long)spacechange,
 
511
                               dquot->dq_dqb.dqb_curinodes,
 
512
                               (long long)inodechange);
516
513
        if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags))
517
514
                dquot->dq_dqb.dqb_curspace += spacechange;
518
515
        if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags))
559
556
        spin_unlock(&dq_data_lock);
560
557
        err = ocfs2_qinfo_lock(info, freeing);
561
558
        if (err < 0) {
562
 
                mlog(ML_ERROR, "Failed to lock quota info, loosing quota write"
 
559
                mlog(ML_ERROR, "Failed to lock quota info, losing quota write"
563
560
                               " (type=%d, id=%u)\n", dquot->dq_type,
564
561
                               (unsigned)dquot->dq_id);
565
562
                goto out;
596
593
        struct ocfs2_super *osb = OCFS2_SB(sb);
597
594
        int status = 0;
598
595
 
599
 
        mlog_entry("id=%u qtype=%u type=%lu device=%s\n", dquot->dq_id,
600
 
                   dquot->dq_type, type, sb->s_id);
 
596
        trace_ocfs2_sync_dquot_helper(dquot->dq_id, dquot->dq_type,
 
597
                                      type, sb->s_id);
601
598
        if (type != dquot->dq_type)
602
599
                goto out;
603
600
        status = ocfs2_lock_global_qf(oinfo, 1);
623
620
out_ilock:
624
621
        ocfs2_unlock_global_qf(oinfo, 1);
625
622
out:
626
 
        mlog_exit(status);
627
623
        return status;
628
624
}
629
625
 
635
631
        struct super_block *sb = oinfo->dqi_gqinode->i_sb;
636
632
 
637
633
        dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type);
638
 
        queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
639
 
                           msecs_to_jiffies(oinfo->dqi_syncms));
 
634
        schedule_delayed_work(&oinfo->dqi_sync_work,
 
635
                              msecs_to_jiffies(oinfo->dqi_syncms));
640
636
}
641
637
 
642
638
/*
649
645
        struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
650
646
        int status = 0;
651
647
 
652
 
        mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
 
648
        trace_ocfs2_write_dquot(dquot->dq_id, dquot->dq_type);
653
649
 
654
650
        handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS);
655
651
        if (IS_ERR(handle)) {
662
658
        mutex_unlock(&sb_dqopt(dquot->dq_sb)->dqio_mutex);
663
659
        ocfs2_commit_trans(osb, handle);
664
660
out:
665
 
        mlog_exit(status);
666
661
        return status;
667
662
}
668
663
 
688
683
        struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
689
684
        int status = 0;
690
685
 
691
 
        mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
 
686
        trace_ocfs2_release_dquot(dquot->dq_id, dquot->dq_type);
692
687
 
693
688
        mutex_lock(&dquot->dq_lock);
694
689
        /* Check whether we are not racing with some other dqget() */
724
719
        ocfs2_unlock_global_qf(oinfo, 1);
725
720
out:
726
721
        mutex_unlock(&dquot->dq_lock);
727
 
        mlog_exit(status);
 
722
        if (status)
 
723
                mlog_errno(status);
728
724
        return status;
729
725
}
730
726
 
745
741
        int need_alloc = ocfs2_global_qinit_alloc(sb, type);
746
742
        handle_t *handle;
747
743
 
748
 
        mlog_entry("id=%u, type=%d", dquot->dq_id, type);
 
744
        trace_ocfs2_acquire_dquot(dquot->dq_id, type);
749
745
        mutex_lock(&dquot->dq_lock);
750
746
        /*
751
747
         * We need an exclusive lock, because we're going to update use count
811
807
        set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
812
808
out:
813
809
        mutex_unlock(&dquot->dq_lock);
814
 
        mlog_exit(status);
 
810
        if (status)
 
811
                mlog_errno(status);
815
812
        return status;
816
813
}
817
814
 
831
828
        handle_t *handle;
832
829
        struct ocfs2_super *osb = OCFS2_SB(sb);
833
830
 
834
 
        mlog_entry("id=%u, type=%d", dquot->dq_id, type);
 
831
        trace_ocfs2_mark_dquot_dirty(dquot->dq_id, type);
835
832
 
836
833
        /* In case user set some limits, sync dquot immediately to global
837
834
         * quota file so that information propagates quicker */
868
865
out_ilock:
869
866
        ocfs2_unlock_global_qf(oinfo, 1);
870
867
out:
871
 
        mlog_exit(status);
 
868
        if (status)
 
869
                mlog_errno(status);
872
870
        return status;
873
871
}
874
872
 
879
877
        int status = 0;
880
878
        struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
881
879
 
882
 
        mlog_entry_void();
883
 
 
884
880
        status = ocfs2_lock_global_qf(oinfo, 1);
885
881
        if (status < 0)
886
882
                goto out;
895
891
out_ilock:
896
892
        ocfs2_unlock_global_qf(oinfo, 1);
897
893
out:
898
 
        mlog_exit(status);
 
894
        if (status)
 
895
                mlog_errno(status);
899
896
        return status;
900
897
}
901
898
 
923
920
        .alloc_dquot    = ocfs2_alloc_dquot,
924
921
        .destroy_dquot  = ocfs2_destroy_dquot,
925
922
};
926
 
 
927
 
int ocfs2_quota_setup(void)
928
 
{
929
 
        ocfs2_quota_wq = create_workqueue("o2quot");
930
 
        if (!ocfs2_quota_wq)
931
 
                return -ENOMEM;
932
 
        return 0;
933
 
}
934
 
 
935
 
void ocfs2_quota_shutdown(void)
936
 
{
937
 
        if (ocfs2_quota_wq) {
938
 
                flush_workqueue(ocfs2_quota_wq);
939
 
                destroy_workqueue(ocfs2_quota_wq);
940
 
                ocfs2_quota_wq = NULL;
941
 
        }
942
 
}