diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-01-31 21:33:38 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:03 -0500 |
commit | 2f6c9896f71e6b6c1c565ea76dd9f5e89579c120 (patch) | |
tree | aa6cd3c4349c6268d68f93c2535818b664511ac5 /fs/gfs2 | |
parent | 558e85289fca3d3397882442d1a695936c4f2662 (diff) |
gfs2: Introduce qd2index
Both qd_alloc and qd2offset perform the exact same computation
to get an index from a gfs2_quota_data. Make life a little
simpler and factor out this index computation.
Cc: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/quota.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index f8279eed56e1..0e7c982377a1 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -120,11 +120,17 @@ out: | |||
120 | return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100; | 120 | return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100; |
121 | } | 121 | } |
122 | 122 | ||
123 | static u64 qd2index(struct gfs2_quota_data *qd) | ||
124 | { | ||
125 | return (2 * (u64)qd->qd_id) + | ||
126 | test_bit(QDF_USER, &qd->qd_flags) ? 0 : 1; | ||
127 | } | ||
128 | |||
123 | static u64 qd2offset(struct gfs2_quota_data *qd) | 129 | static u64 qd2offset(struct gfs2_quota_data *qd) |
124 | { | 130 | { |
125 | u64 offset; | 131 | u64 offset; |
126 | 132 | ||
127 | offset = 2 * (u64)qd->qd_id + !test_bit(QDF_USER, &qd->qd_flags); | 133 | offset = qd2index(qd); |
128 | offset *= sizeof(struct gfs2_quota); | 134 | offset *= sizeof(struct gfs2_quota); |
129 | 135 | ||
130 | return offset; | 136 | return offset; |
@@ -147,7 +153,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, | |||
147 | qd->qd_slot = -1; | 153 | qd->qd_slot = -1; |
148 | INIT_LIST_HEAD(&qd->qd_reclaim); | 154 | INIT_LIST_HEAD(&qd->qd_reclaim); |
149 | 155 | ||
150 | error = gfs2_glock_get(sdp, 2 * (u64)id + !user, | 156 | error = gfs2_glock_get(sdp, qd2index(qd), |
151 | &gfs2_quota_glops, CREATE, &qd->qd_gl); | 157 | &gfs2_quota_glops, CREATE, &qd->qd_gl); |
152 | if (error) | 158 | if (error) |
153 | goto fail; | 159 | goto fail; |