Difference between revisions of "Ploop/diskinodes"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (add 'translate' tags)
(Marked this version for translation)
Line 1: Line 1:
 
<translate>
 
<translate>
 +
<!--T:1-->
 
Everything you wanted to know about DISKINODES for ploop but were afraid to ask.
 
Everything you wanted to know about DISKINODES for ploop but were afraid to ask.
  
== Limitations ==
+
== Limitations == <!--T:2-->
  
 +
<!--T:3-->
 
With simfs layout, vzquota is used to set limits for DISKSPACE and
 
With simfs layout, vzquota is used to set limits for DISKSPACE and
 
DISKINODES, so these limits can be changed any time.
 
DISKINODES, so these limits can be changed any time.
  
 +
<!--T:4-->
 
Unlike simfs, ploop contains a real file system, so amount of disk space
 
Unlike simfs, ploop contains a real file system, so amount of disk space
 
and disk inodes are properties of the file system, determined while
 
and disk inodes are properties of the file system, determined while
Line 13: Line 16:
 
inodes.
 
inodes.
  
 +
<!--T:5-->
 
{{Note|There is no way to change DISKINODES for existing ploop. This is a limitation of ext4.}}
 
{{Note|There is no way to change DISKINODES for existing ploop. This is a limitation of ext4.}}
  
 +
<!--T:6-->
 
In other words, <code>vzctl set --diskinodes</code> is ignored for ploop layout -- it can only be specified on create.
 
In other words, <code>vzctl set --diskinodes</code> is ignored for ploop layout -- it can only be specified on create.
  
== Default value ==
+
== Default value == <!--T:7-->
  
 +
<!--T:8-->
 
By default, ext4 allocates 1 (one) inode per each 16 KB of data; this is
 
By default, ext4 allocates 1 (one) inode per each 16 KB of data; this is
 
practically the same as to assume that the average file size will be 16KB.
 
practically the same as to assume that the average file size will be 16KB.
  
 +
<!--T:9-->
 
For example, when creating a ploop with 40GB of disk space, 2621440 inodes
 
For example, when creating a ploop with 40GB of disk space, 2621440 inodes
 
will be available:
 
will be available:
  
 +
<!--T:10-->
 
<math>\frac{40 * 1024 * 1024}{16} = 2621440</math>
 
<math>\frac{40 * 1024 * 1024}{16} = 2621440</math>
  
== Increasing ==
+
== Increasing == <!--T:11-->
  
 +
<!--T:12-->
 
If the above default is too low for your usage (for example, a container
 
If the above default is too low for your usage (for example, a container
 
has or will have too many small files), you can specify a larger value
 
has or will have too many small files), you can specify a larger value
 
for DISKINODES '''during container creation or conversion only'''.
 
for DISKINODES '''during container creation or conversion only'''.
  
 +
<!--T:13-->
 
{{Note|The feature works since vzctl 4.7.}}
 
{{Note|The feature works since vzctl 4.7.}}
  
 +
<!--T:14-->
 
{{Note|You can only specify <code>--diskinodes</code> for <code>vzctl create</code> or <code>vzctl convert</code>.}}
 
{{Note|You can only specify <code>--diskinodes</code> for <code>vzctl create</code> or <code>vzctl convert</code>.}}
  
 +
<!--T:15-->
 
The way it works is the following. First, a file system big enough
 
The way it works is the following. First, a file system big enough
 
to accommodate the requested number of DISKINODES is created, and then
 
to accommodate the requested number of DISKINODES is created, and then
Line 42: Line 54:
 
requested amount of DISKSPACE.
 
requested amount of DISKSPACE.
  
 +
<!--T:16-->
 
Example:
 
Example:
  
  vzctl create 123 --diskspace 40G --diskinodes 5242880
+
  <!--T:17-->
 +
vzctl create 123 --diskspace 40G --diskinodes 5242880
  
 +
<!--T:18-->
 
Here, a filesystem big enough to have 5242880 of diskinodes
 
Here, a filesystem big enough to have 5242880 of diskinodes
 
will be created (it's 5242880 * 16K = 80G), then downsized to 40G.
 
will be created (it's 5242880 * 16K = 80G), then downsized to 40G.
  
== Issues ==
+
== Issues == <!--T:19-->
  
=== Too high DISKINODES value ===
+
=== Too high DISKINODES value === <!--T:20-->
  
 +
<!--T:21-->
 
Sometimes, when the amount of DISKINODES specified is too high,
 
Sometimes, when the amount of DISKINODES specified is too high,
 
a very large filesystem is created, and it can not be downsized
 
a very large filesystem is created, and it can not be downsized
Line 58: Line 74:
 
shown when converting a container from simfs to ploop:
 
shown when converting a container from simfs to ploop:
  
  vzctl set ''CTID'' --diskspace  40G --diskinodes 1000000000 --save
+
  <!--T:22-->
 +
vzctl set ''CTID'' --diskspace  40G --diskinodes 1000000000 --save
 
  ...
 
  ...
 
  vzctl convert ''CTID''
 
  vzctl convert ''CTID''
Line 67: Line 84:
 
  Failed to resize image: Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144 [38]
 
  Failed to resize image: Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144 [38]
  
 +
<!--T:23-->
 
In this case, 1G inodes requirement leads to creation of 16TB filesystem
 
In this case, 1G inodes requirement leads to creation of 16TB filesystem
 
(remember, 1 inode per 16K). Unfortunately, such huge FS can't be downsized
 
(remember, 1 inode per 16K). Unfortunately, such huge FS can't be downsized
Line 72: Line 90:
 
the error message are in sectors which are 512 bytes each).
 
the error message are in sectors which are 512 bytes each).
  
 +
