diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2014-07-28 17:49:41 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-08-01 12:30:36 -0400 |
commit | 99eb1908e643609e83454c6fbcbb59f9055abf09 (patch) | |
tree | dd48bfd8f2521f35b75e839502727d76a91b6481 | |
parent | b02465308f13f3266480275fd143747bfd441a2f (diff) |
dm switch: factor out switch_region_table_read
Move code that reads the table to a switch_region_table_read.
It will be needed for the next commit. No functional change.
Tested-by: Jay Wang <jwang@nimblestorage.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r-- | drivers/md/dm-switch.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c index 09a688b3d48c..c40e0954cec8 100644 --- a/drivers/md/dm-switch.c +++ b/drivers/md/dm-switch.c | |||
@@ -137,13 +137,23 @@ static void switch_get_position(struct switch_ctx *sctx, unsigned long region_nr | |||
137 | *bit *= sctx->region_table_entry_bits; | 137 | *bit *= sctx->region_table_entry_bits; |
138 | } | 138 | } |
139 | 139 | ||
140 | static unsigned switch_region_table_read(struct switch_ctx *sctx, unsigned long region_nr) | ||
141 | { | ||
142 | unsigned long region_index; | ||
143 | unsigned bit; | ||
144 | |||
145 | switch_get_position(sctx, region_nr, ®ion_index, &bit); | ||
146 | |||
147 | return (ACCESS_ONCE(sctx->region_table[region_index]) >> bit) & | ||
148 | ((1 << sctx->region_table_entry_bits) - 1); | ||
149 | } | ||
150 | |||
140 | /* | 151 | /* |
141 | * Find which path to use at given offset. | 152 | * Find which path to use at given offset. |
142 | */ | 153 | */ |
143 | static unsigned switch_get_path_nr(struct switch_ctx *sctx, sector_t offset) | 154 | static unsigned switch_get_path_nr(struct switch_ctx *sctx, sector_t offset) |
144 | { | 155 | { |
145 | unsigned long region_index; | 156 | unsigned path_nr; |
146 | unsigned bit, path_nr; | ||
147 | sector_t p; | 157 | sector_t p; |
148 | 158 | ||
149 | p = offset; | 159 | p = offset; |
@@ -152,9 +162,7 @@ static unsigned switch_get_path_nr(struct switch_ctx *sctx, sector_t offset) | |||
152 | else | 162 | else |
153 | sector_div(p, sctx->region_size); | 163 | sector_div(p, sctx->region_size); |
154 | 164 | ||
155 | switch_get_position(sctx, p, ®ion_index, &bit); | 165 | path_nr = switch_region_table_read(sctx, p); |
156 | path_nr = (ACCESS_ONCE(sctx->region_table[region_index]) >> bit) & | ||
157 | ((1 << sctx->region_table_entry_bits) - 1); | ||
158 | 166 | ||
159 | /* This can only happen if the processor uses non-atomic stores. */ | 167 | /* This can only happen if the processor uses non-atomic stores. */ |
160 | if (unlikely(path_nr >= sctx->nr_paths)) | 168 | if (unlikely(path_nr >= sctx->nr_paths)) |