Mark device ID free only if device actually got deleted
Mark device ID free only if device actually got deleted

Right now if somebody has enabled deferred device deletion, then
deleteTransaction() returns success even if device could not be deleted. It
has been marked for deferred deletion. Right now we will mark device ID free
and potentially use it again when somebody tries to create new container. And
that's wrong. Device ID is not free yet. It will become free once devices
has actually been deleted by the goroutine later.

So move the location of call to markDeviceIDFree() to a place where we know
device actually got deleted and was not marked for deferred deletion.

Signed-off-by: Vivek Goyal <61d11262d0d9873ddb5a887f48fcb04e8c5973d0@redhat.com>

contiv/docker,jloehel/docker,nghiant2710/docker,hqhq/moby,13W/docker,jecarey/docker,BenHall/docker,KarthikNayak/docker,endophage/docker,anweiss/docker.github.io,jongiddy/docker,dsau/docker,HuKeping/docker,konstruktoid/docker-1,fangyuan930917/docker,shubheksha/docker.github.io,pradipd/moby,naveed-jamil-tenpearls/moby,yosifkit/docker,umerazad/docker,Syntaxide/docker,docker-zh/docker.github.io,ZJUshuaizhou/docker,paralin/docker,gnailuy/docker,medallia/docker,zhangjianfnst/docker,shubheksha/docker.github.io,nawawi/docker,x1022as/docker,yp-engineering/docker,aduermael/docker.github.io,swasd/baleno,gigidwan/docker,tpounds/docker,erikh/docker,achanda/docker,ZJU-SEL/docker,ndeloof/docker,pyotr777/docker,rkazak/docker,jzwlqx/denverdino.github.io,joeuo/docker.github.io,JimGalasyn/docker.github.io,jvanz/docker,mbanikazemi/docker,moul/docker,BSWANG/denverdino.github.io,vdemeester/docker,anortef/docker,kunalkushwaha/docker,isubuz/docker,gjaskiewicz/moby,scotttlin/docker,johnstep/docker.github.io,zhuguihua/docker,tkopczynski/docker,moby/moby,luxas/docker,docker/docker,rillig/docker.github.io,solganik/docker,ColinHebert/docker,TheBigBear/docker,dsau/docker,ckeyer/docker,sarnautov/moby,PatrickLang/moby,rillig/docker.github.io,justincormack/docker,anujbahuguna/docker,alexisbellido/docker.github.io,cyli/docker,twaugh/docker,Test-Betta-Inc/psychic-barnacle,JimGalasyn/docker.github.io,londoncalling/docker.github.io,charleszheng44/moby,mikebrow/docker,BenHall/docker,mbanikazemi/docker,erikstmartin/docker,flavio/docker,dnephin/docker,dongjoon-hyun/docker,ivansaracino/docker,michelvocks/docker,justyntemme/docker,Altiscale/docker,bfirsh/docker,Microsoft/docker,skatsuta/docker,sanjeo/docker,dsau/docker,BSWANG/denverdino.github.io,eskaaren/docker,arun-gupta/docker,erikstmartin/docker,johnstep/docker.github.io,tklauser/docker,anweiss/docker.github.io,sdurrheimer/docker,kolyshkin/moby,shubheksha/docker.github.io,mathewkoshy493/docker,tmp6154/docker,gnailuy/docker,ibuildthecloud/docker,jhorwit2/docker,swasd/baleno,harche/docker,afein/docker,cpuguy83/docker,sallyom/docker,Syntaxide/docker,mike1729/docker,docker-zh/docker.github.io,kerneltime/docker,thaJeztah/docker,jlebon/docker,laijs/docker,erikh/docker,willmtemple/docker,gdevillele/docker.github.io,liaoqingwei/docker,DoraALin/docker,POLJM242/docker,tagomoris/docker,pramodhkp/moby,tophj-ibm/moby,yasiramin10p/moby,cyphar/docker,tophj-ibm/docker,HideoYamauchi/docker,pradipd/moby,johnstep/docker.github.io,gdevillele/docker.github.io,SvenDowideit/docker,charleszheng44/moby,thaJeztah/docker.github.io,BrianBland/docker,wenchma/docker,Shopify/docker,bearstech/moby,JimGalasyn/docker.github.io,tklauser/docker,mssola/docker,geekylucas/docker,gdevillele/docker.github.io,resin-io/docker,kimh/docker,jlhawn/docker,aduermael/docker.github.io,LaynePeng/docker,Altiscale/docker,jlhawn/docker,duglin/docker,trebonian/docker,duglin/docker,stainboy/docker,jloehel/docker,vijaykilari/docker,yasiramin10p/moby,johnstep/moby-moby,denverdino/docker.github.io,ibuildthecloud/docker,afein/docker,phiroict/docker,pyotr777/docker,diogomonica/docker,joaofnfernandes/docker.github.io,sfsmithcha/docker,davinashreddy/docker,denverdino/docker.github.io,nigelpoulton/docker,rhatdan/docker,sanscontext/docker.github.io,gigidwan/docker,ncdc/docker,denverdino/denverdino.github.io,xuxinkun/docker,konstruktoid/docker-upstream,estesp/docker,Test-Betta-Inc/psychic-barnacle,x1022as/docker,LaynePeng/docker,laijs/moby,justincormack/docker,nguyentm83/docker,wenchma/docker,djs55/docker,michael-holzheu/docker,rhatdan/docker,mixja/docker,hustcat/docker,mtrmac/docker,jc-m/docker,rkazak/docker,alexisbellido/docker.github.io,jongiddy/docker,izarov/docker,tagomoris/docker,rhatdan/docker,lixiaobing1/docker,jlebon/docker,tmp6154/docker,danix800/docker.github.io,noxiouz/docker,rhatdan/storage,ZJU-SEL/docker,HideoYamauchi/docker,bdwill/docker.github.io,Mashimiao/docker,OnePaaS/docker,umerazad/docker,mahak/docker,shhsu/docker,dccurtis/docker,srust/docker,flavio/docker,13W/docker,crosbymichael/docker,DoraALin/docker,jimjag/docker,sfsmithcha/docker,shin-/docker.github.io,tklauser/docker,denverdino/docker.github.io,gdevillele/docker.github.io,swasd/baleno,errordeveloper/docker,nalind/docker,carolfh/docker,jzwlqx/denverdino.github.io,jimjag/docker,dccurtis/docker,unclejack/docker,ncdc/docker,docker/docker,menglingwei/denverdino.github.io,londoncalling/docker.github.io,madhanrm/docker,moul/docker,nigelpoulton/docker,JMesser81/docker,BrianBland/docker,coolljt0725/docker,lixiaobing1/docker,brahmaroutu/docker,paralin/docker,brahmaroutu/docker,nguyentm83/docker,mgoelzer/docker,errordeveloper/docker,nalind/docker,jwhonce/docker,ColinHebert/docker,willmtemple/docker,alexisbellido/docker.github.io,contiv/docker,anweiss/docker.github.io,troy0820/docker.github.io,bdwill/docker.github.io,isubuz/docker,zhuguihua/docker,kolyshkin/docker,maxamillion/docker,londoncalling/docker.github.io,davinashreddy/docker,mikedougherty/docker,coreos/docker,pecameron/docker,AkihiroSuda/docker,erikh/docker,lixiaobing10051267/docker,rancher/docker,resin-io/docker,mstanleyjones/docker,dims/docker,hyperhq/hypercli,sheimi/docker,asbjornenge/docker,dongjoon-hyun/docker,flavio/docker,tianon/docker,danix800/docker.github.io,whuwxl/docker,SvenDowideit/docker,tonistiigi/docker,naveed-jamil-tenpearls/moby,AkihiroSuda/docker,jameszhan/docker,xiaods/docker,ibuildthecloud/docker,rancher/docker,sanscontext/docker.github.io,BenHall/docker,tkopczynski/docker,KingEmet/docker,mike1729/docker,shhsu/docker,diogomonica/docker,mstanleyjones/docker,achanda/docker,denverdino/docker.github.io,kimh/docker,Microsoft/docker,noxiouz/docker,mssola/docker,hypriot/docker,moypray/docker,Ramzec/docker,eskaaren/docker,nigelpoulton/docker,darrenstahlmsft/docker,bluebreezecf/docker,icecrime/docker,q384566678/docker,catinthesky/docker,crosbymichael/docker,14rcole/docker,endophage/docker,moby/moby,cmehay/docker-1,kolyshkin/moby,kolyshkin/moby,x1022as/docker,sterchelen/docker,runcom/docker,thaJeztah/docker.github.io,isubuz/docker,cmehay/docker-1,shin-/docker.github.io,justincormack/docker,dccurtis/docker,rremer/moby,ffoysal/docker,anweiss/docker.github.io,denverdino/denverdino.github.io,containers/storage,cpuguy83/docker,cyphar/docker,cnaize/docker,POLJM242/docker,flavio/docker,kojiromike/docker,harche/docker,laijs/moby,luxas/docker,sunyuan3/docker,vijaykilari/docker,mgoelzer/docker,ripcurld0/moby,gao-feng/docker,coolljt0725/docker,docker/docker.github.io,mohmost12/docker,maxamillion/docker,allencloud/docker,ncdc/docker,darrenstahlmsft/docker,pecameron/docker,aaronlehmann/docker,SaiedKazemi/docker,mtesselH/docker,sanscontext/docker.github.io,mikebrow/docker,thaJeztah/docker,Tenk42/docker,kojiromike/docker,tophj-ibm/docker,darrenstahlmsft/moby,docker/docker.github.io,Mokolea/docker,KingEmet/docker,mtesselH/docker,gjaskiewicz/moby,vincentwoo/docker,hustcat/docker,madhanrm/docker,hyperhq/hypercli,rhatdan/storage,KarthikNayak/docker,SvenDowideit/docker,cnaize/docker,TheBigBear/docker,noironetworks/docker,laijs/moby,thtanaka/docker,danyalKhaliq10p/moby,bearstech/moby,sanscontext/docker.github.io,aaronlehmann/docker,jecarey/docker,OnePaaS/docker,anortef/docker,yummypeng/docker,mahak/docker,aditirajagopal/docker,xiaods/docker,vincentwoo/docker,johnstep/moby-moby,justyntemme/docker,icaoweiwei/docker,mixja/docker,aditirajagopal/docker,tonistiigi/docker,dongjoon-hyun/docker,cr7pt0gr4ph7/docker,HuKeping/docker,dsheets/moby,HackToday/docker,dperny/docker,sunyuan3/docker,sdurrheimer/docker,tonistiigi/docker,tpounds/docker,rillig/docker.github.io,BSWANG/denverdino.github.io,zhuguihua/docker,achanda/docker,dmcgowan/docker,coolljt0725/docker,hallyn/docker,JeffBellegarde/docker,sean-jc/docker,izarov/docker,catinthesky/docker,kimh/docker,jvanz/docker,cnaize/docker,jc-m/docker,tophj-ibm/moby,docker/docker.github.io,yongtang/docker,akira-baruah/docker,trebonian/docker,Morsicus/docker,phiroict/docker,konstruktoid/docker-upstream,raja-sami-10p/moby,hyperhq/hypercli,stainboy/docker,docker/docker.github.io,londoncalling/docker.github.io,sallyom/docker,asbjornenge/docker,YuPengZTE/docker,inatatsu/docker,inatatsu/docker,supasate/docker,vdemeester/docker,michael-holzheu/docker,Mokolea/docker,hallyn/docker,solganik/docker,prertik/docker,bfirsh/docker,diogomonica/docker,hustcat/docker,cyphar/docker,menglingwei/denverdino.github.io,srust/docker,ivansaracino/docker,LuisBosquez/docker.github.io,carolfh/docker,trebonian/docker,toli/docker,mahak/docker,ckeyer/docker,darrenstahlmsft/moby,icecrime/docker,coreos/docker,dnephin/docker,akira-baruah/docker,mohmost12/docker,dsheets/moby,Collinux/docker,Test-Betta-Inc/psychic-barnacle,fsoppelsa/docker,Mashimiao/docker,fcrisciani/docker,lixiaobing10051267/docker,LuisBosquez/docker.github.io,mgoelzer/docker,sanjeo/docker,Collinux/docker,ripcurld0/moby,bdwill/docker.github.io,HackToday/docker,harche/docker,solganik/docker,mikebrow/docker,londoncalling/docker.github.io,rremer/moby,anweiss/docker.github.io,Morsicus/docker,projectatomic/docker,arun-gupta/docker,denverdino/denverdino.github.io,shin-/docker.github.io,phiroict/docker,sallyom/docker,moypray/docker,eskaaren/docker,cloudflare/docker,laijs/docker,joaofnfernandes/docker.github.io,prertik/docker,paralin/docker,tpounds/docker,mathewkoshy493/docker,moypray/docker,projectatomic/docker,mkumatag/docker,yummypeng/docker,ripcurld0/moby,shishir-a412ed/docker,containers/storage,mtanlee/docker,danix800/docker.github.io,xiekeyang/docker,splunk/docker,gigidwan/docker,mohmost12/docker,nghiant2710/docker,amatsus/docker,aduermael/docker.github.io,mkumatag/docker,LuisBosquez/docker.github.io,jwhonce/docker,containers/storage,alexisbellido/docker.github.io,whuwxl/docker,skatsuta/docker,prertik/docker,imkin/moby,danyalKhaliq10p/moby,shin-/docker.github.io,cpuguy83/docker,abhinavdahiya/docker,jlhawn/docker,upmio/docker,supasate/docker,charleswhchan/docker,msabansal/docker,cr7pt0gr4ph7/docker,YuPengZTE/docker,inatatsu/docker,kunalkushwaha/docker,toli/docker,alfred-landrum/docker,kyle-wang/docker,moxiegirl/docker,thaJeztah/docker,qudongfang/docker,abhinavdahiya/docker,nawawi/docker,mikedougherty/docker,fcrisciani/docker,ivansaracino/docker,xiekeyang/docker,13W/docker,dmcgowan/docker,TrumanLing/docker,joaofnfernandes/docker.github.io,menglingwei/denverdino.github.io,mahak/docker,zhangjianfnst/docker,resin-io/docker,unclejack/docker,BSWANG/denverdino.github.io,coreos/docker,scollier/docker,wenchma/docker,lixiaobing1/docker,ajaymdesai/docker,cyli/docker,splunk/docker,dgageot/docker,ajaymdesai/docker,troy0820/docker.github.io,aidanhs/docker,cr7pt0gr4ph7/docker,vdemeester/docker,yosifkit/docker,charleswhchan/docker,moul/docker,PatrickLang/moby,thaJeztah/docker.github.io,kencochrane/docker,Ramzec/docker,raja-sami-10p/moby,troy0820/docker.github.io,umerazad/docker,mssola/docker,shishir-a412ed/docker,zhangjianfnst/docker,JimGalasyn/docker.github.io,pramodhkp/moby,yongtang/docker,sanjeo/docker,gnailuy/docker,nawawi/docker,gdevillele/docker.github.io,xiekeyang/docker,splunk/docker,thaJeztah/docker.github.io,moby/moby,estesp/docker,anujbahuguna/docker,davinashreddy/docker,duglin/docker,fsoppelsa/docker,miminar/docker,qudongfang/docker,runcom/docker,LuisBosquez/docker.github.io,sheimi/docker,pyotr777/docker,raja-sami-10p/moby,danyalKhaliq10p/moby,allencloud/docker,mstanleyjones/docker,gschaetz/moby,shubheksha/docker.github.io,mtrmac/docker,scollier/docker,johnstep/moby-moby,fangyuan930917/docker,sarnautov/moby,ZJUshuaizhou/docker,jc-m/docker,cyli/docker,kunalkushwaha/docker,denverdino/denverdino.github.io,msabansal/docker,bluebreezecf/docker,joaofnfernandes/docker.github.io,bearstech/moby,jongiddy/docker,medallia/docker,dgageot/docker,docker-zh/docker.github.io,joaofnfernandes/docker.github.io,hqhq/moby,carolfh/docker,joeuo/docker.github.io,danix800/docker.github.io,imeoer/hypercli,endophage/docker,pradipd/moby,djs55/docker,HackToday/docker,sunyuan3/docker,liaoqingwei/docker,sterchelen/docker,YujiOshima/docker,mtrmac/docker,Syntaxide/docker,kencochrane/docker,tkopczynski/docker,mbanikazemi/docker,miminar/docker,unclejack/docker,Tenk42/docker,jzwlqx/denverdino.github.io,luxas/docker,charleswhchan/docker,ibuildthecloud/docker,BSWANG/denverdino.github.io,msabansal/docker,yasiramin10p/moby,shhsu/docker,mikedougherty/docker,bonczj/moby-json-file-logger,docker/docker.github.io,bonczj/moby-json-file-logger,aduermael/docker.github.io,anortef/docker,haveatry/docker,haveatry/docker,sean-jc/docker,q384566678/docker,michelvocks/docker,mixja/docker,miminar/docker,hypriot/docker,menglingwei/denverdino.github.io,dperny/docker,JMesser81/docker,kolyshkin/docker,sean-jc/docker,dims/docker,gschaetz/moby,Jimmy-Xu/hypercli,mtanlee/docker,icecrime/docker,aaronlehmann/docker,Tenk42/docker,twaugh/docker,kerneltime/docker,HideoYamauchi/docker,amatsus/docker,imkin/moby,laijs/docker,ffoysal/docker,jimjag/docker,medallia/docker,jloehel/docker,upmio/docker,stevvooe/docker,jthelin/docker,jthelin/docker,dims/docker,ckeyer/docker,darrenstahlmsft/docker,ZJUshuaizhou/docker,imeoer/hypercli,mkumatag/docker,nawawi/docker,amatsus/docker,rkazak/docker,docker/docker,jlebon/docker,noironetworks/docker,joeuo/docker.github.io,pramodhkp/moby,thaJeztah/docker,xiaods/docker,srust/docker,vijaykilari/docker,catinthesky/docker,pecameron/docker,PatrickLang/moby,yongtang/docker,xuxinkun/docker,jhorwit2/docker,JimGalasyn/docker.github.io,13W/docker,lixiaobing10051267/docker,bluebreezecf/docker,supasate/docker,joeuo/docker.github.io,docker-zh/docker.github.io,docker-zh/docker.github.io,Ramzec/docker,cloudflare/docker,kyle-wang/docker,ibuildthecloud/docker,yp-engineering/docker,upmio/docker,willmtemple/docker,imeoer/hypercli,alfred-landrum/docker,ndeloof/docker,TrumanLing/docker,cloudflare/docker,contiv/docker,bdwill/docker.github.io,YuPengZTE/docker,yp-engineering/docker,ailispaw/docker,qudongfang/docker,YujiOshima/docker,liaoqingwei/docker,sdurrheimer/docker,sfsmithcha/docker,rremer/moby,geekylucas/docker,troy0820/docker.github.io,14rcole/docker,moby/moby,erikstmartin/docker,moxiegirl/docker,imkin/moby,dmcgowan/docker,denverdino/docker.github.io,michelvocks/docker,crosbymichael/docker,bearstech/moby,JeffBellegarde/docker,arun-gupta/docker,Jimmy-Xu/hypercli,johnstep/docker.github.io,Jimmy-Xu/hypercli,menglingwei/denverdino.github.io,portworx/docker,abhinavdahiya/docker,Collinux/docker,BrianBland/docker,michael-holzheu/docker,LuisBosquez/docker.github.io,twaugh/docker,LaynePeng/docker,jvanz/docker,justyntemme/docker,jimjag/docker,nalind/docker,nghiant2710/docker,TheBigBear/docker,gao-feng/docker,gjaskiewicz/moby,bdwill/docker.github.io,kencochrane/docker,portworx/docker,geekylucas/docker,hypriot/docker,jameszhan/docker,dgageot/docker,fsoppelsa/docker,asbjornenge/docker,dnephin/docker,kyle-wang/docker,projectatomic/docker,madhanrm/docker,noironetworks/docker,bfirsh/docker,stevvooe/docker,tianon/docker,Mokolea/docker,JeffBellegarde/docker,hqhq/moby,Mokolea/docker,stevvooe/docker,thaJeztah/docker.github.io,13W/docker,mike1729/docker,whuwxl/docker,shishir-a412ed/docker,estesp/docker,denverdino/denverdino.github.io,dsheets/moby,hallyn/docker,sterchelen/docker,konstruktoid/docker-1,alexisbellido/docker.github.io,gschaetz/moby,afein/docker,johnstep/docker.github.io,Shopify/docker,Microsoft/docker,TrumanLing/docker,konstruktoid/docker-1,yummypeng/docker,yosifkit/docker,cpuguy83/docker,ffoysal/docker,stainboy/docker,izarov/docker,jzwlqx/denverdino.github.io,rhardih/docker,gao-feng/docker,sheimi/docker,anujbahuguna/docker,moul/docker,fcrisciani/docker,aidanhs/docker,naveed-jamil-tenpearls/moby,HuKeping/docker,xuxinkun/docker,scotttlin/docker,shin-/docker.github.io,thtanaka/docker,ailispaw/docker,rillig/docker.github.io,rhardih/docker,thtanaka/docker,kerneltime/docker,mtanlee/docker,dperny/docker,icaoweiwei/docker,scotttlin/docker,aidanhs/docker,AkihiroSuda/docker,phiroict/docker,portworx/docker,Mashimiao/docker,yosifkit/docker,konstruktoid/docker-upstream,jzwlqx/denverdino.github.io,mtesselH/docker,nalind/docker,moxiegirl/docker,fangyuan930917/docker,jhorwit2/docker,Altiscale/docker,SaiedKazemi/docker,rancher/docker,darrenstahlmsft/moby,haveatry/docker,OnePaaS/docker,tophj-ibm/moby,runcom/docker,charleszheng44/moby,AkihiroSuda/docker,DoraALin/docker,vincentwoo/docker,maxamillion/docker,skatsuta/docker,sarnautov/moby,noxiouz/docker,aditirajagopal/docker,djs55/docker,brahmaroutu/docker,KingEmet/docker,errordeveloper/docker,gnailuy/docker,konstruktoid/docker-upstream,sanscontext/docker.github.io,jwhonce/docker,jameszhan/docker,Shopify/docker,mathewkoshy493/docker,allencloud/docker,q384566678/docker,bonczj/moby-json-file-logger,cmehay/docker-1,tmp6154/docker,ColinHebert/docker,tagomoris/docker,ailispaw/docker,tophj-ibm/docker,phiroict/docker,shubheksha/docker.github.io,trebonian/docker,icaoweiwei/docker,ajaymdesai/docker,joeuo/docker.github.io,rhatdan/storage,medallia/docker,SaiedKazemi/docker,KarthikNayak/docker,kojiromike/docker,Morsicus/docker,alfred-landrum/docker,YujiOshima/docker,toli/docker,Ramzec/docker,ndeloof/docker,paralin/docker,JMesser81/docker