diff options
author | Bob Peterson <rpeterso@redhat.com> | 2013-09-11 14:44:02 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2013-09-17 05:15:13 -0400 |
commit | 7e230f5774336c5c180d8aeab0e2cb1326c73fa3 (patch) | |
tree | 56b733f9e0ef00e4aa022adcd6a3c1e41fab1a84 /fs | |
parent | 6aa7640f306a1dd0923d29d9190c5686907d5140 (diff) |
GFS2: introduce bi_blocks for optimization
This patch introduces a new field in the bitmap structure called
bi_blocks. Its purpose is to save us from constantly multiplying
bi_len by the constant GFS2_NBBY. It also paves the way for more
optimization in a future patch.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 26aabd7caba7..f1a3243dfaf2 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -71,6 +71,7 @@ struct gfs2_bitmap { | |||
71 | u32 bi_offset; | 71 | u32 bi_offset; |
72 | u32 bi_start; | 72 | u32 bi_start; |
73 | u32 bi_len; | 73 | u32 bi_len; |
74 | u32 bi_blocks; | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | struct gfs2_rgrpd { | 77 | struct gfs2_rgrpd { |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 7a6fa03bb32a..7d64a27683d9 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -262,7 +262,7 @@ static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) | |||
262 | rbm->bi = rbm->rgd->rd_bits; | 262 | rbm->bi = rbm->rgd->rd_bits; |
263 | rbm->offset = (u32)(rblock); | 263 | rbm->offset = (u32)(rblock); |
264 | /* Check if the block is within the first block */ | 264 | /* Check if the block is within the first block */ |
265 | if (rbm->offset < rbm->bi->bi_len * GFS2_NBBY) | 265 | if (rbm->offset < rbm->bi->bi_blocks) |
266 | return 0; | 266 | return 0; |
267 | 267 | ||
268 | /* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */ | 268 | /* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */ |
@@ -743,18 +743,21 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
743 | bi->bi_offset = sizeof(struct gfs2_rgrp); | 743 | bi->bi_offset = sizeof(struct gfs2_rgrp); |
744 | bi->bi_start = 0; | 744 | bi->bi_start = 0; |
745 | bi->bi_len = bytes; | 745 | bi->bi_len = bytes; |
746 | bi->bi_blocks = bytes * GFS2_NBBY; | ||
746 | /* header block */ | 747 | /* header block */ |
747 | } else if (x == 0) { | 748 | } else if (x == 0) { |
748 | bytes = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_rgrp); | 749 | bytes = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_rgrp); |
749 | bi->bi_offset = sizeof(struct gfs2_rgrp); | 750 | bi->bi_offset = sizeof(struct gfs2_rgrp); |
750 | bi->bi_start = 0; | 751 | bi->bi_start = 0; |
751 | bi->bi_len = bytes; | 752 | bi->bi_len = bytes; |
753 | bi->bi_blocks = bytes * GFS2_NBBY; | ||
752 | /* last block */ | 754 | /* last block */ |
753 | } else if (x + 1 == length) { | 755 | } else if (x + 1 == length) { |
754 | bytes = bytes_left; | 756 | bytes = bytes_left; |
755 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 757 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
756 | bi->bi_start = rgd->rd_bitbytes - bytes_left; | 758 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
757 | bi->bi_len = bytes; | 759 | bi->bi_len = bytes; |
760 | bi->bi_blocks = bytes * GFS2_NBBY; | ||
758 | /* other blocks */ | 761 | /* other blocks */ |
759 | } else { | 762 | } else { |
760 | bytes = sdp->sd_sb.sb_bsize - | 763 | bytes = sdp->sd_sb.sb_bsize - |
@@ -762,6 +765,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
762 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 765 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
763 | bi->bi_start = rgd->rd_bitbytes - bytes_left; | 766 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
764 | bi->bi_len = bytes; | 767 | bi->bi_len = bytes; |
768 | bi->bi_blocks = bytes * GFS2_NBBY; | ||
765 | } | 769 | } |
766 | 770 | ||
767 | bytes_left -= bytes; | 771 | bytes_left -= bytes; |