[sheepdog] Unreliable error code handling in sheep/plainstore.c

Liu Yuan namei.unix at gmail.com
Wed Mar 4 09:31:52 CET 2015


On Wed, Mar 04, 2015 at 04:21:46PM +0800, Xu Yifeng wrote:
> I found some unreliable error handling in plainstore.c, reason is
> combination of
> sd_err() and err_to_sderr(), because it is not guaranteed that
> sd_err() does not
> muck errno, it is possible passing an mucked errno to
> err_to_sderr(), see following
> code in plain_store.c, line 758:
>    if (unlikely(size != len)) {
>                 sd_err("failed to write object %"PRIx64", path=%s,
> offset=%"
>                        PRId32", size=%"PRId32", result=%zd, %m", oid, path,
>                        iocb->offset, iocb->length, size);
>                 ret = err_to_sderr(path, oid, errno);
>                 goto out;
>         }
> 
> it is possible that sd_err() may muck the errno, causing an
> irrelevant errno to be passed to
> err_to_sderr!

Good catch!

It is really a hidden bug for a long time. This might explain why I sometimes saw
strange logs in the past!

Could you please cook a decent patch for this problem? The fix looks good to me.

Thanks,
Yuan



More information about the sheepdog mailing list