Skip to content

Commit e09764c

Browse files
cmaiolinobrauner
authored andcommitted
shmem: quota support
Now the basic infra-structure is in place, enable quota support for tmpfs. This offers user and group quotas to tmpfs (project quotas will be added later). Also, as other filesystems, the tmpfs quota is not supported within user namespaces yet, so idmapping is not translated. Signed-off-by: Lukas Czerner <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]> Reviewed-by: Jan Kara <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent eafc474 commit e09764c

File tree

3 files changed

+201
-8
lines changed

3 files changed

+201
-8
lines changed

Documentation/filesystems/tmpfs.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ sysfs file /sys/kernel/mm/transparent_hugepage/shmem_enabled: which can
123123
be used to deny huge pages on all tmpfs mounts in an emergency, or to
124124
force huge pages on all tmpfs mounts for testing.
125125

126+
tmpfs also supports quota with the following mount options
127+
128+
======== =============================================================
129+
quota User and group quota accounting and enforcement is enabled on
130+
the mount. Tmpfs is using hidden system quota files that are
131+
initialized on mount.
132+
usrquota User quota accounting and enforcement is enabled on the
133+
mount.
134+
grpquota Group quota accounting and enforcement is enabled on the
135+
mount.
136+
======== =============================================================
137+
138+
Note that tmpfs quotas do not support user namespaces so no uid/gid
139+
translation is done if quotas are enabled inside user namespaces.
140+
126141
tmpfs has a mount option to set the NUMA memory allocation policy for
127142
all files in that instance (if CONFIG_NUMA is enabled) - which can be
128143
adjusted on the fly via 'mount -o remount ...'

include/linux/shmem_fs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct shmem_inode_info {
3131
atomic_t stop_eviction; /* hold when working on inode */
3232
struct timespec64 i_crtime; /* file creation time */
3333
unsigned int fsflags; /* flags for FS_IOC_[SG]ETFLAGS */
34+
#ifdef CONFIG_TMPFS_QUOTA
35+
struct dquot *i_dquot[MAXQUOTAS];
36+
#endif
3437
struct inode vfs_inode;
3538
};
3639

@@ -184,4 +187,9 @@ extern int shmem_mfill_atomic_pte(pmd_t *dst_pmd,
184187
#define SHMEM_QUOTA_MAX_SPC_LIMIT 0x7fffffffffffffffLL /* 2^63-1 */
185188
#define SHMEM_QUOTA_MAX_INO_LIMIT 0x7fffffffffffffffLL
186189

190+
#ifdef CONFIG_TMPFS_QUOTA
191+
extern const struct dquot_operations shmem_quota_operations;
192+
extern struct quota_format_type shmem_quota_format;
193+
#endif /* CONFIG_TMPFS_QUOTA */
194+
187195
#endif

0 commit comments

Comments
 (0)