Save restore device Id: issue #8978

Fixes #8978

During testing of docker with device mapper backend, I often noticed bunch of warnings on console and often thought that if something is wrong with my docker setup. It turned out that docker does not keep track of already used device ids.  This patch series should make docker little bit smarter about it.

More details are in issue and patches. Please review and pull.

Thanks
Vivek
On Tue, Nov 11, 2014 at 10:12:35AM -0800, Michael Crosby wrote:
> > @@ -535,6 +550,24 @@ func (devices *DeviceSet) ResizePool(size int64) error {
> >  	return nil
> >  }
> >  
> > +func (devices *DeviceSet) loadDeviceSetMetaData() error {
> > +	jsonData, err := ioutil.ReadFile(devices.deviceSetMetaFile())
> > +	if err != nil {
> > +		return nil
> > +	}
> > +
> > +	return json.Unmarshal(jsonData, devices)
> > +}
> > +
> > +func (devices *DeviceSet) saveDeviceSetMetaData() error {
> > +	jsonData, err := json.Marshal(devices)
> 
> Like my comment above I would use a json.Encoder so that we don't marshal into a in memory byte array before writing to disk. 

Ok, will do. Given that it is such a small file, we probably are looking
at saving 32 or 64 bytes of memory. And that memory might get consumed
due to internal buffering done by Encoder/Decoder. 

But anyway, I will do it given that you seem to have a liking for it.

Vivek