Support for ext4 as default filesystem for ephemeral disks

The ext3 filesystem does orders of magnitude more I/O than ext4 in
mkfs - a brief benchmark showed 14m to make a 1TB ext3 filesystem
vs 7 seconds to make a 1TB ext4 filesystem, with the ext3 filesystem
doing upwards of 6GB I/O.

Since ext4 has been a default in all major Linux distributions for
a long time now - RHEL5 has it as default, for instance - there is
no reason to default to ext3: users that need ext3 can configure
that themselves. So the default now is ext4 for all linux with
this commit. Also note that for non-linux and non-windows
the default used to be ext3, now it is vfat.

Note that there is still support for ext3 as the default if some
deployers do choose to keep that as the default, by using either
virt_mkfs or default_ephemeral_format configuration option. We
are just trying to move the default for everyone who is starting
fresh.

Originally logged by lifeless as I833356af81df743a63d4442d389be82bc25f3914,
reverted in I8de225729bbc77b263fcac2fa72b0e9cc6c1b2bf by phil and re-proposed
by swapnil in Ibe9e9ba4265125c5bd933cde1a93cca02511bb46

DocImpact

Closes-Bug: #1266262
Change-Id: I92cb51c6118e48fd66ada0e2fee624597c4ad8f0
This commit is contained in:
Davanum Srinivas
2014-12-17 13:37:43 -05:00
committed by Davanum Srinivas
parent 2ff55736ee
commit 7517108e7a
5 changed files with 42 additions and 28 deletions

View File

@@ -168,6 +168,7 @@ touch: CommandFilter, touch, root
# nova/virt/disk/api.py:
mkfs.ext3: CommandFilter, mkfs.ext3, root
mkfs.ext4: CommandFilter, mkfs.ext4, root
mkfs.ntfs: CommandFilter, mkfs.ntfs, root
# nova/virt/libvirt/connection.py:

View File

@@ -160,16 +160,15 @@ class APITestCase(test.NoDBTestCase):
self.mox.ReplayAll()
api.extend(imgfile, imgsize, use_cow=use_cow)
HASH_EXT3 = utils.get_hash_str(api.FS_FORMAT_EXT3)[:7]
HASH_VFAT = utils.get_hash_str(api.FS_FORMAT_VFAT)[:7]
HASH_EXT4 = utils.get_hash_str(api.FS_FORMAT_EXT4)[:7]
HASH_NTFS = utils.get_hash_str(api.FS_FORMAT_NTFS)[:7]
def test_get_file_extension_for_os_type(self):
self.assertEqual(self.HASH_EXT3,
api.get_file_extension_for_os_type(
None, None))
self.assertEqual(self.HASH_EXT3,
api.get_file_extension_for_os_type(
'linux', None))
self.assertEqual(self.HASH_VFAT,
api.get_file_extension_for_os_type(None, None))
self.assertEqual(self.HASH_EXT4,
api.get_file_extension_for_os_type('linux', None))
self.assertEqual(self.HASH_NTFS,
api.get_file_extension_for_os_type(
'windows', None))
@@ -184,14 +183,14 @@ class APITestCase(test.NoDBTestCase):
api.get_file_extension_for_os_type(
'windows', None))
self.assertEqual("a74d253",
api.get_file_extension_for_os_type(
'osx', None))
api.get_file_extension_for_os_type('osx', None))
with mock.patch.dict(api._MKFS_COMMAND,
{'osx': 'custom mkfs command'}, clear=True):
self.assertEqual(self.HASH_EXT3,
api.get_file_extension_for_os_type(
'linux', None))
self.assertEqual(self.HASH_VFAT,
api.get_file_extension_for_os_type(None, None))
self.assertEqual(self.HASH_EXT4,
api.get_file_extension_for_os_type('linux', None))
self.assertEqual(self.HASH_NTFS,
api.get_file_extension_for_os_type(
'windows', None))

View File

