Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f6c9896 authored by Eric W. Biederman's avatar Eric W. Biederman
Browse files

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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 558e8528
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -120,11 +120,17 @@ int gfs2_shrink_qd_memory(struct shrinker *shrink, struct shrink_control *sc)
	return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100;
	return (atomic_read(&qd_lru_count) * sysctl_vfs_cache_pressure) / 100;
}
}


static u64 qd2index(struct gfs2_quota_data *qd)
{
	return (2 * (u64)qd->qd_id) +
		test_bit(QDF_USER, &qd->qd_flags) ? 0 : 1;
}

static u64 qd2offset(struct gfs2_quota_data *qd)
static u64 qd2offset(struct gfs2_quota_data *qd)
{
{
	u64 offset;
	u64 offset;


	offset = 2 * (u64)qd->qd_id + !test_bit(QDF_USER, &qd->qd_flags);
	offset = qd2index(qd);
	offset *= sizeof(struct gfs2_quota);
	offset *= sizeof(struct gfs2_quota);


	return offset;
	return offset;
@@ -147,7 +153,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id,
	qd->qd_slot = -1;
	qd->qd_slot = -1;
	INIT_LIST_HEAD(&qd->qd_reclaim);
	INIT_LIST_HEAD(&qd->qd_reclaim);


	error = gfs2_glock_get(sdp, 2 * (u64)id + !user,
	error = gfs2_glock_get(sdp, qd2index(qd),
			      &gfs2_quota_glops, CREATE, &qd->qd_gl);
			      &gfs2_quota_glops, CREATE, &qd->qd_gl);
	if (error)
	if (error)
		goto fail;
		goto fail;