/* * Write the MMP block using WRITE_SYNC to try to get the block on-disk * faster. */ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh) { struct mmp_struct *mmp = (struct mmp_struct *)(bh->b_data); /* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ sb_start_write(sb); ext4_mmp_csum_set(sb, mmp); mark_buffer_dirty(bh); lock_buffer(bh); bh->b_end_io = end_buffer_write_sync; get_bh(bh); #ifdef FEATURE_STORAGE_META_LOG if( bh && bh->b_bdev && bh->b_bdev->bd_disk) set_metadata_rw_status(bh->b_bdev->bd_disk->first_minor, WAIT_WRITE_CNT); #endif submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh); wait_on_buffer(bh); sb_end_write(sb); if (unlikely(!buffer_uptodate(bh))) return 1; return 0; }
/* * Write the MMP block using WRITE_SYNC to try to get the block on-disk * faster. */ static int write_mmp_block(struct buffer_head *bh) { mark_buffer_dirty(bh); lock_buffer(bh); bh->b_end_io = end_buffer_write_sync; get_bh(bh); #ifdef FEATURE_STORAGE_META_LOG set_metadata_rw_status(bh->b_bdev->bd_disk->first_minor, WAIT_WRITE_CNT); #endif submit_bh(WRITE_SYNC, bh); wait_on_buffer(bh); if (unlikely(!buffer_uptodate(bh))) return 1; return 0; }
/* * Read the MMP block. It _must_ be read from disk and hence we clear the * uptodate flag on the buffer. */ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh, ext4_fsblk_t mmp_block) { struct mmp_struct *mmp; if (*bh) clear_buffer_uptodate(*bh); /* This would be sb_bread(sb, mmp_block), except we need to be sure * that the MD RAID device cache has been bypassed, and that the read * is not blocked in the elevator. */ if (!*bh) *bh = sb_getblk(sb, mmp_block); if (!*bh) return -ENOMEM; if (*bh) { get_bh(*bh); lock_buffer(*bh); (*bh)->b_end_io = end_buffer_read_sync; #ifdef FEATURE_STORAGE_META_LOG if( (*bh) && (*bh)->b_bdev && (*bh)->b_bdev->bd_disk) set_metadata_rw_status((*bh)->b_bdev->bd_disk->first_minor, WAIT_READ_CNT); #endif submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh); wait_on_buffer(*bh); if (!buffer_uptodate(*bh)) { brelse(*bh); *bh = NULL; } } if (unlikely(!*bh)) { ext4_warning(sb, "Error while reading MMP block %llu", mmp_block); return -EIO; } mmp = (struct mmp_struct *)((*bh)->b_data); if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC || !ext4_mmp_csum_verify(sb, mmp)) return -EINVAL; return 0; }