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>
This commit is contained in:
parent
92c60ccaf3
commit
8b94025c00
3 changed files with 100 additions and 73 deletions
|
@ -110,8 +110,8 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calc_crc_cont - check CRC of blocks continuously
|
* nilfs_compute_checksum - compute checksum of blocks continuously
|
||||||
* @sbi: nilfs_sb_info
|
* @nilfs: nilfs object
|
||||||
* @bhs: buffer head of start block
|
* @bhs: buffer head of start block
|
||||||
* @sum: place to store result
|
* @sum: place to store result
|
||||||
* @offset: offset bytes in the first block
|
* @offset: offset bytes in the first block
|
||||||
|
@ -119,23 +119,25 @@ static void store_segsum_info(struct nilfs_segsum_info *ssi,
|
||||||
* @start: DBN of start block
|
* @start: DBN of start block
|
||||||
* @nblock: number of blocks to be checked
|
* @nblock: number of blocks to be checked
|
||||||
*/
|
*/
|
||||||
static int calc_crc_cont(struct nilfs_sb_info *sbi, struct buffer_head *bhs,
|
static int nilfs_compute_checksum(struct the_nilfs *nilfs,
|
||||||
u32 *sum, unsigned long offset, u64 check_bytes,
|
struct buffer_head *bhs, u32 *sum,
|
||||||
sector_t start, unsigned long nblock)
|
unsigned long offset, u64 check_bytes,
|
||||||
|
sector_t start, unsigned long nblock)
|
||||||
{
|
{
|
||||||
unsigned long blocksize = sbi->s_super->s_blocksize;
|
unsigned int blocksize = nilfs->ns_blocksize;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
u32 crc;
|
u32 crc;
|
||||||
|
|
||||||
BUG_ON(offset >= blocksize);
|
BUG_ON(offset >= blocksize);
|
||||||
check_bytes -= offset;
|
check_bytes -= offset;
|
||||||
size = min_t(u64, check_bytes, blocksize - offset);
|
size = min_t(u64, check_bytes, blocksize - offset);
|
||||||
crc = crc32_le(sbi->s_nilfs->ns_crc_seed,
|
crc = crc32_le(nilfs->ns_crc_seed,
|
||||||
(unsigned char *)bhs->b_data + offset, size);
|
(unsigned char *)bhs->b_data + offset, size);
|
||||||
if (--nblock > 0) {
|
if (--nblock > 0) {
|
||||||
do {
|
do {
|
||||||
struct buffer_head *bh
|
struct buffer_head *bh;
|
||||||
= sb_bread(sbi->s_super, ++start);
|
|
||||||
|
bh = __bread(nilfs->ns_bdev, ++start, blocksize);
|
||||||
if (!bh)
|
if (!bh)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
check_bytes -= size;
|
check_bytes -= size;
|
||||||
|
@ -150,12 +152,12 @@ static int calc_crc_cont(struct nilfs_sb_info *sbi, struct buffer_head *bhs,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nilfs_read_super_root_block - read super root block
|
* nilfs_read_super_root_block - read super root block
|
||||||
* @sb: super_block
|
* @nilfs: nilfs object
|
||||||
* @sr_block: disk block number of the super root block
|
* @sr_block: disk block number of the super root block
|
||||||
* @pbh: address of a buffer_head pointer to return super root buffer
|
* @pbh: address of a buffer_head pointer to return super root buffer
|
||||||
* @check: CRC check flag
|
* @check: CRC check flag
|
||||||
*/
|
*/
|
||||||
int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block,
|
int nilfs_read_super_root_block(struct the_nilfs *nilfs, sector_t sr_block,
|
||||||
struct buffer_head **pbh, int check)
|
struct buffer_head **pbh, int check)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh_sr;
|
struct buffer_head *bh_sr;
|
||||||
|
@ -164,7 +166,7 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
*pbh = NULL;
|
*pbh = NULL;
|
||||||
bh_sr = sb_bread(sb, sr_block);
|
bh_sr = __bread(nilfs->ns_bdev, sr_block, nilfs->ns_blocksize);
|
||||||
if (unlikely(!bh_sr)) {
|
if (unlikely(!bh_sr)) {
|
||||||
ret = NILFS_SEG_FAIL_IO;
|
ret = NILFS_SEG_FAIL_IO;
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -174,12 +176,13 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block,
|
||||||
if (check) {
|
if (check) {
|
||||||
unsigned bytes = le16_to_cpu(sr->sr_bytes);
|
unsigned bytes = le16_to_cpu(sr->sr_bytes);
|
||||||
|
|
||||||
if (bytes == 0 || bytes > sb->s_blocksize) {
|
if (bytes == 0 || bytes > nilfs->ns_blocksize) {
|
||||||
ret = NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT;
|
ret = NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT;
|
||||||
goto failed_bh;
|
goto failed_bh;
|
||||||
}
|
}
|
||||||
if (calc_crc_cont(NILFS_SB(sb), bh_sr, &crc,
|
if (nilfs_compute_checksum(
|
||||||
sizeof(sr->sr_sum), bytes, sr_block, 1)) {
|
nilfs, bh_sr, &crc, sizeof(sr->sr_sum), bytes,
|
||||||
|
sr_block, 1)) {
|
||||||
ret = NILFS_SEG_FAIL_IO;
|
ret = NILFS_SEG_FAIL_IO;
|
||||||
goto failed_bh;
|
goto failed_bh;
|
||||||
}
|
}
|
||||||
|
@ -200,13 +203,13 @@ int nilfs_read_super_root_block(struct super_block *sb, sector_t sr_block,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load_segment_summary - read segment summary of the specified partial segment
|
* load_segment_summary - read segment summary of the specified partial segment
|
||||||
* @sbi: nilfs_sb_info
|
* @nilfs: nilfs object
|
||||||
* @pseg_start: start disk block number of partial segment
|
* @pseg_start: start disk block number of partial segment
|
||||||
* @seg_seq: sequence number requested
|
* @seg_seq: sequence number requested
|
||||||
* @ssi: pointer to nilfs_segsum_info struct to store information
|
* @ssi: pointer to nilfs_segsum_info struct to store information
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start,
|
load_segment_summary(struct the_nilfs *nilfs, sector_t pseg_start,
|
||||||
u64 seg_seq, struct nilfs_segsum_info *ssi)
|
u64 seg_seq, struct nilfs_segsum_info *ssi)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh_sum;
|
struct buffer_head *bh_sum;
|
||||||
|
@ -215,7 +218,7 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start,
|
||||||
u32 crc;
|
u32 crc;
|
||||||
int ret = NILFS_SEG_FAIL_IO;
|
int ret = NILFS_SEG_FAIL_IO;
|
||||||
|
|
||||||
bh_sum = sb_bread(sbi->s_super, pseg_start);
|
bh_sum = __bread(nilfs->ns_bdev, pseg_start, nilfs->ns_blocksize);
|
||||||
if (!bh_sum)
|
if (!bh_sum)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -226,22 +229,21 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start,
|
||||||
ret = NILFS_SEG_FAIL_MAGIC;
|
ret = NILFS_SEG_FAIL_MAGIC;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
store_segsum_info(ssi, sum, sbi->s_super->s_blocksize);
|
store_segsum_info(ssi, sum, nilfs->ns_blocksize);
|
||||||
if (seg_seq != ssi->seg_seq) {
|
if (seg_seq != ssi->seg_seq) {
|
||||||
ret = NILFS_SEG_FAIL_SEQ;
|
ret = NILFS_SEG_FAIL_SEQ;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
nblock = ssi->nblocks;
|
nblock = ssi->nblocks;
|
||||||
if (unlikely(nblock == 0 ||
|
if (unlikely(nblock == 0 || nblock > nilfs->ns_blocks_per_segment)) {
|
||||||
nblock > sbi->s_nilfs->ns_blocks_per_segment)) {
|
|
||||||
/* This limits the number of blocks read in the CRC check */
|
/* This limits the number of blocks read in the CRC check */
|
||||||
ret = NILFS_SEG_FAIL_CONSISTENCY;
|
ret = NILFS_SEG_FAIL_CONSISTENCY;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
if (calc_crc_cont(sbi, bh_sum, &crc, sizeof(sum->ss_datasum),
|
if (nilfs_compute_checksum(nilfs, bh_sum, &crc, sizeof(sum->ss_datasum),
|
||||||
((u64)nblock << sbi->s_super->s_blocksize_bits),
|
((u64)nblock << nilfs->ns_blocksize_bits),
|
||||||
pseg_start, nblock)) {
|
pseg_start, nblock)) {
|
||||||
ret = NILFS_SEG_FAIL_IO;
|
ret = NILFS_SEG_FAIL_IO;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -255,8 +257,16 @@ load_segment_summary(struct nilfs_sb_info *sbi, sector_t pseg_start,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *segsum_get(struct super_block *sb, struct buffer_head **pbh,
|
/**
|
||||||
unsigned int *offset, unsigned int bytes)
|
* nilfs_read_summary_info - read an item on summary blocks of a log
|
||||||
|
* @nilfs: nilfs object
|
||||||
|
* @pbh: the current buffer head on summary blocks [in, out]
|
||||||
|
* @offset: the current byte offset on summary blocks [in, out]
|
||||||
|
* @bytes: byte size of the item to be read
|
||||||
|
*/
|
||||||
|
static void *nilfs_read_summary_info(struct the_nilfs *nilfs,
|
||||||
|
struct buffer_head **pbh,
|
||||||
|
unsigned int *offset, unsigned int bytes)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
sector_t blocknr;
|
sector_t blocknr;
|
||||||
|
@ -265,7 +275,8 @@ static void *segsum_get(struct super_block *sb, struct buffer_head **pbh,
|
||||||
if (bytes > (*pbh)->b_size - *offset) {
|
if (bytes > (*pbh)->b_size - *offset) {
|
||||||
blocknr = (*pbh)->b_blocknr;
|
blocknr = (*pbh)->b_blocknr;
|
||||||
brelse(*pbh);
|
brelse(*pbh);
|
||||||
*pbh = sb_bread(sb, blocknr + 1);
|
*pbh = __bread(nilfs->ns_bdev, blocknr + 1,
|
||||||
|
nilfs->ns_blocksize);
|
||||||
if (unlikely(!*pbh))
|
if (unlikely(!*pbh))
|
||||||
return NULL;
|
return NULL;
|
||||||
*offset = 0;
|
*offset = 0;
|
||||||
|
@ -275,9 +286,18 @@ static void *segsum_get(struct super_block *sb, struct buffer_head **pbh,
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void segsum_skip(struct super_block *sb, struct buffer_head **pbh,
|
/**
|
||||||
unsigned int *offset, unsigned int bytes,
|
* nilfs_skip_summary_info - skip items on summary blocks of a log
|
||||||
unsigned long count)
|
* @nilfs: nilfs object
|
||||||
|
* @pbh: the current buffer head on summary blocks [in, out]
|
||||||
|
* @offset: the current byte offset on summary blocks [in, out]
|
||||||
|
* @bytes: byte size of the item to be skipped
|
||||||
|
* @count: number of items to be skipped
|
||||||
|
*/
|
||||||
|
static void nilfs_skip_summary_info(struct the_nilfs *nilfs,
|
||||||
|
struct buffer_head **pbh,
|
||||||
|
unsigned int *offset, unsigned int bytes,
|
||||||
|
unsigned long count)
|
||||||
{
|
{
|
||||||
unsigned int rest_item_in_current_block
|
unsigned int rest_item_in_current_block
|
||||||
= ((*pbh)->b_size - *offset) / bytes;
|
= ((*pbh)->b_size - *offset) / bytes;
|
||||||
|
@ -294,26 +314,33 @@ static void segsum_skip(struct super_block *sb, struct buffer_head **pbh,
|
||||||
*offset = bytes * (count - (bcnt - 1) * nitem_per_block);
|
*offset = bytes * (count - (bcnt - 1) * nitem_per_block);
|
||||||
|
|
||||||
brelse(*pbh);
|
brelse(*pbh);
|
||||||
*pbh = sb_bread(sb, blocknr + bcnt);
|
*pbh = __bread(nilfs->ns_bdev, blocknr + bcnt,
|
||||||
|
nilfs->ns_blocksize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/**
|
||||||
collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr,
|
* nilfs_scan_dsync_log - get block information of a log written for data sync
|
||||||
struct nilfs_segsum_info *ssi,
|
* @nilfs: nilfs object
|
||||||
struct list_head *head)
|
* @start_blocknr: start block number of the log
|
||||||
|
* @ssi: log summary information
|
||||||
|
* @head: list head to add nilfs_recovery_block struct
|
||||||
|
*/
|
||||||
|
static int nilfs_scan_dsync_log(struct the_nilfs *nilfs, sector_t start_blocknr,
|
||||||
|
struct nilfs_segsum_info *ssi,
|
||||||
|
struct list_head *head)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned long nfinfo = ssi->nfinfo;
|
unsigned long nfinfo = ssi->nfinfo;
|
||||||
sector_t blocknr = sum_blocknr + ssi->nsumblk;
|
sector_t blocknr = start_blocknr + ssi->nsumblk;
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
int err = -EIO;
|
int err = -EIO;
|
||||||
|
|
||||||
if (!nfinfo)
|
if (!nfinfo)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bh = sb_bread(sbi->s_super, sum_blocknr);
|
bh = __bread(nilfs->ns_bdev, start_blocknr, nilfs->ns_blocksize);
|
||||||
if (unlikely(!bh))
|
if (unlikely(!bh))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -323,7 +350,8 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr,
|
||||||
unsigned long nblocks, ndatablk, nnodeblk;
|
unsigned long nblocks, ndatablk, nnodeblk;
|
||||||
struct nilfs_finfo *finfo;
|
struct nilfs_finfo *finfo;
|
||||||
|
|
||||||
finfo = segsum_get(sbi->s_super, &bh, &offset, sizeof(*finfo));
|
finfo = nilfs_read_summary_info(nilfs, &bh, &offset,
|
||||||
|
sizeof(*finfo));
|
||||||
if (unlikely(!finfo))
|
if (unlikely(!finfo))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -336,8 +364,8 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr,
|
||||||
struct nilfs_recovery_block *rb;
|
struct nilfs_recovery_block *rb;
|
||||||
struct nilfs_binfo_v *binfo;
|
struct nilfs_binfo_v *binfo;
|
||||||
|
|
||||||
binfo = segsum_get(sbi->s_super, &bh, &offset,
|
binfo = nilfs_read_summary_info(nilfs, &bh, &offset,
|
||||||
sizeof(*binfo));
|
sizeof(*binfo));
|
||||||
if (unlikely(!binfo))
|
if (unlikely(!binfo))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -355,9 +383,9 @@ collect_blocks_from_segsum(struct nilfs_sb_info *sbi, sector_t sum_blocknr,
|
||||||
}
|
}
|
||||||
if (--nfinfo == 0)
|
if (--nfinfo == 0)
|
||||||
break;
|
break;
|
||||||
blocknr += nnodeblk; /* always 0 for the data sync segments */
|
blocknr += nnodeblk; /* always 0 for data sync logs */
|
||||||
segsum_skip(sbi->s_super, &bh, &offset, sizeof(__le64),
|
nilfs_skip_summary_info(nilfs, &bh, &offset, sizeof(__le64),
|
||||||
nnodeblk);
|
nnodeblk);
|
||||||
if (unlikely(!bh))
|
if (unlikely(!bh))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -467,14 +495,14 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nilfs_recovery_copy_block(struct nilfs_sb_info *sbi,
|
static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
|
||||||
struct nilfs_recovery_block *rb,
|
struct nilfs_recovery_block *rb,
|
||||||
struct page *page)
|
struct page *page)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh_org;
|
struct buffer_head *bh_org;
|
||||||
void *kaddr;
|
void *kaddr;
|
||||||
|
|
||||||
bh_org = sb_bread(sbi->s_super, rb->blocknr);
|
bh_org = __bread(nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize);
|
||||||
if (unlikely(!bh_org))
|
if (unlikely(!bh_org))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
@ -485,13 +513,14 @@ static int nilfs_recovery_copy_block(struct nilfs_sb_info *sbi,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int recover_dsync_blocks(struct nilfs_sb_info *sbi,
|
static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
|
||||||
struct list_head *head,
|
struct nilfs_sb_info *sbi,
|
||||||
unsigned long *nr_salvaged_blocks)
|
struct list_head *head,
|
||||||
|
unsigned long *nr_salvaged_blocks)
|
||||||
{
|
{
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
struct nilfs_recovery_block *rb, *n;
|
struct nilfs_recovery_block *rb, *n;
|
||||||
unsigned blocksize = sbi->s_super->s_blocksize;
|
unsigned blocksize = nilfs->ns_blocksize;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
loff_t pos;
|
loff_t pos;
|
||||||
int err = 0, err2 = 0;
|
int err = 0, err2 = 0;
|
||||||
|
@ -511,7 +540,7 @@ static int recover_dsync_blocks(struct nilfs_sb_info *sbi,
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
goto failed_inode;
|
goto failed_inode;
|
||||||
|
|
||||||
err = nilfs_recovery_copy_block(sbi, rb, page);
|
err = nilfs_recovery_copy_block(nilfs, rb, page);
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
goto failed_page;
|
goto failed_page;
|
||||||
|
|
||||||
|
@ -551,8 +580,8 @@ static int recover_dsync_blocks(struct nilfs_sb_info *sbi,
|
||||||
/**
|
/**
|
||||||
* nilfs_do_roll_forward - salvage logical segments newer than the latest
|
* nilfs_do_roll_forward - salvage logical segments newer than the latest
|
||||||
* checkpoint
|
* checkpoint
|
||||||
|
* @nilfs: nilfs object
|
||||||
* @sbi: nilfs_sb_info
|
* @sbi: nilfs_sb_info
|
||||||
* @nilfs: the_nilfs
|
|
||||||
* @ri: pointer to a nilfs_recovery_info
|
* @ri: pointer to a nilfs_recovery_info
|
||||||
*/
|
*/
|
||||||
static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
||||||
|
@ -582,7 +611,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
||||||
|
|
||||||
while (segnum != ri->ri_segnum || pseg_start <= ri->ri_pseg_start) {
|
while (segnum != ri->ri_segnum || pseg_start <= ri->ri_pseg_start) {
|
||||||
|
|
||||||
ret = load_segment_summary(sbi, pseg_start, seg_seq, &ssi);
|
ret = load_segment_summary(nilfs, pseg_start, seg_seq, &ssi);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == NILFS_SEG_FAIL_IO) {
|
if (ret == NILFS_SEG_FAIL_IO) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
|
@ -610,13 +639,14 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
||||||
if (!NILFS_SEG_DSYNC(&ssi))
|
if (!NILFS_SEG_DSYNC(&ssi))
|
||||||
goto confused;
|
goto confused;
|
||||||
|
|
||||||
err = collect_blocks_from_segsum(
|
err = nilfs_scan_dsync_log(nilfs, pseg_start, &ssi,
|
||||||
sbi, pseg_start, &ssi, &dsync_blocks);
|
&dsync_blocks);
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
goto failed;
|
goto failed;
|
||||||
if (NILFS_SEG_LOGEND(&ssi)) {
|
if (NILFS_SEG_LOGEND(&ssi)) {
|
||||||
err = recover_dsync_blocks(
|
err = nilfs_recover_dsync_blocks(
|
||||||
sbi, &dsync_blocks, &nsalvaged_blocks);
|
nilfs, sbi, &dsync_blocks,
|
||||||
|
&nsalvaged_blocks);
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
goto failed;
|
goto failed;
|
||||||
state = RF_INIT_ST;
|
state = RF_INIT_ST;
|
||||||
|
@ -653,7 +683,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
dispose_recovery_list(&dsync_blocks);
|
dispose_recovery_list(&dsync_blocks);
|
||||||
nilfs_detach_writer(sbi->s_nilfs, sbi);
|
nilfs_detach_writer(nilfs, sbi);
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
confused:
|
confused:
|
||||||
|
@ -667,7 +697,6 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
|
static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
|
||||||
struct nilfs_sb_info *sbi,
|
|
||||||
struct nilfs_recovery_info *ri)
|
struct nilfs_recovery_info *ri)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
|
@ -677,7 +706,7 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
|
||||||
nilfs_get_segnum_of_block(nilfs, ri->ri_super_root))
|
nilfs_get_segnum_of_block(nilfs, ri->ri_super_root))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bh = sb_getblk(sbi->s_super, ri->ri_lsegs_start);
|
bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize);
|
||||||
BUG_ON(!bh);
|
BUG_ON(!bh);
|
||||||
memset(bh->b_data, 0, bh->b_size);
|
memset(bh->b_data, 0, bh->b_size);
|
||||||
set_buffer_dirty(bh);
|
set_buffer_dirty(bh);
|
||||||
|
@ -751,7 +780,7 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs,
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
nilfs_finish_roll_forward(nilfs, sbi, ri);
|
nilfs_finish_roll_forward(nilfs, ri);
|
||||||
}
|
}
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
@ -762,7 +791,6 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs,
|
||||||
/**
|
/**
|
||||||
* nilfs_search_super_root - search the latest valid super root
|
* nilfs_search_super_root - search the latest valid super root
|
||||||
* @nilfs: the_nilfs
|
* @nilfs: the_nilfs
|
||||||
* @sbi: nilfs_sb_info
|
|
||||||
* @ri: pointer to a nilfs_recovery_info struct to store search results.
|
* @ri: pointer to a nilfs_recovery_info struct to store search results.
|
||||||
*
|
*
|
||||||
* nilfs_search_super_root() looks for the latest super-root from a partial
|
* 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,
|
||||||
*
|
*
|
||||||
* %-EIO - I/O error
|
* %-EIO - I/O error
|
||||||
*/
|
*/
|
||||||
int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
|
int nilfs_search_super_root(struct the_nilfs *nilfs,
|
||||||
struct nilfs_recovery_info *ri)
|
struct nilfs_recovery_info *ri)
|
||||||
{
|
{
|
||||||
struct nilfs_segsum_info ssi;
|
struct nilfs_segsum_info ssi;
|
||||||
|
@ -801,11 +829,10 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
|
||||||
/* Read ahead segment */
|
/* Read ahead segment */
|
||||||
b = seg_start;
|
b = seg_start;
|
||||||
while (b <= seg_end)
|
while (b <= seg_end)
|
||||||
sb_breadahead(sbi->s_super, b++);
|
__breadahead(nilfs->ns_bdev, b++, nilfs->ns_blocksize);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* Load segment summary */
|
ret = load_segment_summary(nilfs, pseg_start, seg_seq, &ssi);
|
||||||
ret = load_segment_summary(sbi, pseg_start, seg_seq, &ssi);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == NILFS_SEG_FAIL_IO)
|
if (ret == NILFS_SEG_FAIL_IO)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -836,7 +863,8 @@ int nilfs_search_super_root(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi,
|
||||||
if (pseg_start == seg_start) {
|
if (pseg_start == seg_start) {
|
||||||
nilfs_get_segment_range(nilfs, nextnum, &b, &end);
|
nilfs_get_segment_range(nilfs, nextnum, &b, &end);
|
||||||
while (b <= end)
|
while (b <= end)
|
||||||
sb_breadahead(sbi->s_super, b++);
|
__breadahead(nilfs->ns_bdev, b++,
|
||||||
|
nilfs->ns_blocksize);
|
||||||
}
|
}
|
||||||
if (!NILFS_SEG_HAS_SR(&ssi)) {
|
if (!NILFS_SEG_HAS_SR(&ssi)) {
|
||||||
if (!ri->ri_lsegs_start && NILFS_SEG_LOGBGN(&ssi)) {
|
if (!ri->ri_lsegs_start && NILFS_SEG_LOGBGN(&ssi)) {
|
||||||
|
|
|
@ -234,9 +234,9 @@ extern int nilfs_attach_segment_constructor(struct nilfs_sb_info *);
|
||||||
extern void nilfs_detach_segment_constructor(struct nilfs_sb_info *);
|
extern void nilfs_detach_segment_constructor(struct nilfs_sb_info *);
|
||||||
|
|
||||||
/* recovery.c */
|
/* recovery.c */
|
||||||
extern int nilfs_read_super_root_block(struct super_block *, sector_t,
|
extern int nilfs_read_super_root_block(struct the_nilfs *, sector_t,
|
||||||
struct buffer_head **, int);
|
struct buffer_head **, int);
|
||||||
extern int nilfs_search_super_root(struct the_nilfs *, struct nilfs_sb_info *,
|
extern int nilfs_search_super_root(struct the_nilfs *,
|
||||||
struct nilfs_recovery_info *);
|
struct nilfs_recovery_info *);
|
||||||
extern int nilfs_recover_logical_segments(struct the_nilfs *,
|
extern int nilfs_recover_logical_segments(struct the_nilfs *,
|
||||||
struct nilfs_sb_info *,
|
struct nilfs_sb_info *,
|
||||||
|
|
|
@ -159,8 +159,7 @@ void put_nilfs(struct the_nilfs *nilfs)
|
||||||
kfree(nilfs);
|
kfree(nilfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nilfs_load_super_root(struct the_nilfs *nilfs,
|
static int nilfs_load_super_root(struct the_nilfs *nilfs, sector_t sr_block)
|
||||||
struct nilfs_sb_info *sbi, sector_t sr_block)
|
|
||||||
{
|
{
|
||||||
struct buffer_head *bh_sr;
|
struct buffer_head *bh_sr;
|
||||||
struct nilfs_super_root *raw_sr;
|
struct nilfs_super_root *raw_sr;
|
||||||
|
@ -169,7 +168,7 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs,
|
||||||
unsigned inode_size;
|
unsigned inode_size;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = nilfs_read_super_root_block(sbi->s_super, sr_block, &bh_sr, 1);
|
err = nilfs_read_super_root_block(nilfs, sr_block, &bh_sr, 1);
|
||||||
if (unlikely(err))
|
if (unlikely(err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -285,13 +284,13 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
|
||||||
|
|
||||||
nilfs_init_recovery_info(&ri);
|
nilfs_init_recovery_info(&ri);
|
||||||
|
|
||||||
err = nilfs_search_super_root(nilfs, sbi, &ri);
|
err = nilfs_search_super_root(nilfs, &ri);
|
||||||
if (unlikely(err)) {
|
if (unlikely(err)) {
|
||||||
printk(KERN_ERR "NILFS: error searching super root.\n");
|
printk(KERN_ERR "NILFS: error searching super root.\n");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nilfs_load_super_root(nilfs, sbi, ri.ri_super_root);
|
err = nilfs_load_super_root(nilfs, ri.ri_super_root);
|
||||||
if (unlikely(err)) {
|
if (unlikely(err)) {
|
||||||
printk(KERN_ERR "NILFS: error loading super root.\n");
|
printk(KERN_ERR "NILFS: error loading super root.\n");
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
Loading…
Reference in a new issue