Skip to content

Commit 99eb190

Browse files
Mikulas Patockasnitm
authored andcommitted
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>
1 parent b024653 commit 99eb190

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎drivers/md/dm-switch.c‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,23 @@ static void switch_get_position(struct switch_ctx *sctx, unsigned long region_nr
137137
*bit *= sctx->region_table_entry_bits;
138138
}
139139

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, &region_index, &bit);
146+
147+
return (ACCESS_ONCE(sctx->region_table[region_index]) >> bit) &
148+
((1 << sctx->region_table_entry_bits) - 1);
149+
}
150+
140151
/*
141152
* Find which path to use at given offset.
142153
*/
143154
static unsigned switch_get_path_nr(struct switch_ctx *sctx, sector_t offset)
144155
{
145-
unsigned long region_index;
146-
unsigned bit, path_nr;
156+
unsigned path_nr;
147157
sector_t p;
148158

149159
p = offset;
@@ -152,9 +162,7 @@ static unsigned switch_get_path_nr(struct switch_ctx *sctx, sector_t offset)
152162
else
153163
sector_div(p, sctx->region_size);
154164

155-
switch_get_position(sctx, p, &region_index, &bit);
156-
path_nr = (ACCESS_ONCE(sctx->region_table[region_index]) >> bit) &
157-
((1 << sctx->region_table_entry_bits) - 1);
165+
path_nr = switch_region_table_read(sctx, p);
158166

159167
/* This can only happen if the processor uses non-atomic stores. */
160168
if (unlikely(path_nr >= sctx->nr_paths))

0 commit comments

Comments
 (0)