[sheepdog] [PATCH v1 4/4] sheep: go to panic if using unaligned memory in direct-io mode

Liu Yuan namei.unix at gmail.com
Wed Jan 29 11:02:10 CET 2014


On Wed, Jan 29, 2014 at 05:15:07PM +0800, Robin Dong wrote:
> When startup sheep with option "-D", the plain_store will check alignment of
> read/write buffer, but if the buffer is not aligned, it will do nothing if
> it dose not choose "--enable-debug" for configuration. Then sheep will open
> file with "O_DIRECT" and call pread() with unaligned buffer, it will cause
> error io and remove the disk from md which is totally wrong behavior.
> So, we should make the check strong enough: sheep will panic directlly if
> finding unaligned buffer.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  sheep/plain_store.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sheep/plain_store.c b/sheep/plain_store.c
> index fa6c01b..9a4871c 100644
> --- a/sheep/plain_store.c
> +++ b/sheep/plain_store.c
> @@ -48,7 +48,8 @@ static int prepare_iocb(uint64_t oid, const struct siocb *iocb, bool create)
>  		flags &= ~O_DSYNC;
>  
>  	if (sys->backend_dio && iocb_is_aligned(iocb)) {
> -		assert(is_aligned_to_pagesize(iocb->buf));
> +		if (!is_aligned_to_pagesize(iocb->buf))
> +			panic("Memory isn't aligned to pagesize %p", iocb->buf);
>  		flags |= O_DIRECT;
>  	}
>  
> -- 
> 1.7.12.4
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Applied thanks

Yuan



More information about the sheepdog mailing list