aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2013-05-01 21:31:17 +0900
committerDaniel Phillips <daniel@tux3.org>2013-05-01 21:31:17 +0900
commit0b6c746d54fb9cc544c0c0c52fbaf35e0b1e6cf9 (patch)
tree2c4e38f95f12ded66482ae8728f6dab5fd5d3fc3
parentd041487ebc7bf8f00f41d3bfbb983c16e385f20b (diff)
downloadlinux-tux3-0b6c746d54fb9cc544c0c0c52fbaf35e0b1e6cf9.tar.gz
tux3: Prepare to teach partial allocation to data extent
This is cleanup, and has no logical change. Rename some dleaf_req fields. nr_seg => seg_idx max_segs => seg_cnt and introduce new seg_max for tell seg[] buffer size. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
-rw-r--r--fs/tux3/dleaf2.c28
-rw-r--r--fs/tux3/dleaf2.h9
-rw-r--r--fs/tux3/filemap.c36
3 files changed, 37 insertions, 36 deletions
diff --git a/fs/tux3/dleaf2.c b/fs/tux3/dleaf2.c
index 34923dc4cf722a..82392d402a877d 100644
--- a/fs/tux3/dleaf2.c
+++ b/fs/tux3/dleaf2.c
@@ -409,8 +409,8 @@ static int dleaf2_write(struct btree *btree, tuxkey_t key_bottom,
int need_split, ret;
/* Paranoia checks */
- assert(key->len == seg_total_count(rq->seg + rq->nr_segs,
- rq->max_segs - rq->nr_segs));
+ assert(key->len == seg_total_count(rq->seg + rq->seg_idx,
+ rq->seg_cnt - rq->seg_idx));
/*
* Overwrite existent diskextent2 by specified segs. To do
@@ -423,7 +423,7 @@ static int dleaf2_write(struct btree *btree, tuxkey_t key_bottom,
dleaf2_init_sentinel(sb, dleaf, key_bottom);
limit = key->start + key->len;
- write_segs = rq->max_segs - rq->nr_segs;
+ write_segs = rq->seg_cnt - rq->seg_idx;
dex_limit = dleaf->table + be16_to_cpu(dleaf->count);
need = write_segs + 1; /* +1 is for sentinel */
@@ -514,7 +514,7 @@ recheck:
* New segs was added by ->seg_balloc().
* Adjust number of segs by adding separated numbers
*/
- write_segs = rq->max_segs - rq->nr_segs;
+ write_segs = rq->seg_cnt - rq->seg_idx;
need = orig_need + ret;
goto recheck;
}
@@ -524,14 +524,14 @@ recheck:
assert(need == be16_to_cpu(dleaf->count));
/* Fill extents */
- while (rq->nr_segs < rq->max_segs - rest_segs) {
- struct block_segment *seg = rq->seg + rq->nr_segs;
+ while (rq->seg_idx < rq->seg_cnt - rest_segs) {
+ struct block_segment *seg = rq->seg + rq->seg_idx;
put_extent(dex_start, sb->version, key->start, seg->block);
key->start += seg->count;
key->len -= seg->count;
- rq->nr_segs++;
+ rq->seg_idx++;
dex_start++;
}
if (rest_segs) {
@@ -560,7 +560,7 @@ static int dleaf2_read(struct btree *btree, tuxkey_t key_bottom,
struct extent next;
block_t physical;
- if (rq->nr_segs >= rq->max_segs)
+ if (rq->seg_idx >= rq->seg_cnt)
return 0;
dex_limit = dleaf->table + be16_to_cpu(dleaf->count);
@@ -585,7 +585,7 @@ static int dleaf2_read(struct btree *btree, tuxkey_t key_bottom,
dex++;
do {
- struct block_segment *seg = rq->seg + rq->nr_segs;
+ struct block_segment *seg = rq->seg + rq->seg_idx;
get_extent(dex, &next);
@@ -602,14 +602,14 @@ static int dleaf2_read(struct btree *btree, tuxkey_t key_bottom,
physical = next.physical;
key->start += seg->count;
key->len -= seg->count;
- rq->nr_segs++;
+ rq->seg_idx++;
dex++;
- } while (key->len && rq->nr_segs < rq->max_segs && dex < dex_limit);
+ } while (key->len && rq->seg_idx < rq->seg_cnt && dex < dex_limit);
fill_seg:
/* Between sentinel and key_limit is hole */
- if (key->start < key_limit && key->len && rq->nr_segs < rq->max_segs) {
- struct block_segment *seg = rq->seg + rq->nr_segs;
+ if (key->start < key_limit && key->len && rq->seg_idx < rq->seg_cnt) {
+ struct block_segment *seg = rq->seg + rq->seg_idx;
seg->count = min_t(tuxkey_t, key->len, key_limit - key->start);
seg->block = 0;
@@ -617,7 +617,7 @@ fill_seg:
key->start += seg->count;
key->len -= seg->count;
- rq->nr_segs++;
+ rq->seg_idx++;
}
return 0;
diff --git a/fs/tux3/dleaf2.h b/fs/tux3/dleaf2.h
index 5e32fc1dab87a7..7d2f1cf3526a21 100644
--- a/fs/tux3/dleaf2.h
+++ b/fs/tux3/dleaf2.h
@@ -4,11 +4,10 @@
struct dleaf_req {
struct btree_key_range key; /* index and count */
- int nr_segs; /* For read: how many segs was read.
- * For write: how many segs was written. */
- int max_segs; /* For read: how many seg[] are available
- * For write: how many seg[] to write */
- struct block_segment *seg; /* pointer to seg[] */
+ int seg_idx; /* Current offset for seg[] */
+ int seg_cnt; /* How many segs are available */
+ int seg_max; /* Max size of seg[] */
+ struct block_segment *seg; /* Pointer to seg[] */
/* Callback to allocate blocks to ->seg for write */
int (*seg_alloc)(struct btree *, struct dleaf_req *, int);
diff --git a/fs/tux3/filemap.c b/fs/tux3/filemap.c
index 7d0b01cbe88fe6..67f8f04b0e624c 100644
--- a/fs/tux3/filemap.c
+++ b/fs/tux3/filemap.c
@@ -85,7 +85,7 @@ static int map_bfree(struct inode *inode, block_t block, unsigned count)
/* map_region() by using dleaf1 */
static int map_region1(struct inode *inode, block_t start, unsigned count,
- struct block_segment seg[], unsigned max_segs,
+ struct block_segment seg[], unsigned seg_max,
enum map_mode mode)
{
struct sb *sb = tux_sb(inode->i_sb);
@@ -93,7 +93,7 @@ static int map_region1(struct inode *inode, block_t start, unsigned count,
struct cursor *cursor = NULL;
int err, segs = 0;
- assert(max_segs > 0);
+ assert(seg_max > 0);
/*
* bitmap enters here recursively.
@@ -170,7 +170,7 @@ static int map_region1(struct inode *inode, block_t start, unsigned count,
seg_start = dwalk_index(walk);
else
seg_start = index;
- while (index < limit && segs < max_segs) {
+ while (index < limit && segs < seg_max) {
block_t ex_index;
if (!dwalk_end(walk))
ex_index = dwalk_index(walk);
@@ -365,9 +365,9 @@ static int seg_alloc(struct btree *btree, struct dleaf_req *rq,
struct block_segment *seg = rq->seg;
int i;
- assert(rq->nr_segs + write_segs <= rq->max_segs);
+ assert(rq->seg_idx + write_segs <= rq->seg_cnt);
- for (i = rq->nr_segs; i < rq->nr_segs + write_segs; i++) {
+ for (i = rq->seg_idx; i < rq->seg_idx + write_segs; i++) {
int err;
if (seg[i].state != BLOCK_SEG_HOLE)
@@ -423,14 +423,14 @@ static int (*seg_alloc_funs[])(struct btree *, struct dleaf_req *, int) = {
/* map_region() by using dleaf2 */
static int map_region2(struct inode *inode, block_t start, unsigned count,
- struct block_segment seg[], unsigned max_segs,
+ struct block_segment seg[], unsigned seg_max,
enum map_mode mode)
{
struct btree *btree = &tux_inode(inode)->btree;
struct cursor *cursor = NULL;
int err, segs = 0;
- assert(max_segs > 0);
+ assert(seg_max > 0);
/*
* bitmap enters here recursively.
@@ -470,7 +470,8 @@ static int map_region2(struct inode *inode, block_t start, unsigned count,
.start = start,
.len = count,
},
- .max_segs = max_segs,
+ .seg_cnt = seg_max,
+ .seg_max = seg_max,
.seg = seg,
};
@@ -491,9 +492,9 @@ static int map_region2(struct inode *inode, block_t start, unsigned count,
segs = err;
goto out_unlock;
}
- segs = rq.nr_segs;
+ segs = rq.seg_idx;
/*
- * Read might be partial. (due to max_segs, or FIXME:
+ * Read might be partial. (due to seg_max, or FIXME:
* lack of read for multiple leaves)
*/
count = seg_total_count(seg, segs);
@@ -532,7 +533,8 @@ static int map_region2(struct inode *inode, block_t start, unsigned count,
.start = start,
.len = count,
},
- .max_segs = segs,
+ .seg_cnt = segs,
+ .seg_max = seg_max,
.seg = seg,
.seg_alloc = seg_alloc_funs[mode],
};
@@ -541,7 +543,7 @@ static int map_region2(struct inode *inode, block_t start, unsigned count,
segs = err;
goto out_release;
}
- assert(segs == rq.nr_segs);
+ assert(segs == rq.seg_idx);
out_release:
if (cursor)
@@ -567,7 +569,7 @@ out_unlock:
* 0 < - number of physical extents which were mapped
*/
static int map_region(struct inode *inode, block_t start, unsigned count,
- struct block_segment seg[], unsigned max_segs,
+ struct block_segment seg[], unsigned seg_max,
enum map_mode mode)
{
struct btree *btree = &tux_inode(inode)->btree;
@@ -581,7 +583,7 @@ static int map_region(struct inode *inode, block_t start, unsigned count,
if (mode == MAP_READ) {
/* If whole region was hole, don't need to call map_region */
if (tux3_is_hole(inode, start, count)) {
- assert(max_segs >= 1);
+ assert(seg_max >= 1);
seg[0].state = BLOCK_SEG_HOLE;
seg[0].block = 0;
seg[0].count = count;
@@ -590,13 +592,13 @@ static int map_region(struct inode *inode, block_t start, unsigned count,
}
if (btree->ops == &dtree1_ops)
- segs = map_region1(inode, start, count, seg, max_segs, mode);
+ segs = map_region1(inode, start, count, seg, seg_max, mode);
else
- segs = map_region2(inode, start, count, seg, max_segs, mode);
+ segs = map_region2(inode, start, count, seg, seg_max, mode);
if (mode == MAP_READ) {
/* Update seg[] with hole information */
- segs = tux3_map_hole(inode, start, count, seg, segs, max_segs);
+ segs = tux3_map_hole(inode, start, count, seg, segs, seg_max);
}
return segs;