[sheepdog] [PATCH] dog: don't set copy_policy for inode update of 'vdi write/create'

Liu Yuan namei.unix at gmail.com
Wed Oct 9 17:51:26 CEST 2013


On Thu, Oct 10, 2013 at 12:28:00AM +0900, MORITA Kazutaka wrote:
> At Wed,  9 Oct 2013 18:51:27 +0800,
> Liu Yuan wrote:
> > 
> > inode object isn't erasure coded but replicated.
> 
> Is this a cleanup patch?  IIUC, is_erasure_oid() in sheep returns
> false against vdi objects, so I thought that it's not problem to set
> copy_policy for inode update.
> 

Not exactly, without this patch, vdi write will always fail because
is_erasure_req() will return true for inode object and will panic sheep.

> > 
> > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > ---
> >  dog/vdi.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/dog/vdi.c b/dog/vdi.c
> > index db32193..b4a2aeb 100644
> > --- a/dog/vdi.c
> > +++ b/dog/vdi.c
> > @@ -559,8 +559,7 @@ static int vdi_create(int argc, char **argv)
> >  		inode->data_vdi_id[idx] = vid;
> >  		ret = sd_write_object(vid_to_vdi_oid(vid), 0, &vid, sizeof(vid),
> >  				      SD_INODE_HEADER_SIZE + sizeof(vid) * idx,
> > -				      0, inode->nr_copies, inode->copy_policy,
> > -				      false, true);
> > +				      0, inode->nr_copies, 0, false, true);
> >  		if (ret) {
> >  			ret = EXIT_FAILURE;
> >  			goto out;
> > @@ -1323,11 +1322,12 @@ static int vdi_write(int argc, char **argv)
> >  		}
> >  
> >  		if (create) {
> > +			/* For inode update, don't set copy_policy */
> >  			ret = sd_write_object(vid_to_vdi_oid(vid), 0, &vid,
> >  					      sizeof(vid),
> >  				SD_INODE_HEADER_SIZE + sizeof(vid) * idx,
> >  					      flags, inode->nr_copies,
> > -					      inode->copy_policy, false, false);
> > +					      0, false, false);
> >  			if (ret) {
> >  				ret = EXIT_FAILURE;
> >  				goto out;
> 
> There are other sd_write_object() calls against vdi objects in
> vdi_snapshot(), vdi_clone(), vdi_resize(), and many other places in
> dog/vdi.c.

It seems we'd better introduce sd_write_inode_{data,inode} helpers unless we
find a better way to handle this problem. How do you think?

Thanks
Yuan



More information about the sheepdog mailing list