[Ocfs2-tools-devel] [PATCH 1/5] fsck.ocfs2: Check the validity of slot_map's inode before fsck
Goldwyn Rodrigues
rgoldwyn at suse.de
Fri Apr 24 07:43:07 PDT 2015
Hi Piaojun,
On 04/02/2015 07:25 AM, piaojun wrote:
> In main(), slot_map's inode should be checked if invalid before being
> fixed, as fsck.ocfs2 can not handle this situation.
This is a good attempt. However, this would render filesystem useless if
the slot map file is corrupted. Do you think you can add more code to
write the slotmap inode after asking the user to fix it?
Also, supporting it with fswreck will be great.
Thanks,
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> Reviewed-by: Alex Chen <alex.chen at huawei.com>
>
> ---
> fsck.ocfs2/fsck.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
> index 4b7d4b3..7a67c9e 100644
> --- a/fsck.ocfs2/fsck.c
> +++ b/fsck.ocfs2/fsck.c
> @@ -675,6 +675,31 @@ bail:
> return ret;
> }
>
> +static int check_system_file_if_valid(ocfs2_filesys *fs, int type,
> + int slot_num)
> +{
> + errcode_t ret;
> + uint64_t blkno;
> + char *buf = NULL;
> +
> + ret = ocfs2_lookup_system_inode(fs, type, slot_num,
> + &blkno);
> + if (ret)
> + goto out;
> +
> + ret = ocfs2_malloc_block(fs->fs_io, &buf);
> + if (ret)
> + goto out;
> +
> + ret = ocfs2_read_inode(fs, blkno, buf);
> +
> +out:
> + if (buf)
> + ocfs2_free(&buf);
> +
> + return ret;
> +}
> +
> int main(int argc, char **argv)
> {
> char *filename;
> @@ -978,6 +1003,13 @@ int main(int argc, char **argv)
> goto unlock;
> }
>
> + ret = check_system_file_if_valid(ost->ost_fs, SLOT_MAP_SYSTEM_INODE, 0);
> + if (ret) {
> + com_err(whoami, ret, "while checking slot map.");
> + fsck_mask |= FSCK_ERROR;
> + goto unlock;
> + }
> +
> ret = o2fsck_slot_recovery(ost);
> if (ret) {
> printf("fsck encountered errors while recovering slot "
>
--
Goldwyn
More information about the Ocfs2-tools-devel
mailing list