<!--T:24-->
 
'''Solution 1''': please be reasonable when requesting diskinodes for ploop.  
 
'''Solution 1''': please be reasonable when requesting diskinodes for ploop.  
  
 +
<!--T:25-->
 
'''Solution 2''': please set DISKINODES to 0 before conversion:
 
'''Solution 2''': please set DISKINODES to 0 before conversion:
  
  vzctl stop ''CTID''
+
  <!--T:26-->
 +
vzctl stop ''CTID''
 
  vzctl set ''CTID'' --diskspace ''xxx''G--diskinodes 0 --save
 
  vzctl set ''CTID'' --diskspace ''xxx''G--diskinodes 0 --save
 
  vzctl convert ''CTID''
 
  vzctl convert ''CTID''
  
 +
<!--T:27-->
 
This will lead to creating a filesystem with default number of inodes.
 
This will lead to creating a filesystem with default number of inodes.
  
=== Too low DISKINODES value ===
+
=== Too low DISKINODES value === <!--T:28-->
  
 +
<!--T:29-->
 
If DISKINODES specified during <code>create</code> or <code>convert</code> is
 
If DISKINODES specified during <code>create</code> or <code>convert</code> is
 
lower than the default (1 inode per 16K of disk space), it is silently ignored.
 
lower than the default (1 inode per 16K of disk space), it is silently ignored.
 
In other words, there is no way to limit DISKINODES to lower than DISKSPACE / 16384.
 
In other words, there is no way to limit DISKINODES to lower than DISKSPACE / 16384.
  
== See also ==
+
== See also == <!--T:30-->
 
* {{git commit|vzctl|ef320d32a4}}
 
* {{git commit|vzctl|ef320d32a4}}
 
* https://lists.openvz.org/pipermail/users/2014-October/005913.html
 
* https://lists.openvz.org/pipermail/users/2014-October/005913.html

Revision as of 08:42, 26 December 2015

<translate> Everything you wanted to know about DISKINODES for ploop but were afraid to ask.

Limitations

With simfs layout, vzquota is used to set limits for DISKSPACE and DISKINODES, so these limits can be changed any time.

Unlike simfs, ploop contains a real file system, so amount of disk space and disk inodes are properties of the file system, determined while creating a filesystem. It is possible to resize an ext4 file system in terms of disk space, but there's no way to change the number of available inodes.

Yellowpin.svg Note: There is no way to change DISKINODES for existing ploop. This is a limitation of ext4.

In other words, vzctl set --diskinodes is ignored for ploop layout -- it can only be specified on create.

Default value

By default, ext4 allocates 1 (one) inode per each 16 KB of data; this is practically the same as to assume that the average file size will be 16KB.

For example, when creating a ploop with 40GB of disk space, 2621440 inodes will be available:

Increasing

If the above default is too low for your usage (for example, a container has or will have too many small files), you can specify a larger value for DISKINODES during container creation or conversion only.

Yellowpin.svg Note: The feature works since vzctl 4.7.
Yellowpin.svg Note: You can only specify --diskinodes for vzctl create or vzctl convert.

The way it works is the following. First, a file system big enough to accommodate the requested number of DISKINODES is created, and then ploop resize is performed to downsize the file system to meet the requested amount of DISKSPACE.

Example:

vzctl create 123 --diskspace 40G --diskinodes 5242880

Here, a filesystem big enough to have 5242880 of diskinodes will be created (it's 5242880 * 16K = 80G), then downsized to 40G.

Issues

Too high DISKINODES value

Sometimes, when the amount of DISKINODES specified is too high, a very large filesystem is created, and it can not be downsized to a specified amount. In this case, the following error will be shown when converting a container from simfs to ploop:

vzctl set CTID --diskspace 40G --diskinodes 1000000000 --save

...
vzctl convert CTID
...
Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144
Unmounting file system at /vz/private/101.ploop/root.hdd/root.hdd.mnt
Unmounting device /dev/ploop37776
Failed to resize image: Error in ploop_resize_image (ploop.c:2477): Unable to change image size to 83877888 sectors, minimal size is 502423144 [38]

In this case, 1G inodes requirement leads to creation of 16TB filesystem (remember, 1 inode per 16K). Unfortunately, such huge FS can't be downsized to as low as 40G, the minimum seems to be around 240G (values printed in the error message are in sectors which are 512 bytes each).

Solution 1: please be reasonable when requesting diskinodes for ploop.

Solution 2: please set DISKINODES to 0 before conversion:

vzctl stop CTID

vzctl set CTID --diskspace xxxG--diskinodes 0 --save
vzctl convert CTID

This will lead to creating a filesystem with default number of inodes.

Too low DISKINODES value

If DISKINODES specified during create or convert is lower than the default (1 inode per 16K of disk space), it is silently ignored. In other words, there is no way to limit DISKINODES to lower than DISKSPACE / 16384.

See also

</translate>