Browse code

Fix devmapper backend in docker info

Signed-off-by: Anusha Ragunathan <anusha@docker.com>

Anusha Ragunathan authored on 2015/11/14 03:56:21
Showing 2 changed files
... ...
@@ -100,7 +100,7 @@ type DeviceSet struct {
100 100
 	dataLoopbackSize      int64
101 101
 	metaDataLoopbackSize  int64
102 102
 	baseFsSize            uint64
103
-	userFilesystem        string // FS specified by user using dm.fs
103
+	filesystem            string
104 104
 	mountOptions          string
105 105
 	mkfsArgs              []string
106 106
 	dataDevice            string // block or loop dev
... ...
@@ -149,6 +149,8 @@ type Status struct {
149 149
 	Metadata DiskUsage
150 150
 	// BaseDeviceSize is base size of container and image
151 151
 	BaseDeviceSize uint64
152
+	// BaseDeviceFS is backing filesystem.
153
+	BaseDeviceFS string
152 154
 	// SectorSize size of the vector.
153 155
 	SectorSize uint64
154 156
 	// UdevSyncSupported is true if sync is supported.
... ...
@@ -584,12 +586,11 @@ func (devices *DeviceSet) createFilesystem(info *devInfo) error {
584 584
 
585 585
 	var err error
586 586
 
587
-	fs := devices.userFilesystem
588
-	if fs == "" {
589
-		fs = determineDefaultFS()
587
+	if devices.filesystem == "" {
588
+		devices.filesystem = determineDefaultFS()
590 589
 	}
591 590
 
592
-	switch fs {
591
+	switch devices.filesystem {
593 592
 	case "xfs":
594 593
 		err = exec.Command("mkfs.xfs", args...).Run()
595 594
 	case "ext4":
... ...
@@ -602,7 +603,7 @@ func (devices *DeviceSet) createFilesystem(info *devInfo) error {
602 602
 		}
603 603
 		err = exec.Command("tune2fs", append([]string{"-c", "-1", "-i", "0"}, devname)...).Run()
604 604
 	default:
605
-		err = fmt.Errorf("Unsupported filesystem type %s", fs)
605
+		err = fmt.Errorf("Unsupported filesystem type %s", devices.filesystem)
606 606
 	}
607 607
 	if err != nil {
608 608
 		return err
... ...
@@ -889,6 +890,10 @@ func (devices *DeviceSet) getBaseDeviceSize() uint64 {
889 889
 	return info.Size
890 890
 }
891 891
 
892
+func (devices *DeviceSet) getBaseDeviceFS() string {
893
+	return devices.filesystem
894
+}
895
+
892 896
 func (devices *DeviceSet) verifyBaseDeviceUUIDFS(baseInfo *devInfo) error {
893 897
 	devices.Lock()
894 898
 	defer devices.Unlock()
... ...
@@ -911,14 +916,15 @@ func (devices *DeviceSet) verifyBaseDeviceUUIDFS(baseInfo *devInfo) error {
911 911
 	// If user specified a filesystem using dm.fs option and current
912 912
 	// file system of base image is not same, warn user that dm.fs
913 913
 	// will be ignored.
914
-	if devices.userFilesystem != "" {
914
+	if devices.filesystem != "" {
915 915
 		fs, err := ProbeFsType(baseInfo.DevName())
916 916
 		if err != nil {
917 917
 			return err
918 918
 		}
919 919
 
920
-		if fs != devices.userFilesystem {
921
-			logrus.Warnf("Base device already exists and has filesystem %s on it. User specified filesystem %s will be ignored.", fs, devices.userFilesystem)
920
+		if fs != devices.filesystem {
921
+			logrus.Warnf("Base device already exists and has filesystem %s on it. User specified filesystem %s will be ignored.", fs, devices.filesystem)
922
+			devices.filesystem = fs
922 923
 		}
923 924
 	}
924 925
 	return nil
... ...
@@ -2268,6 +2274,7 @@ func (devices *DeviceSet) Status() *Status {
2268 2268
 	status.DeferredDeleteEnabled = devices.deferredDelete
2269 2269
 	status.DeferredDeletedDeviceCount = devices.nrDeletedDevices
2270 2270
 	status.BaseDeviceSize = devices.getBaseDeviceSize()
2271
+	status.BaseDeviceFS = devices.getBaseDeviceFS()
2271 2272
 
2272 2273
 	totalSizeInSectors, _, dataUsed, dataTotal, metadataUsed, metadataTotal, err := devices.poolStatus()
2273 2274
 	if err == nil {
... ...
@@ -2366,7 +2373,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
2366 2366
 			if val != "ext4" && val != "xfs" {
2367 2367
 				return nil, fmt.Errorf("Unsupported filesystem %s\n", val)
2368 2368
 			}
2369
-			devices.userFilesystem = val
2369
+			devices.filesystem = val
2370 2370
 		case "dm.mkfsarg":
2371 2371
 			devices.mkfsArgs = append(devices.mkfsArgs, val)
2372 2372
 		case "dm.mountopt":
... ...
@@ -80,7 +80,7 @@ func (d *Driver) Status() [][2]string {
80 80
 		{"Pool Name", s.PoolName},
81 81
 		{"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(float64(s.SectorSize)))},
82 82
 		{"Base Device Size", fmt.Sprintf("%s", units.HumanSize(float64(s.BaseDeviceSize)))},
83
-		{"Backing Filesystem", backingFs},
83
+		{"Backing Filesystem", s.BaseDeviceFS},
84 84
 		{"Data file", s.DataFile},
85 85
 		{"Metadata file", s.MetadataFile},
86 86
 		{"Data Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Used)))},