@@ -68,7 +68,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
def test_volume_in_mapping(self):
swap = {'device_name': '/dev/sdb',
'swap_size': 1}
ephemerals = [{'device_type': 'disk', 'guest_format': 'ext3',
ephemerals = [{'device_type': 'disk', 'guest_format': 'ext4',
'device_name': '/dev/sdc1', 'size': 10},
{'disk_bus': 'ide', 'guest_format': None,
'device_name': '/dev/sdd', 'size': 10}]
@@ -372,7 +372,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
block_device_info = {
'ephemerals': [
{'device_type': 'disk', 'guest_format': 'ext3',
{'device_type': 'disk', 'guest_format': 'ext4',
'device_name': '/dev/vdb', 'size': 10},
{'disk_bus': 'ide', 'guest_format': None,
'device_name': '/dev/vdc', 'size': 10},
@@ -389,7 +389,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
'disk': {'bus': 'virtio', 'dev': 'vda',
'type': 'disk', 'boot_index': '1'},
'disk.eph0': {'bus': 'virtio', 'dev': 'vdb',
'type': 'disk', 'format': 'ext3'},
'type': 'disk', 'format': 'ext4'},
'disk.eph1': {'bus': 'ide', 'dev': 'vdc', 'type': 'disk'},
'disk.eph2': {'bus': 'virtio', 'dev': 'vdd', 'type': 'floppy'},
'disk.swap': {'bus': 'virtio', 'dev': 'vde', 'type': 'disk'},
@@ -525,7 +525,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
'swap': {'device_name': '/dev/vdy',
'swap_size': 10},
'ephemerals': [
{'device_type': 'disk', 'guest_format': 'ext3',
{'device_type': 'disk', 'guest_format': 'ext4',
'device_name': '/dev/vdb', 'size': 10},
{'disk_bus': 'ide', 'guest_format': None,
'device_name': '/dev/vdc', 'size': 10},
@@ -548,7 +548,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
'/dev/vda': {'bus': 'virtio', 'dev': 'vda',
'type': 'disk', 'boot_index': '2'},
'disk.eph0': {'bus': 'virtio', 'dev': 'vdb',
'type': 'disk', 'format': 'ext3'},
'type': 'disk', 'format': 'ext4'},
'disk.eph1': {'bus': 'ide', 'dev': 'vdc', 'type': 'disk'},
'disk.swap': {'bus': 'virtio', 'dev': 'vdy', 'type': 'disk'},
'root': {'bus': 'virtio', 'dev': 'vdf',
@@ -672,7 +672,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
def test_get_info_from_bdm(self):
bdms = [{'device_name': '/dev/vds', 'device_type': 'disk',
'disk_bus': 'usb', 'swap_size': 4},
{'device_type': 'disk', 'guest_format': 'ext3',
{'device_type': 'disk', 'guest_format': 'ext4',
'device_name': '/dev/vdb', 'size': 2},
{'disk_bus': 'ide', 'guest_format': None,
'device_name': '/dev/vdc', 'size': 3},
@@ -690,7 +690,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
'delete_on_termination': True}]
expected = [{'dev': 'vds', 'type': 'disk', 'bus': 'usb'},
{'dev': 'vdb', 'type': 'disk',
'bus': 'virtio', 'format': 'ext3'},
'bus': 'virtio', 'format': 'ext4'},
{'dev': 'vdc', 'type': 'disk', 'bus': 'ide'},
{'dev': 'sdr', 'type': 'cdrom',
'bus': 'scsi', 'boot_index': '1'},
@@ -814,7 +814,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
'/dev/fda': {'bus': 'fdc', 'dev': 'fda',
'type': 'floppy', 'boot_index': '2'},
'disk.eph0': {'bus': 'virtio', 'dev': 'vdb',
'type': 'disk', 'format': 'ext3'},
'type': 'disk', 'format': 'ext4'},
'disk.eph1': {'bus': 'ide', 'dev': 'vdc', 'type': 'disk'},
'disk.swap': {'bus': 'virtio', 'dev': 'vdy', 'type': 'disk'},
'root': {'bus': 'virtio', 'dev': 'vdf',

View File

@@ -444,7 +444,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
REQUIRES_LOCKING = True
_EPHEMERAL_20_DEFAULT = ('ephemeral_20_%s' %
utils.get_hash_str('ext3')[:7])
utils.get_hash_str(disk._DEFAULT_FILE_SYSTEM)[:7])
def setUp(self):
super(LibvirtConnTestCase, self).setUp()
@@ -7307,7 +7307,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.stubs.Set(drvr, 'get_info', fake_get_info)
if mkfs:
self.stubs.Set(nova.virt.disk.api, '_MKFS_COMMAND',
{os_type: 'mkfs.ext3 --label %(fs_label)s %(target)s'})
{os_type: 'mkfs.ext4 --label %(fs_label)s %(target)s'})
image_meta = {'id': instance['image_ref']}
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
@@ -7342,7 +7342,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
def test_create_image_plain_os_type_set_with_fs(self):
ephemeral_file_name = ('ephemeral_20_%s' % utils.get_hash_str(
'mkfs.ext3 --label %(fs_label)s %(target)s')[:7])
'mkfs.ext4 --label %(fs_label)s %(target)s')[:7])
self._test_create_image_plain(os_type='test',
filename=ephemeral_file_name,
@@ -7451,7 +7451,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
def test_create_ephemeral_default(self):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.mox.StubOutWithMock(utils, 'execute')
utils.execute('mkfs', '-t', 'ext3', '-F', '-L', 'myVol',
utils.execute('mkfs', '-t', 'ext4', '-F', '-L', 'myVol',
'/dev/something', run_as_root=True)
self.mox.ReplayAll()
drvr._create_ephemeral('/dev/something', 20, 'myVol', 'linux',
@@ -7468,6 +7468,17 @@ class LibvirtConnTestCase(test.NoDBTestCase):
is_block_dev=True)
def test_create_ephemeral_with_arbitrary(self):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.stubs.Set(nova.virt.disk.api, '_MKFS_COMMAND',
{'linux': 'mkfs.ext4 --label %(fs_label)s %(target)s'})
self.mox.StubOutWithMock(utils, 'execute')
utils.execute('mkfs.ext4', '--label', 'myVol', '/dev/something',
run_as_root=True)
self.mox.ReplayAll()
drvr._create_ephemeral('/dev/something', 20, 'myVol', 'linux',
is_block_dev=True)
def test_create_ephemeral_with_ext3(self):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.stubs.Set(nova.virt.disk.api, '_MKFS_COMMAND',
{'linux': 'mkfs.ext3 --label %(fs_label)s %(target)s'})

View File

@@ -51,7 +51,7 @@ disk_opts = [
# NOTE(yamahata): ListOpt won't work because the command may include a
# comma. For example:
#
# mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16
# mkfs.ext4 -O dir_index,extent -E stride=8,stripe-width=16
# --label %(fs_label)s %(target)s
#
# list arguments are comma separated and there is no way to
@@ -90,7 +90,8 @@ SUPPORTED_FS_TO_EXTEND = (
FS_FORMAT_EXT3,
FS_FORMAT_EXT4)
_DEFAULT_FS_BY_OSTYPE = {'linux': FS_FORMAT_EXT3,
_DEFAULT_FILE_SYSTEM = FS_FORMAT_VFAT
_DEFAULT_FS_BY_OSTYPE = {'linux': FS_FORMAT_EXT4,
'windows': FS_FORMAT_NTFS}
for s in CONF.virt_mkfs:
@@ -115,7 +116,8 @@ def get_file_extension_for_os_type(os_type, specified_fs=None):
if not specified_fs:
specified_fs = CONF.default_ephemeral_format
if not specified_fs:
specified_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type, 'ext3')
specified_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type,
_DEFAULT_FILE_SYSTEM)
extension = specified_fs
return utils.get_hash_str(extension)[:7]
@@ -137,7 +139,8 @@ def mkfs(os_type, fs_label, target, run_as_root=True, specified_fs=None):
if not specified_fs:
specified_fs = CONF.default_ephemeral_format
if not specified_fs:
specified_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type, 'ext3')
specified_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type,
_DEFAULT_FILE_SYSTEM)
utils.mkfs(specified_fs, target, fs_label, run_as_root=run_as_root)