Commit 3fd880af authored by JackieLiu's avatar JackieLiu Committed by Shaohua Li

raid5-cache: restrict the use area of the log_offset variable

We can calculate this offset by using ctx->meta_total_blocks,
without passing in from the function
Signed-off-by: default avatarJackieLiu <liuyun01@kylinos.cn>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent cc6167b4
...@@ -895,7 +895,7 @@ static int r5l_read_meta_block(struct r5l_log *log, ...@@ -895,7 +895,7 @@ static int r5l_read_meta_block(struct r5l_log *log,
static int r5l_recovery_flush_one_stripe(struct r5l_log *log, static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
struct r5l_recovery_ctx *ctx, struct r5l_recovery_ctx *ctx,
sector_t stripe_sect, sector_t stripe_sect,
int *offset, sector_t *log_offset) int *offset)
{ {
struct r5conf *conf = log->rdev->mddev->private; struct r5conf *conf = log->rdev->mddev->private;
struct stripe_head *sh; struct stripe_head *sh;
...@@ -904,6 +904,8 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log, ...@@ -904,6 +904,8 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
sh = raid5_get_active_stripe(conf, stripe_sect, 0, 0, 0); sh = raid5_get_active_stripe(conf, stripe_sect, 0, 0, 0);
while (1) { while (1) {
sector_t log_offset = r5l_ring_add(log, ctx->pos,
ctx->meta_total_blocks);
payload = page_address(ctx->meta_page) + *offset; payload = page_address(ctx->meta_page) + *offset;
if (le16_to_cpu(payload->header.type) == R5LOG_PAYLOAD_DATA) { if (le16_to_cpu(payload->header.type) == R5LOG_PAYLOAD_DATA) {
...@@ -911,16 +913,15 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log, ...@@ -911,16 +913,15 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
le64_to_cpu(payload->location), 0, le64_to_cpu(payload->location), 0,
&disk_index, sh); &disk_index, sh);
sync_page_io(log->rdev, *log_offset, PAGE_SIZE, sync_page_io(log->rdev, log_offset, PAGE_SIZE,
sh->dev[disk_index].page, REQ_OP_READ, 0, sh->dev[disk_index].page, REQ_OP_READ, 0,
false); false);
sh->dev[disk_index].log_checksum = sh->dev[disk_index].log_checksum =
le32_to_cpu(payload->checksum[0]); le32_to_cpu(payload->checksum[0]);
set_bit(R5_Wantwrite, &sh->dev[disk_index].flags); set_bit(R5_Wantwrite, &sh->dev[disk_index].flags);
ctx->meta_total_blocks += BLOCK_SECTORS;
} else { } else {
disk_index = sh->pd_idx; disk_index = sh->pd_idx;
sync_page_io(log->rdev, *log_offset, PAGE_SIZE, sync_page_io(log->rdev, log_offset, PAGE_SIZE,
sh->dev[disk_index].page, REQ_OP_READ, 0, sh->dev[disk_index].page, REQ_OP_READ, 0,
false); false);
sh->dev[disk_index].log_checksum = sh->dev[disk_index].log_checksum =
...@@ -930,7 +931,7 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log, ...@@ -930,7 +931,7 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
if (sh->qd_idx >= 0) { if (sh->qd_idx >= 0) {
disk_index = sh->qd_idx; disk_index = sh->qd_idx;
sync_page_io(log->rdev, sync_page_io(log->rdev,
r5l_ring_add(log, *log_offset, BLOCK_SECTORS), r5l_ring_add(log, log_offset, BLOCK_SECTORS),
PAGE_SIZE, sh->dev[disk_index].page, PAGE_SIZE, sh->dev[disk_index].page,
REQ_OP_READ, 0, false); REQ_OP_READ, 0, false);
sh->dev[disk_index].log_checksum = sh->dev[disk_index].log_checksum =
...@@ -938,11 +939,9 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log, ...@@ -938,11 +939,9 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
set_bit(R5_Wantwrite, set_bit(R5_Wantwrite,
&sh->dev[disk_index].flags); &sh->dev[disk_index].flags);
} }
ctx->meta_total_blocks += BLOCK_SECTORS * conf->max_degraded;
} }
*log_offset = r5l_ring_add(log, *log_offset, ctx->meta_total_blocks += le32_to_cpu(payload->size);
le32_to_cpu(payload->size));
*offset += sizeof(struct r5l_payload_data_parity) + *offset += sizeof(struct r5l_payload_data_parity) +
sizeof(__le32) * sizeof(__le32) *
(le32_to_cpu(payload->size) >> (PAGE_SHIFT - 9)); (le32_to_cpu(payload->size) >> (PAGE_SHIFT - 9));
...@@ -999,12 +998,10 @@ static int r5l_recovery_flush_one_meta(struct r5l_log *log, ...@@ -999,12 +998,10 @@ static int r5l_recovery_flush_one_meta(struct r5l_log *log,
struct r5l_payload_data_parity *payload; struct r5l_payload_data_parity *payload;
struct r5l_meta_block *mb; struct r5l_meta_block *mb;
int offset; int offset;
sector_t log_offset;
sector_t stripe_sector; sector_t stripe_sector;
mb = page_address(ctx->meta_page); mb = page_address(ctx->meta_page);
offset = sizeof(struct r5l_meta_block); offset = sizeof(struct r5l_meta_block);
log_offset = r5l_ring_add(log, ctx->pos, BLOCK_SECTORS);
while (offset < le32_to_cpu(mb->meta_size)) { while (offset < le32_to_cpu(mb->meta_size)) {
int dd; int dd;
...@@ -1013,7 +1010,7 @@ static int r5l_recovery_flush_one_meta(struct r5l_log *log, ...@@ -1013,7 +1010,7 @@ static int r5l_recovery_flush_one_meta(struct r5l_log *log,
stripe_sector = raid5_compute_sector(conf, stripe_sector = raid5_compute_sector(conf,
le64_to_cpu(payload->location), 0, &dd, NULL); le64_to_cpu(payload->location), 0, &dd, NULL);
if (r5l_recovery_flush_one_stripe(log, ctx, stripe_sector, if (r5l_recovery_flush_one_stripe(log, ctx, stripe_sector,
&offset, &log_offset)) &offset))
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment