[sheepdog] [PATCH 1/2] md: purge directory only when md_add_disk() succeed

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri May 10 07:49:57 CEST 2013


At Fri, 10 May 2013 13:44:03 +0800,
Liu Yuan wrote:
> 
> > At Fri, 10 May 2013 13:33:00 +0800,
> > Liu Yuan wrote:
> > >
> > > @@ -608,13 +609,12 @@ static int do_plug_unplug(char *disks, bool plug)
> > >       old_nr = md_nr_disks;
> > >       path = strtok(disks, ",");
> > >       do {
> > > -             if (purge_directory(path) < 0)
> > > -                     goto out;
> > > -
> > > -             if (plug)
> > > -                     md_add_disk(path);
> > > -             else
> > > +             if (plug) {
> > > +                     if (md_add_disk(path) && purge_directory(path) <
> 0)
> > > +                                     goto out;
> >
> > Wrong indentation.
> >
> > What happens if md_add_disk() succeeds but purge_directory() fails?
> > Should we call md_del_disk() against the added disk?
> >
> 
> no, we dont plug any disks in that case

But md_add_disk() increments md_nr_disks in the case.  I think we need
at least some clean-up operations to decrement md_nr_disks.

Thanks,

Kazutaka



More information about the sheepdog mailing list