[sheepdog] [PATCH v2 1/3] journal: ignore invalid journal files

Liu Yuan namei.unix at gmail.com
Thu Apr 11 07:31:39 CEST 2013


On 04/10/2013 04:25 PM, Hitoshi Mitake wrote:
> From: Hitoshi Mitake <mitake.hitoshi at gmail.com>
> 
> Even if journal files are broken, we can do nothing for recoverying
> it. It is better to inform it as log messages and continue the
> initialization process.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> 
> v2: panic when do_recover() fails
> 
>  sheep/journal.c |   16 +++++++---------
>  1 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/sheep/journal.c b/sheep/journal.c
> index 2e1d21f..59608ac 100644
> --- a/sheep/journal.c
> +++ b/sheep/journal.c
> @@ -245,31 +245,29 @@ skip:
>   * we actually only recover one jfile, the other would be empty. This process
>   * is fast with buffered IO that only take several secends at most.
>   */
> -static int check_recover_journal_file(const char *p)
> +static void check_recover_journal_file(const char *p)
>  {
>  	int old = 0, new = 0;
>  
>  	if (get_old_new_jfile(p, &old, &new) < 0)
> -		return -1;
> +		return;
>  
>  	/* No journal file found */
>  	if (old == 0)
> -		return 0;
> +		return;
>  
>  	if (do_recover(old) < 0)
> -		return -1;
> +		panic("recoverying from journal file (old) failed");
>  	if (do_recover(new) < 0)
> -		return -1;
> -
> -	return 0;
> +		panic("recoverying from journal file (new) failed");
>  }
>  
>  int journal_file_init(const char *path, size_t size, bool skip)
>  {
>  	int fd;
>  
> -	if (!skip && check_recover_journal_file(path) < 0)
> -		return -1;
> +	if (!skip)
> +		check_recover_journal_file(path);
>  
>  	jfile_size = (size * 1024 * 1024) / 2;
>  
> 

We need to handle empty jfile too (proceed when meeting empty jfile, not
exist as now). Empty jfile could exist when sheep crash just between
ftruncate() and prealloc() in commit_data().

Thanks,
Yuan



More information about the sheepdog mailing list