[sheepdog] [PATCH] sheep: read journal head first in journal_recover

Liu Yuan namei.unix at gmail.com
Thu Jul 5 08:11:27 CEST 2012


On 07/05/2012 02:06 PM, levin li wrote:
> From: levin li <xingke.lwp at taobao.com>
> 
> Sheep doesn't read the journal head in journal_recover which
> always leaves all the fields of journal head uninitialized,
> so the target_path is something random.
> 
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
>  sheep/journal.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/sheep/journal.c b/sheep/journal.c
> index d082aa2..74384b2 100644
> --- a/sheep/journal.c
> +++ b/sheep/journal.c
> @@ -257,6 +257,12 @@ int jrnl_recover(const char *jrnl_dir)
>  			goto end_while_3;
>  		}
>  
> +		ret = pread64(jd.fd, &jd.head, sizeof(jd.head), 0);

why not use xpread which handles short read? I think all pread64 should
be changed into xpread

Thanks,
Yuan
> +		if (ret != sizeof(jd.head)) {
> +			eprintf("can't read journal head\n");
> +			goto end_while_2;
> +		}
> +
>  		ret = pread64(jd.fd, &end_mark, sizeof(end_mark),
>  				sizeof(jd.head) + jd.head.size);
>  		if (ret != sizeof(end_mark)) {
> 





More information about the sheepdog mailing list