diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-05-22 12:39:02 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-22 21:02:08 -0400 |
commit | 8b94025c00f9171b41ba9c1696943f5c935b62ef (patch) | |
tree | 97f770d1f1aa6d57c1a070514d4f933ffc4d467c /fs/nilfs2/recovery.c | |
parent | 92c60ccaf3c15a06d859682b980de1066641b4d0 (diff) |
nilfs2: refactor recovery logic routines
Most functions in recovery code take an argument of a super block
instance or a nilfs_sb_info struct for convenience sake.
This replaces them aggressively with a nilfs object by applying
__bread and __breadahead against routines using sb_bread and
sb_breadahead.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/recovery.c')
-rw-r--r-- | fs/nilfs2/recovery.c | 160 |
1 files changed, 94 insertions, 66 deletions
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c index bae2a516b4ee..1c883b1074eb 100644 --- a/fs/nilfs2/recovery.c +++ b/fs/nilfs2/recovery.c | |||
@@ -110,8 +110,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi, | |||
110 | } | 110 | } |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * calc_crc_cont - check CRC of blocks continuously | 113 | * nilfs_compute_checksum - compute checksum of blocks continuously |
114 | * @sbi: nilfs_sb_info | 114 | * @nilfs: nilfs object |
115 | * @bhs: buffer head of start block | 115 | * @bhs: buffer head of start block |
116 | * @sum: place to store result | 116 | * @sum: place to store result |
117 | * @offset: offset bytes in the first block | 117 | * @offset: offset bytes in the first block |
@@ -119,23 +119,25 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi, | |||
119 | * @start: DBN of start block | 119 | * @start: DBN of start block |
120 | * @nblock: number of blocks to be checked | 120 | * @nblock: number of blocks to be checked |
121 | */ | 121 | */ |
122 | static int calc_crc_cont(struct nilfs_sb_info *sbi, struct buffer_head *bhs, | 122 | static int nilfs_compute_checksum(struct the_nilfs *nilfs, |
123 | u32 *sum, unsigned long offset, u64 check_bytes, | 123 | struct buffer_head *bhs, u32 *sum, |
124 | sector_t start, unsigned long nblock) | 124 | unsigned long offset, u64 check_bytes, |
125 | sector_t start, unsigned long nblock) | ||
125 | { | 126 | { |
126 | unsigned long blocksize = sbi->s_super->s_blocksize; | 127 | unsigned int blocksize = nilfs->ns_blocksize; |
127 | unsigned long size; | 128 | unsigned long size; |
128 | u32 crc; | 129 | u32 crc; |
129 | 130 | ||
130 | BUG_ON(offset >= blocksize); | 131 | BUG_ON(offset >= blocksize); |
131 | check_bytes -= offset; | 132 | check_bytes -= offset; |
132 | size = min_t(u64, check_bytes, blocksize - offset); | 133 | size = min_t(u64, check_bytes, blocksize - offset); |
133 | crc = crc32_le(sbi->s_nilfs->ns_crc_seed, | 134 | crc = crc32_le(nilfs->ns_crc_seed, |
134 | (unsigned char *)bhs->b_data + offset, size); | 135 | (unsigned char *)bhs->b_data + offset, size); |
135 | if (--nblock > 0) { | 136 | if (--nblock > 0) { |
136 | do { | 137 | do { |
137 | struct buffer_head *bh | 138 | struct buffer_head *bh; |
138 | = sb_bread(sbi->s_super, ++start); | 139 | |
140 | bh = __bread(nilfs->ns_bdev, ++start, blocksize); | ||
139 | if (!bh) | 141 | if (!bh) |
140 | return -EIO; | 142 | return -EIO; |
141 | check_bytes -= size; | 143 | check_bytes -= size; |
@@ -150,12 +152,12 @@ static int calc_crc_cont(struct nilfs_sb_info *sbi, struct buffer_head *bhs, | |||
150 | 152 | ||
151 | /** | 153 | /** |
152 | * nilfs_read_super_root_block - read super root block | 154 | * nilfs_read_super_root_block - read super root block |
153 | * @sb: super_block | 155 | * @nilfs: nilfs object |
154 | * @sr_block: disk block number of the super root block | 156 | * @sr_block: disk block number of the super root block |
155 | * @pbh: address of a buffer_head pointer to return super root buffer | 157 | * @pbh: address of a buffer_head pointer to return super root buffer |
156 | * @check: CRC check flag | 158 | * @check: CRC check flag |
157 | */ | 159 | */ |
158 | int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block, | 160 | int nilfs_read_super_root_block(struct the_nilfs *nilfs, sector_t sr_block, |
159 | struct buffer_head **pbh, int check) | 161 | struct buffer_head **pbh, int check) |
160 | { | 162 | { |
161 | struct buffer_head *bh_sr; | 163 | struct buffer_head *bh_sr; |
@@ -164,7 +166,7 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block, | |||
164 | int ret; | 166 | int ret; |
165 | 167 | ||
166 | *pbh = NULL; | 168 | *pbh = NULL; |
167 | bh_sr = sb_bread(sb, sr_block); | 169 | bh_sr = __bread(nilfs->ns_bdev, sr_block, nilfs->ns_blocksize); |
168 | if (unlikely(!bh_sr)) { | 170 | if (unlikely(!bh_sr)) { |
169 | ret = NILFS_SEG_FAIL_IO; | 171 | ret = NILFS_SEG_FAIL_IO; |
170 | goto failed; | 172 | goto failed; |
@@ -174,12 +176,13 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block, | |||
174 | if (check) { | 176 | if (check) { |
175 | unsigned bytes = le16_to_cpu(sr->sr_bytes); | 177 | unsigned bytes = le16_to_cpu(sr->sr_bytes); |
176 | 178 | ||
177 | if (bytes == 0 || bytes > sb->s_blocksize) { | 179 | if (bytes == 0 || bytes > nilfs->ns_blocksize) { |
178 | ret = NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT; | 180 | ret = NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT; |
179 | goto failed_bh; | 181 | goto failed_bh; |
180 | } | 182 | } |
181 | if (calc_crc_cont(NILFS_SB(sb), bh_sr, &crc, | 183 | if (nilfs_compute_checksum( |
182 | sizeof(sr->sr_sum), bytes, sr_block, 1)) { | 184 | nilfs, bh_sr, &crc, sizeof(sr->sr_sum), bytes, |
185 | sr_block, 1)) { | ||
183 | ret = NILFS_SEG_FAIL_IO; | 186 | ret = NILFS_SEG_FAIL_IO; |
184 | goto failed_bh; | 187 | goto failed_bh; |
185 | } | 188 | } |
@@ -200,13 +203,13 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block, | |||
200 | 203 | ||
201 | /** | 204 | /** |
202 | * load_segment_summary - read segment summary of the specified partial segment | 205 | * load_segment_summary - read segment summary of the specified partial segment |
203 | * @sbi: nilfs_sb_info | 206 | * @nilfs: nilfs object |
204 | * @pseg_start: start disk block number of partial segment | 207 | * @pseg_start: start disk block number of partial segment |
205 | * @seg_seq: sequence number requested | 208 | * @seg_seq: sequence number requested |
206 | * @ssi: pointer to nilfs_segsum_info struct to store information | 209 | * @ssi: pointer to nilfs_segsum_info struct to store information |
207 | */ | 210 | */ |
208 | static int | 211 | static int |
209 | load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start, | 212 | load_segment_summary(struct the_nilfs *nilfs, sector_t pseg_start, |
210 | u64 seg_seq, struct nilfs_segsum_info *ssi) | 213 | u64 seg_seq, struct nilfs_segsum_info *ssi) |
211 | { | 214 | { |
212 | struct buffer_head *bh_sum; | 215 | struct buffer_head *bh_sum; |
@@ -215,7 +218,7 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start, | |||
215 | u32 crc; | 218 | u32 crc; |
216 | int ret = NILFS_SEG_FAIL_IO; | 219 | int ret = NILFS_SEG_FAIL_IO; |
217 | 220 | ||
218 | bh_sum = sb_bread(sbi->s_super, pseg_start); | 221 | bh_sum = __bread(nilfs->ns_bdev, pseg_start, nilfs->ns_blocksize); |
219 | if (!bh_sum) | 222 | if (!bh_sum) |
220 | goto out; | 223 | goto out; |
221 | 224 | ||
@@ -226,22 +229,21 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start, | |||
226 | ret = NILFS_SEG_FAIL_MAGIC; | 229 | ret = NILFS_SEG_FAIL_MAGIC; |
227 | goto failed; | 230 | goto failed; |
228 | } | 231 | } |
229 | store_segsum_info(ssi, sum, sbi->s_super->s_blocksize); | 232 | store_segsum_info(ssi, sum, nilfs->ns_blocksize); |
230 | if (seg_seq != ssi->seg_seq) { | 233 | if (seg_seq != ssi->seg_seq) { |
231 | ret = NILFS_SEG_FAIL_SEQ; | 234 | ret = NILFS_SEG_FAIL_SEQ; |
232 | goto failed; | 235 | goto failed; |
233 | } | 236 | } |
234 | 237 | ||
235 | nblock = ssi->nblocks; | 238 | nblock = ssi->nblocks; |
236 | if (unlikely(nblock == 0 || | 239 | if (unlikely(nblock == 0 || nblock > nilfs->ns_blocks_per_segment)) { |
237 | nblock > sbi->s_nilfs->ns_blocks_per_segment)) { | ||
238 | /* This limits the number of blocks read in the CRC check */ | 240 | /* This limits the number of blocks read in the CRC check */ |
239 | ret = NILFS_SEG_FAIL_CONSISTENCY; | 241 | ret = NILFS_SEG_FAIL_CONSISTENCY; |
240 | goto failed; | 242 | goto failed; |
241 | } | 243 | } |
242 | if (calc_crc_cont(sbi, bh_sum, &crc, sizeof(sum->ss_datasum), | 244 | if (nilfs_compute_checksum(nilfs, bh_sum, &crc, sizeof(sum->ss_datasum), |
243 | ((u64)nblock << sbi->s_super->s_blocksize_bits), | 245 | ((u64)nblock << nilfs->ns_blocksize_bits), |
244 | pseg_start, nblock)) { | 246 | pseg_start, nblock)) { |
245 | ret = NILFS_SEG_FAIL_IO; | 247 | ret = NILFS_SEG_FAIL_IO; |
246 | goto failed; | 248 | goto failed; |
247 | } | 249 | } |
@@ -255,8 +257,16 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start, | |||
255 | return ret; | 257 | return ret; |
256 | } | 258 | } |
257 | 259 | ||
258 | static void *segsum_get(struct super_block *sb, struct buffer_head **pbh, | 260 | /** |
259 | unsigned int *offset, unsigned int bytes) | 261 | * nilfs_read_summary_info - read an item on summary blocks of a log |
262 | * @nilfs: nilfs object | ||
263 | * @pbh: the current buffer head on summary blocks [in, out] | ||
264 | * @offset: the current byte offset on summary blocks [in, out] | ||
265 | * @bytes: byte size of the item to be read | ||
266 | */ | ||
267 | static void *nilfs_read_summary_info(struct the_nilfs *nilfs, | ||
268 | struct buffer_head **pbh, | ||
269 | unsigned int *offset, unsigned int bytes) | ||
260 | { | 270 | { |
261 | void *ptr; | 271 | void *ptr; |
262 | sector_t blocknr; | 272 | sector_t blocknr; |
@@ -265,7 +275,8 @@ static void *segsum_get(struct super_block *sb, struct buffer_head **pbh, | |||
265 | if (bytes > (*pbh)->b_size - *offset) { | 275 | if (bytes > (*pbh)->b_size - *offset) { |
266 | blocknr = (*pbh)->b_blocknr; | 276 | blocknr = (*pbh)->b_blocknr; |
267 | brelse(*pbh); | 277 | brelse(*pbh); |
268 | *pbh = sb_bread(sb, blocknr + 1); | 278 | *pbh = __bread(nilfs->ns_bdev, blocknr + 1, |
279 | nilfs->ns_blocksize); | ||
269 | if (unlikely(!*pbh)) | 280 | if (unlikely(!*pbh)) |
270 | return NULL; | 281 | return NULL; |
271 | *offset = 0; | 282 | *offset = 0; |
@@ -275,9 +286,18 @@ static void *segsum_get(struct super_block *sb, struct buffer_head **pbh, | |||
275 | return ptr; | 286 | return ptr; |
276 | } | 287 | } |
277 | 288 | ||
278 | static void segsum_skip(struct super_block *sb, struct buffer_head **pbh, | 289 | /** |
279 | unsigned int *offset, unsigned int bytes, | 290 | * nilfs_skip_summary_info - skip items on summary blocks of a log |
280 | unsigned long count) | 291 | * @nilfs: nilfs object |
292 | * @pbh: the current buffer head on summary blocks [in, out] | ||
293 | * @offset: the current byte offset on summary blocks [in, out] | ||
294 | * @bytes: byte size of the item to be skipped | ||
295 | * @count: number of items to be skipped | ||
296 | */ | ||
297 | static void nilfs_skip_summary_info(struct the_nilfs *nilfs, | ||
298 | struct buffer_head **pbh, | ||
299 | unsigned int *offset, unsigned int bytes, | ||
300 | unsigned long count) | ||
281 | { | 301 | { |
282 | unsigned int rest_item_in_current_block | 302 | unsigned int rest_item_in_current_block |
283 | = ((*pbh)->b_size - *offset) / bytes; | 303 | = ((*pbh)->b_size - *offset) / bytes; |
@@ -294,26 +314,33 @@ static void segsum_skip(struct super_block *sb, struct buffer_head **pbh, | |||
294 | *offset = bytes * (count - (bcnt - 1) * nitem_per_block); | 314 | *offset = bytes * (count - (bcnt - 1) * nitem_per_block); |
295 | 315 | ||
296 | brelse(*pbh); | 316 | brelse(*pbh); |
297 | *pbh = sb_bread(sb, blocknr + bcnt); | 317 | *pbh = __bread(nilfs->ns_bdev, blocknr + bcnt, |
318 | nilfs->ns_blocksize); | ||
298 | } | 319 | } |
299 | } | 320 | } |
300 | 321 | ||
301 | static int | 322 | /** |
302 | collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr, | 323 | * nilfs_scan_dsync_log - get block information of a log written for data sync |
303 | struct nilfs_segsum_info *ssi, | 324 | * @nilfs: nilfs object |
304 | struct list_head *head) | 325 | * @start_blocknr: start block number of the log |
326 | * @ssi: log summary information | ||
327 | * @head: list head to add nilfs_recovery_block struct | ||
328 | */ | ||
329 | static int nilfs_scan_dsync_log(struct the_nilfs *nilfs, sector_t start_blocknr, | ||
330 | struct nilfs_segsum_info *ssi, | ||
331 | struct list_head *head) | ||
305 | { | 332 | { |
306 | struct buffer_head *bh; | 333 | struct buffer_head *bh; |
307 | unsigned int offset; | 334 | unsigned int offset; |
308 | unsigned long nfinfo = ssi->nfinfo; | 335 | unsigned long nfinfo = ssi->nfinfo; |
309 | sector_t blocknr = sum_blocknr + ssi->nsumblk; | 336 | sector_t blocknr = start_blocknr + ssi->nsumblk; |
310 | ino_t ino; | 337 | ino_t ino; |
311 | int err = -EIO; | 338 | int err = -EIO; |
312 | 339 | ||
313 | if (!nfinfo) | 340 | if (!nfinfo) |
314 | return 0; | 341 | return 0; |
315 | 342 | ||
316 | bh = sb_bread(sbi->s_super, sum_blocknr); | 343 | bh = __bread(nilfs->ns_bdev, start_blocknr, nilfs->ns_blocksize); |
317 | if (unlikely(!bh)) | 344 | if (unlikely(!bh)) |
318 | goto out; | 345 | goto out; |
319 | 346 | ||
@@ -323,7 +350,8 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr, | |||
323 | unsigned long nblocks, ndatablk, nnodeblk; | 350 | unsigned long nblocks, ndatablk, nnodeblk; |
324 | struct nilfs_finfo *finfo; | 351 | struct nilfs_finfo *finfo; |
325 | 352 | ||
326 | finfo = segsum_get(sbi->s_super, &bh, &offset, sizeof(*finfo)); | 353 | finfo = nilfs_read_summary_info(nilfs, &bh, &offset, |
354 | sizeof(*finfo)); | ||
327 | if (unlikely(!finfo)) | 355 | if (unlikely(!finfo)) |
328 | goto out; | 356 | goto out; |
329 | 357 | ||
@@ -336,8 +364,8 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr, | |||
336 | struct nilfs_recovery_block *rb; | 364 | struct nilfs_recovery_block *rb; |
337 | struct nilfs_binfo_v *binfo; | 365 | struct nilfs_binfo_v *binfo; |
338 | 366 | ||
339 | binfo = segsum_get(sbi->s_super, &bh, &offset, | 367 | binfo = nilfs_read_summary_info(nilfs, &bh, &offset, |
340 | sizeof(*binfo)); | 368 | sizeof(*binfo)); |
341 | if (unlikely(!binfo)) | 369 | if (unlikely(!binfo)) |
342 | goto out; | 370 | goto out; |
343 | 371 | ||
@@ -355,9 +383,9 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr, | |||
355 | } | 383 | } |
356 | if (--nfinfo == 0) | 384 | if (--nfinfo == 0) |
357 | break; | 385 | break; |
358 | blocknr += nnodeblk; /* always 0 for the data sync segments */ | 386 | blocknr += nnodeblk; /* always 0 for data sync logs */ |
359 | segsum_skip(sbi->s_super, &bh, &offset, sizeof(__le64), | 387 | nilfs_skip_summary_info(nilfs, &bh, &offset, sizeof(__le64), |
360 | nnodeblk); | 388 | nnodeblk); |
361 | if (unlikely(!bh)) | 389 | if (unlikely(!bh)) |
362 | goto out; | 390 | goto out; |
363 | } | 391 | } |
@@ -467,14 +495,14 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, | |||
467 | return err; | 495 | return err; |
468 | } | 496 | } |
469 | 497 | ||
470 | static int nilfs_recovery_copy_block(struct nilfs_sb_info *sbi, | 498 | static int nilfs_recovery_copy_block(struct the_nilfs *nilfs, |
471 | struct nilfs_recovery_block *rb, | 499 | struct nilfs_recovery_block *rb, |
472 | struct page *page) | 500 | struct page *page) |
473 | { | 501 | { |
474 | struct buffer_head *bh_org; | 502 | struct buffer_head *bh_org; |
475 | void *kaddr; | 503 | void *kaddr; |
476 | 504 | ||
477 | bh_org = sb_bread(sbi->s_super, rb->blocknr); | 505 | bh_org = __bread(nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize); |
478 | if (unlikely(!bh_org)) | 506 | if (unlikely(!bh_org)) |
479 | return -EIO; | 507 | return -EIO; |
480 | 508 | ||
@@ -485,13 +513,14 @@ static int nilfs_recovery_copy_block(struct nilfs_sb_info *sbi, | |||
485 | return 0; | 513 | return 0; |
486 | } | 514 | } |
487 | 515 | ||
488 | static int recover_dsync_blocks(struct nilfs_sb_info *sbi, | 516 | static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, |
489 | struct list_head *head, | 517 | struct nilfs_sb_info *sbi, |
490 | unsigned long *nr_salvaged_blocks) | 518 | struct list_head *head, |
519 | unsigned long *nr_salvaged_blocks) | ||
491 | { | 520 | { |
492 | struct inode *inode; | 521 | struct inode *inode; |
493 | struct nilfs_recovery_block *rb, *n; | 522 | struct nilfs_recovery_block *rb, *n; |
494 | unsigned blocksize = sbi->s_super->s_blocksize; | 523 | unsigned blocksize = nilfs->ns_blocksize; |
495 | struct page *page; | 524 | struct page *page; |
496 | loff_t pos; | 525 | loff_t pos; |
497 | int err = 0, err2 = 0; | 526 | int err = 0, err2 = 0; |
@@ -511,7 +540,7 @@ static int recover_dsync_blocks(struct nilfs_sb_info *sbi, | |||
511 | if (unlikely(err)) | 540 | if (unlikely(err)) |
512 | goto failed_inode; | 541 | goto failed_inode; |
513 | 542 | ||
514 | err = nilfs_recovery_copy_block(sbi, rb, page); | 543 | err = nilfs_recovery_copy_block(nilfs, rb, page); |
515 | if (unlikely(err)) | 544 | if (unlikely(err)) |
516 | goto failed_page; | 545 | goto failed_page; |
517 | 546 | ||
@@ -551,8 +580,8 @@ static int recover_dsync_blocks(struct nilfs_sb_info *sbi, | |||
551 | /** | 580 | /** |
552 | * nilfs_do_roll_forward - salvage logical segments newer than the latest | 581 | * nilfs_do_roll_forward - salvage logical segments newer than the latest |
553 | * checkpoint | 582 | * checkpoint |
583 | * @nilfs: nilfs object | ||
554 | * @sbi: nilfs_sb_info | 584 | * @sbi: nilfs_sb_info |
555 | * @nilfs: the_nilfs | ||
556 | * @ri: pointer to a nilfs_recovery_info | 585 | * @ri: pointer to a nilfs_recovery_info |
557 | */ | 586 | */ |
558 | static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | 587 | static int nilfs_do_roll_forward(struct the_nilfs *nilfs, |
@@ -582,7 +611,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
582 | 611 | ||
583 | while (segnum != ri->ri_segnum || pseg_start <= ri->ri_pseg_start) { | 612 | while (segnum != ri->ri_segnum || pseg_start <= ri->ri_pseg_start) { |
584 | 613 | ||
585 | ret = load_segment_summary(sbi, pseg_start, seg_seq, &ssi); | 614 | ret = load_segment_summary(nilfs, pseg_start, seg_seq, &ssi); |
586 | if (ret) { | 615 | if (ret) { |
587 | if (ret == NILFS_SEG_FAIL_IO) { | 616 | if (ret == NILFS_SEG_FAIL_IO) { |
588 | err = -EIO; | 617 | err = -EIO; |
@@ -610,13 +639,14 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
610 | if (!NILFS_SEG_DSYNC(&ssi)) | 639 | if (!NILFS_SEG_DSYNC(&ssi)) |
611 | goto confused; | 640 | goto confused; |
612 | 641 | ||
613 | err = collect_blocks_from_segsum( | 642 | err = nilfs_scan_dsync_log(nilfs, pseg_start, &ssi, |
614 | sbi, pseg_start, &ssi, &dsync_blocks); | 643 | &dsync_blocks); |
615 | if (unlikely(err)) | 644 | if (unlikely(err)) |
616 | goto failed; | 645 | goto failed; |
617 | if (NILFS_SEG_LOGEND(&ssi)) { | 646 | if (NILFS_SEG_LOGEND(&ssi)) { |
618 | err = recover_dsync_blocks( | 647 | err = nilfs_recover_dsync_blocks( |
619 | sbi, &dsync_blocks, &nsalvaged_blocks); | 648 | nilfs, sbi, &dsync_blocks, |
649 | &nsalvaged_blocks); | ||
620 | if (unlikely(err)) | 650 | if (unlikely(err)) |
621 | goto failed; | 651 | goto failed; |
622 | state = RF_INIT_ST; | 652 | state = RF_INIT_ST; |
@@ -653,7 +683,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
653 | } | 683 | } |
654 | out: | 684 | out: |
655 | dispose_recovery_list(&dsync_blocks); | 685 | dispose_recovery_list(&dsync_blocks); |
656 | nilfs_detach_writer(sbi->s_nilfs, sbi); | 686 | nilfs_detach_writer(nilfs, sbi); |
657 | return err; | 687 | return err; |
658 | 688 | ||
659 | confused: | 689 | confused: |
@@ -667,7 +697,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs, | |||
667 | } | 697 | } |
668 | 698 | ||
669 | static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, | 699 | static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, |
670 | struct nilfs_sb_info *sbi, | ||
671 | struct nilfs_recovery_info *ri) | 700 | struct nilfs_recovery_info *ri) |
672 | { | 701 | { |
673 | struct buffer_head *bh; | 702 | struct buffer_head *bh; |
@@ -677,7 +706,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs, | |||
677 | nilfs_get_segnum_of_block(nilfs, ri->ri_super_root)) | 706 | nilfs_get_segnum_of_block(nilfs, ri->ri_super_root)) |
678 | return; | 707 | return; |
679 | 708 | ||
680 | bh = sb_getblk(sbi->s_super, ri->ri_lsegs_start); | 709 | bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize); |
681 | BUG_ON(!bh); | 710 | BUG_ON(!bh); |
682 | memset(bh->b_data, 0, bh->b_size); | 711 | memset(bh->b_data, 0, bh->b_size); |
683 | set_buffer_dirty(bh); | 712 | set_buffer_dirty(bh); |
@@ -751,7 +780,7 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs, | |||
751 | goto failed; | 780 | goto failed; |
752 | } | 781 | } |
753 | 782 | ||
754 | nilfs_finish_roll_forward(nilfs, sbi, ri); | 783 | nilfs_finish_roll_forward(nilfs, ri); |
755 | } | 784 | } |
756 | 785 | ||
757 | failed: | 786 | failed: |
@@ -762,7 +791,6 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs, | |||
762 | /** | 791 | /** |
763 | * nilfs_search_super_root - search the latest valid super root | 792 | * nilfs_search_super_root - search the latest valid super root |
764 | * @nilfs: the_nilfs | 793 | * @nilfs: the_nilfs |
765 | * @sbi: nilfs_sb_info | ||
766 | * @ri: pointer to a nilfs_recovery_info struct to store search results. | 794 | * @ri: pointer to a nilfs_recovery_info struct to store search results. |
767 | * | 795 | * |
768 | * nilfs_search_super_root() looks for the latest super-root from a partial | 796 | * nilfs_search_super_root() looks for the latest super-root from a partial |
@@ -776,7 +804,7 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs, | |||
776 | * | 804 | * |
777 | * %-EIO - I/O error | 805 | * %-EIO - I/O error |
778 | */ | 806 | */ |
779 | int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, | 807 | int nilfs_search_super_root(struct the_nilfs *nilfs, |
780 | struct nilfs_recovery_info *ri) | 808 | struct nilfs_recovery_info *ri) |
781 | { | 809 | { |
782 | struct nilfs_segsum_info ssi; | 810 | struct nilfs_segsum_info ssi; |
@@ -801,11 +829,10 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, | |||
801 | /* Read ahead segment */ | 829 | /* Read ahead segment */ |
802 | b = seg_start; | 830 | b = seg_start; |
803 | while (b <= seg_end) | 831 | while (b <= seg_end) |
804 | sb_breadahead(sbi->s_super, b++); | 832 | __breadahead(nilfs->ns_bdev, b++, nilfs->ns_blocksize); |
805 | 833 | ||
806 | for (;;) { | 834 | for (;;) { |
807 | /* Load segment summary */ | 835 | ret = load_segment_summary(nilfs, pseg_start, seg_seq, &ssi); |
808 | ret = load_segment_summary(sbi, pseg_start, seg_seq, &ssi); | ||
809 | if (ret) { | 836 | if (ret) { |
810 | if (ret == NILFS_SEG_FAIL_IO) | 837 | if (ret == NILFS_SEG_FAIL_IO) |
811 | goto failed; | 838 | goto failed; |
@@ -836,7 +863,8 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, | |||
836 | if (pseg_start == seg_start) { | 863 | if (pseg_start == seg_start) { |
837 | nilfs_get_segment_range(nilfs, nextnum, &b, &end); | 864 | nilfs_get_segment_range(nilfs, nextnum, &b, &end); |
838 | while (b <= end) | 865 | while (b <= end) |
839 | sb_breadahead(sbi->s_super, b++); | 866 | __breadahead(nilfs->ns_bdev, b++, |
867 | nilfs->ns_blocksize); | ||
840 | } | 868 | } |
841 | if (!NILFS_SEG_HAS_SR(&ssi)) { | 869 | if (!NILFS_SEG_HAS_SR(&ssi)) { |
842 | if (!ri->ri_lsegs_start && NILFS_SEG_LOGBGN(&ssi)) { | 870 | if (!ri->ri_lsegs_start && NILFS_SEG_LOGBGN(&ssi)) { |