aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2014-09-08 21:57:29 -0400
committerDave Chinner <david@fromorbit.com>2014-09-08 21:57:29 -0400
commit970fd3f04d5949a4b5f6d0a5fea8e4b6797a5992 (patch)
treeb0b7669bc611d075e52b7ccbeced0181bd08e040
parent59f9c004320704179913fa7c57645017ccf1b5c3 (diff)
xfs: deduplicate xlog_do_recovery_pass()
In xlog_do_recovery_pass(), there are 2 distinct cases: non-wrapped and wrapped log recovery. If we find a wrapped log, we recover around the end of the log, and then handle the rest of recovery exactly as in the non-wrapped case - using exactly the same (duplicated) code. Rather than having the same code in both cases, we can get the wrapped portion out of the way first if needed, and then recover the non-wrapped portion of the log. There should be no functional change here, just code reorganization & deduplication. The patch looks a bit bigger than it really is; the last hunk is whitespace changes (un-indenting). Tested with xfstests "check -g log" on a stock configuration. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_log_recover.c81
1 files changed, 27 insertions, 54 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 176c4b3609ab..29e101fc32c5 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4132,41 +4132,13 @@ xlog_do_recovery_pass(
4132 } 4132 }
4133 4133
4134 memset(rhash, 0, sizeof(rhash)); 4134 memset(rhash, 0, sizeof(rhash));
4135 if (tail_blk <= head_blk) { 4135 blk_no = tail_blk;
4136 for (blk_no = tail_blk; blk_no < head_blk; ) { 4136 if (tail_blk > head_blk) {
4137 error = xlog_bread(log, blk_no, hblks, hbp, &offset);
4138 if (error)
4139 goto bread_err2;
4140
4141 rhead = (xlog_rec_header_t *)offset;
4142 error = xlog_valid_rec_header(log, rhead, blk_no);
4143 if (error)
4144 goto bread_err2;
4145
4146 /* blocks in data section */
4147 bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
4148 error = xlog_bread(log, blk_no + hblks, bblks, dbp,
4149 &offset);
4150 if (error)
4151 goto bread_err2;
4152
4153 error = xlog_unpack_data(rhead, offset, log);
4154 if (error)
4155 goto bread_err2;
4156
4157 error = xlog_recover_process_data(log,
4158 rhash, rhead, offset, pass);
4159 if (error)
4160 goto bread_err2;
4161 blk_no += bblks + hblks;
4162 }
4163 } else {
4164 /* 4137 /*
4165 * Perform recovery around the end of the physical log. 4138 * Perform recovery around the end of the physical log.
4166 * When the head is not on the same cycle number as the tail, 4139 * When the head is not on the same cycle number as the tail,
4167 * we can't do a sequential recovery as above. 4140 * we can't do a sequential recovery.
4168 */ 4141 */
4169 blk_no = tail_blk;
4170 while (blk_no < log->l_logBBsize) { 4142 while (blk_no < log->l_logBBsize) {
4171 /* 4143 /*
4172 * Check for header wrapping around physical end-of-log 4144 * Check for header wrapping around physical end-of-log
@@ -4280,34 +4252,35 @@ xlog_do_recovery_pass(
4280 4252
4281 ASSERT(blk_no >= log->l_logBBsize); 4253 ASSERT(blk_no >= log->l_logBBsize);
4282 blk_no -= log->l_logBBsize; 4254 blk_no -= log->l_logBBsize;
4255 }
4283 4256
4284 /* read first part of physical log */ 4257 /* read first part of physical log */
4285 while (blk_no < head_blk) { 4258 while (blk_no < head_blk) {
4286 error = xlog_bread(log, blk_no, hblks, hbp, &offset); 4259 error = xlog_bread(log, blk_no, hblks, hbp, &offset);
4287 if (error) 4260 if (error)
4288 goto bread_err2; 4261 goto bread_err2;
4289 4262
4290 rhead = (xlog_rec_header_t *)offset; 4263 rhead = (xlog_rec_header_t *)offset;
4291 error = xlog_valid_rec_header(log, rhead, blk_no); 4264 error = xlog_valid_rec_header(log, rhead, blk_no);
4292 if (error) 4265 if (error)
4293 goto bread_err2; 4266 goto bread_err2;
4294 4267
4295 bblks = (int)BTOBB(be32_to_cpu(rhead->h_len)); 4268 /* blocks in data section */
4296 error = xlog_bread(log, blk_no+hblks, bblks, dbp, 4269 bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
4297 &offset); 4270 error = xlog_bread(log, blk_no+hblks, bblks, dbp,
4298 if (error) 4271 &offset);
4299 goto bread_err2; 4272 if (error)
4273 goto bread_err2;
4300 4274
4301 error = xlog_unpack_data(rhead, offset, log); 4275 error = xlog_unpack_data(rhead, offset, log);
4302 if (error) 4276 if (error)
4303 goto bread_err2; 4277 goto bread_err2;
4304 4278
4305 error = xlog_recover_process_data(log, rhash, 4279 error = xlog_recover_process_data(log, rhash,
4306 rhead, offset, pass); 4280 rhead, offset, pass);
4307 if (error) 4281 if (error)
4308 goto bread_err2; 4282 goto bread_err2;
4309 blk_no += bblks + hblks; 4283 blk_no += bblks + hblks;
4310 }
4311 } 4284 }
4312 4285
4313 bread_err2: 4286 bread_err2: