diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-01 11:05:15 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-01 11:05:15 -0400 |
commit | e9fc2aa091ab8fa46e60d4c9d06a89305c441652 (patch) | |
tree | 8cdf5fcc4adba8cd53c51f824b5d8107ce0f4bba /fs/gfs2/quota.c | |
parent | c6e6f0ba8fc1dea99c7bd020916f24d533b62697 (diff) |
[GFS2] Update copyright, tidy up incore.h
As per comments from Jan Engelhardt <jengelh@linux01.gwdg.de> this
updates the copyright message to say "version" in full rather than
"v.2". Also incore.h has been updated to remove forward structure
declarations which are not required.
The gfs2_quota_lvb structure has now had endianess annotations added
to it. Also quota.c has been updated so that we now store the
lvb data locally in endian independant format to avoid needing
a structure in host endianess too. As a result the endianess
conversions are done as required at various points and thus the
conversion routines in lvb.[ch] are no longer required. I've
moved the one remaining constant in lvb.h thats used into lm.h
and removed the unused lvb.[ch].
I have not changed the HIF_ constants. That is left to a later patch
which I hope will unify the gh_flags and gh_iflags fields of the
struct gfs2_holder.
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/quota.c')
-rw-r--r-- | fs/gfs2/quota.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 3ca65c37c354..be87983a20a9 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * This copyrighted material is made available to anyone wishing to use, | 5 | * This copyrighted material is made available to anyone wishing to use, |
6 | * modify, copy, or redistribute it subject to the terms and conditions | 6 | * modify, copy, or redistribute it subject to the terms and conditions |
7 | * of the GNU General Public License v.2. | 7 | * of the GNU General Public License version 2. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
@@ -52,7 +52,6 @@ | |||
52 | #include "glock.h" | 52 | #include "glock.h" |
53 | #include "glops.h" | 53 | #include "glops.h" |
54 | #include "log.h" | 54 | #include "log.h" |
55 | #include "lvb.h" | ||
56 | #include "meta_io.h" | 55 | #include "meta_io.h" |
57 | #include "quota.h" | 56 | #include "quota.h" |
58 | #include "rgrp.h" | 57 | #include "rgrp.h" |
@@ -586,7 +585,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, | |||
586 | struct page *page; | 585 | struct page *page; |
587 | void *kaddr; | 586 | void *kaddr; |
588 | __be64 *ptr; | 587 | __be64 *ptr; |
589 | u64 value; | 588 | s64 value; |
590 | int err = -EIO; | 589 | int err = -EIO; |
591 | 590 | ||
592 | page = grab_cache_page(mapping, index); | 591 | page = grab_cache_page(mapping, index); |
@@ -627,7 +626,8 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, | |||
627 | 626 | ||
628 | kaddr = kmap_atomic(page, KM_USER0); | 627 | kaddr = kmap_atomic(page, KM_USER0); |
629 | ptr = (__be64 *)(kaddr + offset); | 628 | ptr = (__be64 *)(kaddr + offset); |
630 | value = *ptr = cpu_to_be64(be64_to_cpu(*ptr) + change); | 629 | value = (s64)be64_to_cpu(*ptr) + change; |
630 | *ptr = cpu_to_be64(value); | ||
631 | flush_dcache_page(page); | 631 | flush_dcache_page(page); |
632 | kunmap_atomic(kaddr, KM_USER0); | 632 | kunmap_atomic(kaddr, KM_USER0); |
633 | err = 0; | 633 | err = 0; |
@@ -761,6 +761,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, | |||
761 | char buf[sizeof(struct gfs2_quota)]; | 761 | char buf[sizeof(struct gfs2_quota)]; |
762 | struct file_ra_state ra_state; | 762 | struct file_ra_state ra_state; |
763 | int error; | 763 | int error; |
764 | struct gfs2_quota_lvb *qlvb; | ||
764 | 765 | ||
765 | file_ra_state_init(&ra_state, sdp->sd_quota_inode->i_mapping); | 766 | file_ra_state_init(&ra_state, sdp->sd_quota_inode->i_mapping); |
766 | restart: | 767 | restart: |
@@ -768,9 +769,9 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, | |||
768 | if (error) | 769 | if (error) |
769 | return error; | 770 | return error; |
770 | 771 | ||
771 | gfs2_quota_lvb_in(&qd->qd_qb, qd->qd_gl->gl_lvb); | 772 | qd->qd_qb = *(struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb; |
772 | 773 | ||
773 | if (force_refresh || qd->qd_qb.qb_magic != GFS2_MAGIC) { | 774 | if (force_refresh || qd->qd_qb.qb_magic != cpu_to_be32(GFS2_MAGIC)) { |
774 | loff_t pos; | 775 | loff_t pos; |
775 | gfs2_glock_dq_uninit(q_gh); | 776 | gfs2_glock_dq_uninit(q_gh); |
776 | error = gfs2_glock_nq_init(qd->qd_gl, | 777 | error = gfs2_glock_nq_init(qd->qd_gl, |
@@ -779,9 +780,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, | |||
779 | if (error) | 780 | if (error) |
780 | return error; | 781 | return error; |
781 | 782 | ||
782 | error = gfs2_glock_nq_init(ip->i_gl, | 783 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); |
783 | LM_ST_SHARED, 0, | ||
784 | &i_gh); | ||
785 | if (error) | 784 | if (error) |
786 | goto fail; | 785 | goto fail; |
787 | 786 | ||
@@ -794,15 +793,15 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, | |||
794 | 793 | ||
795 | gfs2_glock_dq_uninit(&i_gh); | 794 | gfs2_glock_dq_uninit(&i_gh); |
796 | 795 | ||
796 | |||
797 | gfs2_quota_in(&q, buf); | 797 | gfs2_quota_in(&q, buf); |
798 | 798 | qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb; | |
799 | memset(&qd->qd_qb, 0, sizeof(struct gfs2_quota_lvb)); | 799 | qlvb->qb_magic = cpu_to_be32(GFS2_MAGIC); |
800 | qd->qd_qb.qb_magic = GFS2_MAGIC; | 800 | qlvb->__pad = 0; |
801 | qd->qd_qb.qb_limit = q.qu_limit; | 801 | qlvb->qb_limit = cpu_to_be64(q.qu_limit); |
802 | qd->qd_qb.qb_warn = q.qu_warn; | 802 | qlvb->qb_warn = cpu_to_be64(q.qu_warn); |
803 | qd->qd_qb.qb_value = q.qu_value; | 803 | qlvb->qb_value = cpu_to_be64(q.qu_value); |
804 | 804 | qd->qd_qb = *qlvb; | |
805 | gfs2_quota_lvb_out(&qd->qd_qb, qd->qd_gl->gl_lvb); | ||
806 | 805 | ||
807 | if (gfs2_glock_is_blocking(qd->qd_gl)) { | 806 | if (gfs2_glock_is_blocking(qd->qd_gl)) { |
808 | gfs2_glock_dq_uninit(q_gh); | 807 | gfs2_glock_dq_uninit(q_gh); |
@@ -877,13 +876,14 @@ static int need_sync(struct gfs2_quota_data *qd) | |||
877 | 876 | ||
878 | if (value < 0) | 877 | if (value < 0) |
879 | do_sync = 0; | 878 | do_sync = 0; |
880 | else if (qd->qd_qb.qb_value >= (int64_t)qd->qd_qb.qb_limit) | 879 | else if ((s64)be64_to_cpu(qd->qd_qb.qb_value) >= |
880 | (s64)be64_to_cpu(qd->qd_qb.qb_limit)) | ||
881 | do_sync = 0; | 881 | do_sync = 0; |
882 | else { | 882 | else { |
883 | value *= gfs2_jindex_size(sdp) * num; | 883 | value *= gfs2_jindex_size(sdp) * num; |
884 | do_div(value, den); | 884 | do_div(value, den); |
885 | value += qd->qd_qb.qb_value; | 885 | value += (s64)be64_to_cpu(qd->qd_qb.qb_value); |
886 | if (value < (int64_t)qd->qd_qb.qb_limit) | 886 | if (value < (int64_t)be64_to_cpu(qd->qd_qb.qb_limit)) |
887 | do_sync = 0; | 887 | do_sync = 0; |
888 | } | 888 | } |
889 | 889 | ||
@@ -959,17 +959,17 @@ int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) | |||
959 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) | 959 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) |
960 | continue; | 960 | continue; |
961 | 961 | ||
962 | value = qd->qd_qb.qb_value; | 962 | value = (s64)be64_to_cpu(qd->qd_qb.qb_value); |
963 | spin_lock(&sdp->sd_quota_spin); | 963 | spin_lock(&sdp->sd_quota_spin); |
964 | value += qd->qd_change; | 964 | value += qd->qd_change; |
965 | spin_unlock(&sdp->sd_quota_spin); | 965 | spin_unlock(&sdp->sd_quota_spin); |
966 | 966 | ||
967 | if (qd->qd_qb.qb_limit && (int64_t)qd->qd_qb.qb_limit < value) { | 967 | if (be64_to_cpu(qd->qd_qb.qb_limit) && (int64_t)be64_to_cpu(qd->qd_qb.qb_limit) < value) { |
968 | print_message(qd, "exceeded"); | 968 | print_message(qd, "exceeded"); |
969 | error = -EDQUOT; | 969 | error = -EDQUOT; |
970 | break; | 970 | break; |
971 | } else if (qd->qd_qb.qb_warn && | 971 | } else if (be64_to_cpu(qd->qd_qb.qb_warn) && |
972 | (int64_t)qd->qd_qb.qb_warn < value && | 972 | (int64_t)be64_to_cpu(qd->qd_qb.qb_warn) < value && |
973 | time_after_eq(jiffies, qd->qd_last_warn + | 973 | time_after_eq(jiffies, qd->qd_last_warn + |
974 | gfs2_tune_get(sdp, | 974 | gfs2_tune_get(sdp, |
975 | gt_quota_warn_period) * HZ)) { | 975 | gt_quota_warn_period) * HZ)) { |
@@ -1088,9 +1088,9 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, | |||
1088 | goto out; | 1088 | goto out; |
1089 | 1089 | ||
1090 | memset(q, 0, sizeof(struct gfs2_quota)); | 1090 | memset(q, 0, sizeof(struct gfs2_quota)); |
1091 | q->qu_limit = qd->qd_qb.qb_limit; | 1091 | q->qu_limit = be64_to_cpu(qd->qd_qb.qb_limit); |
1092 | q->qu_warn = qd->qd_qb.qb_warn; | 1092 | q->qu_warn = be64_to_cpu(qd->qd_qb.qb_warn); |
1093 | q->qu_value = qd->qd_qb.qb_value; | 1093 | q->qu_value = be64_to_cpu(qd->qd_qb.qb_value); |
1094 | 1094 | ||
1095 | spin_lock(&sdp->sd_quota_spin); | 1095 | spin_lock(&sdp->sd_quota_spin); |
1096 | q->qu_value += qd->qd_change; | 1096 | q->qu_value += qd->qd_change; |