Skip to contentSkip to conversation

GFS2: Replace rgblk_search with gfs2_rbm_find

Cluster-devel Steven Whitehouse 1 participant 1 message Aug 2, 2012 GFS2 file system

lore
Share & tools
lore
#0 lore raw

Hi,

The following patch is another set along the road towards a clean up of the rgrp code. The overall plan is to refer to blocks using one of two representations (the block number or the newly added rbm representation) only. There will be a few exceptions where we have on-disk rgrp relative addressing, but eventually we'll convert those to use one or the other of the two internal types, I hope.

Also, there are a few helper functions which are introduced in this patch which are likely to be of use in other places in the code too.

Other potential improvements are to do a binary search for gfs2_rbm_from_block() rather than the current linear search.

I think this is enough change for a single patch though. I've given this a bit of testing and it seems to be doing the right thing. Much more testing is still required though, but I think this is ready to get an airing in public at this stage,

Steve.

From cd11a39a389d1c466e77b6089e69b83d92176b8f Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Wed, 1 Aug 2012 20:35:05 +0100
Subject: [PATCH] GFS2: Replace rgblk_search with gfs2_rbm_find

This is part of a series of patches which are introducing the gfs2_rbm structure throughout the block allocation code. The main aim of this part is to create a search function which can deal directly with struct gfs2_rbm. In this case it specifies the initial position at which to start the search and also the point at which the search terminates.

The net result of this is to clean up the search code and make it rather more readable, and the various possible exceptions which may occur during the search are partitioned into their own functions.

There are some bug fixes too. We should not be checking the reservations while allocating extents - the time for that is when we are searching for where to put the extent, not when we've already made that decision.

Also, rgblk_search had two uses, and in only one of those cases did it make sense to check for reservations. This is fixed in the new gfs2_rbm_find function, which has a cleaner interface.

The reservation checking has been improved by always checking for contiguous reservations, and returning the first free block after all contiguous reservations. This is done under the spin lock to ensure consistancy of the tree.

The allocation of extents is now in all cases done by the existing allocation code, and if there is an active reservation, that is updated after the fact. Again this is done under the spin lock, since it entails changing the lookup key for the reservation in question.

fs/gfs2/incore.h +7 -0
index d5e2546..99d7c64 100644
@@ -113,6 +113,13 @@ static inline u64 gfs2_rbm_to_block(const struct gfs2_rbm *rbm)
 	return rbm->rgd->rd_data0 + (rbm->bi->bi_start * GFS2_NBBY) + rbm->offset;
 }
 
+static inline bool gfs2_rbm_eq(const struct gfs2_rbm *rbm1,
+			       const struct gfs2_rbm *rbm2)
+{
+	return (rbm1->rgd == rbm2->rgd) && (rbm1->bi == rbm2->bi) && 
+	       (rbm1->offset == rbm2->offset);
+}
+
 enum gfs2_state_bits {
 	BH_Pinned = BH_PrivateStart,
 	BH_Escaped = BH_PrivateStart + 1,
fs/gfs2/rgrp.c +250 -210

551 lines not on this page · raw message

Signature · 1 line
1.7.4