On 2025-02-21 20:33:21 +0100, Salvatore Bonaccorso wrote:[...]
[...]So size is only showed if sbinfo->max_blocks != shmem_default_max_blocks().
Let's look at shmem_default_max_blocks():
147 #ifdef CONFIG_TMPFS
148 static unsigned long shmem_default_max_blocks(void)
149 {
150 return totalram_pages() / 2;
151 }
[...]size=bytes
^^^^^^^^^^^^The size may also have a % suffix to limit this instance
to a percentage of physical RAM.
Let's start from:
https://www.kernel.org/doc/html/latest/filesystems/vfs.html#mount-options
The important bits are:
Showing options
---------------
If a filesystem accepts mount options, it must define show_options() to
show all the currently active options. The rules are:
- options MUST be shown which are not default or their values differ
from the default
- options MAY be shown which are enabled by default or have their
default value
tmpfs is defined in "mm/shmem.c and we have (current mainline):
5263 #ifdef CONFIG_TMPFS
5264 .statfs = shmem_statfs,
5265 .show_options = shmem_show_options,
5266 #endif
shmem_show_options() handles showming mount options for tmpfs:
4878 static int shmem_show_options(struct seq_file *seq, struct dentry *root) 4879 {
4880 struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb);
4881 struct mempolicy *mpol;
4882
4883 if (sbinfo->max_blocks != shmem_default_max_blocks())
4884 seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks)); [...]
So size is only showed if sbinfo->max_blocks != shmem_default_max_blocks().
Let's look at shmem_default_max_blocks():
147 #ifdef CONFIG_TMPFS
148 static unsigned long shmem_default_max_blocks(void)
149 {
150 return totalram_pages() / 2;
151 }
So this is 50% of ram as *default* which matches tmpfs(5):
Mount options
The tmpfs filesystem supports the following mount options:
size=bytes
Specify an upper limit on the size of the filesystem.
The size is given in bytes, and rounded up to entire
pages. The limit is removed if the size is 0.
The size may have a k, m, or g suffix for Ki, Mi, Gi (biâ€
nary kilo (kibi), binary mega (mebi), and binary giga
(gibi)).
The size may also have a % suffix to limit this instance
to a percentage of physical RAM.
The default, when neither size nor nr_blocks is speciâ€
fied, is size=50%.
So my undestanding would be that the code here is coherent with the specification that if size corresponds to the default value, the code
may, but does not must show it.
Does this make sense?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 480 |
Nodes: | 16 (2 / 14) |
Uptime: | 01:58:33 |
Calls: | 9,534 |
Calls today: | 2 |
Files: | 13,651 |
Messages: | 6,138,363 |
Posted today: | 1 |