Re: [PATCH 1/3] tmpfs: add project ID support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 25-09-23 15:00:26, cem@xxxxxxxxxx wrote:
> From: Carlos Maiolino <cem@xxxxxxxxxx>
> 
> Lay down infrastructure to support project quotas.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx>
> ---
>  include/linux/shmem_fs.h | 11 ++++++++---
>  mm/shmem.c               |  6 ++++++
>  mm/shmem_quota.c         | 10 ++++++++++
>  3 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index 6b0c626620f5..e82a64f97917 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -15,7 +15,10 @@
>  
>  #ifdef CONFIG_TMPFS_QUOTA
>  #define SHMEM_MAXQUOTAS 2
> -#endif
> +
> +/* Default project ID */
> +#define SHMEM_DEF_PROJID 0
> +#endif /* CONFIG_TMPFS_QUOTA */
>  
>  struct shmem_inode_info {
>  	spinlock_t		lock;
> @@ -33,14 +36,16 @@ struct shmem_inode_info {
>  	unsigned int		fsflags;	/* flags for FS_IOC_[SG]ETFLAGS */
>  #ifdef CONFIG_TMPFS_QUOTA
>  	struct dquot		*i_dquot[MAXQUOTAS];
> +	kprojid_t		i_projid;
>  #endif

I'm not sure it is great to bind project ID support with CONFIG_TMPFS_QUOTA
and in particular with sb_has_quota_active(sb, PRJQUOTA). It seems as a bit
unnatural restriction that could confuse administrators.

>  	struct offset_ctx	dir_offsets;	/* stable entry offsets */
>  	struct inode		vfs_inode;
>  };
>  
> -#define SHMEM_FL_USER_VISIBLE		FS_FL_USER_VISIBLE
> +#define SHMEM_FL_USER_VISIBLE		(FS_FL_USER_VISIBLE | FS_PROJINHERIT_FL)
>  #define SHMEM_FL_USER_MODIFIABLE \
> -	(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL)
> +	(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | \
> +	 FS_NOATIME_FL | FS_PROJINHERIT_FL)
>  #define SHMEM_FL_INHERITED		(FS_NODUMP_FL | FS_NOATIME_FL)
>  
>  struct shmem_quota_limits {
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 67d93dd37a5e..6ccf60bd1690 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2539,6 +2539,12 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
>  	if (IS_ERR(inode))
>  		return inode;
>  
> +	if (dir && sb_has_quota_active(sb, PRJQUOTA))
> +		SHMEM_I(inode)->i_projid = SHMEM_I(dir)->i_projid;
> +	else
> +		SHMEM_I(inode)->i_projid = make_kprojid(&init_user_ns,
> +							SHMEM_DEF_PROJID);
> +
>  	err = dquot_initialize(inode);
>  	if (err)
>  		goto errout;
> diff --git a/mm/shmem_quota.c b/mm/shmem_quota.c
> index 062d1c1097ae..71224caa3e85 100644
> --- a/mm/shmem_quota.c
> +++ b/mm/shmem_quota.c
> @@ -325,6 +325,15 @@ static int shmem_dquot_write_info(struct super_block *sb, int type)
>  	return 0;
>  }
>  
> +static int shmem_get_projid(struct inode *inode, kprojid_t *projid)
> +{
> +	if (!sb_has_quota_active(inode->i_sb, PRJQUOTA))
> +		return -EOPNOTSUPP;

This is not needed as quota code ever calls ->get_projid only when project
quotas are enabled...

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux