fs: new interface and behavior for file project id
Subsystems (8)
RFC PATCH 1/6 fs: new interface and behavior for file project id
For now project id and quotas are implemented only in XFS. Existing behavior isn't very useful: any unprivileged user can set any project id for its own files and this way he can bypass project limits.
XFS interface for getting or changing file project is a very XFS-centric:
ioctl XFS_IOC_FSGET/SETXATTR with structure (struct fsxattr) as a argument which has three unrelated fields and twelve reserved padding bytes. Idea of keeping XFS-compatible interface seems overpriced. Old tools checks filesystem name/magic thus without update they anyway will work only for XFS.
This patch defines common interface and new behavior. Depending on sysctl fs.protected_projects = 0|1 projects works as:
0 = XFS-compatible projects
- changing project id could be performed only from init user-ns
- file owner or task with CAP_FOWNER can set any project id
- changing user-ns project-id mapping allowed for everybody
- cross-project hardlinks and renaming are forbidden (-EXDEV)
- new inodes inherits project id from directory if flag XFS_DIFLAG_PROJINHERIT is set for directory inode
1 = Protected projects
- changing project id requires CAP_SYS_RESOURCE in current user-ns
- changing project id mapping require CAP_SYS_RESOURCE in parent user-ns
- cross-project hardlinks and renaming are permitted if current task has CAP_SYS_RESOURCE in current user-namespace or if directory project is mapped to zero in current user-namespace.
- new inodes always inherits project id from directory
Now project id is more sticky and cross-project sharing is more flexible. User-namespace project mapping defines set of project ids which could be used inside, if it's empty then container cannot change project id at all.
CONFIG_PROTECTED_PROJECTS_BY_DEFAULT defines default value for sysctl.
This patch adds two new fcntls:
int fcntl(fd, F_GET_PROJECT, projid_t *);
int fcntl(fd, F_SET_PROJECT, projid_t);
Permissions:F_GET_PROJECT is permitted for everybody but if file project isn't mapped into current user-namespace -EACCESS will be returned.
F_SET_PROJECT: depending on state of sysctl fs.protected_projects allowed either for file owner and CAP_FOWNER or requires capability CAP_SYS_RESOURCE.
Error codes:
EINVAL - not implemented in this kernel EPERM - not permitted/supported by this filesystem type ENOTSUPP - not supported for this filesystem instance (no feature at sb) EACCES - not enough permissions or project id isn't mapped
Project id is stored in fs-specific inode and exposed via couple super-block
operations: get_projid / set_projid. This have to be sb-operations because dquot_initialize() could be called before setting inode->i_op.
--- Documentation/filesystems/Locking | 4 ++ Documentation/filesystems/vfs.txt | 10 ++++++ fs/fcntl.c | 65 +++++++++++++++++++++++++++++++++++++ fs/quota/Kconfig | 9 +++++ include/linux/fs.h | 4 ++ include/linux/projid.h | 4 ++ include/uapi/linux/fcntl.h | 6 +++ kernel/capability.c | 62 +++++++++++++++++++++++++++++++++++ kernel/sysctl.c | 9 +++++ kernel/user_namespace.c | 4 +- 10 files changed, 175 insertions(+), 2 deletions(-)
Documentation/filesystems/Locking +4 -0
@@ -125,6 +125,8 @@ prototypes: int (*show_options)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); + int (*get_projid) (struct inode *, kprojid_t *); + int (*set_projid) (struct inode *, kprojid_t); int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); locking rules:
@@ -147,6 +149,8 @@ show_options: no (namespace_sem) quota_read: no (see below) quota_write: no (see below) bdev_try_to_free_page: no (see below) +get_projid no (maybe i_mutex) +set_projid no (i_mutex) ->statfs() has s_umount (shared) when called by ustat(2) (native or compat), but that's an accident of bad API; s_umount is used to pin
Documentation/filesystems/vfs.txt +10 -0
@@ -228,6 +228,10 @@ struct super_operations { ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); + + int (*get_projid) (struct inode *, kprojid_t *); + int (*set_projid) (struct inode *, kprojid_t); + int (*nr_cached_objects)(struct super_block *); void (*free_cached_objects)(struct super_block *, int); };
@@ -319,6 +323,12 @@ or bottom half). implementations will cause holdoff problems due to large scan batch sizes. + get_projid: called by the VFS and quota to get project id of a inode. + This method is called by fcntl() and project quota management. + + set_projid: called by the VFS to set project if of a inode. + This method is called by fcntl() with i_mutex locked. + Whoever sets up the inode is responsible for filling in the "i_op" field. This is a pointer to a "struct inode_operations" which describes the methods that can be performed on individual inodes.
fs/fcntl.c +65 -0
89 lines not on this page · raw message
fs/quota/Kconfig +9 -0
@@ -74,3 +74,12 @@ config QUOTACTL_COMPAT bool depends on QUOTACTL && COMPAT_FOR_U64_ALIGNMENT default y + +config PROTECTED_PROJECTS_ENABLED_BY_DEFAULT + bool "Protected projects by default" + default n + help + This option defines default value for sysctl fs.protected_projects. + Say N if you need XFS-compatible mode when file owner could set any + project id. If you need reliable project disk quotas say Y here: + in this mode changing project requires capability CAP_SYS_RESOURCE.
include/linux/fs.h +4 -0
@@ -27,6 +27,7 @@#include <linux/shrinker.h> #include <linux/migrate_mode.h> #include <linux/uidgid.h> +#include <linux/projid.h> #include <linux/lockdep.h> #include <linux/percpu-rwsem.h> #include <linux/blk_types.h>
@@ -62,6 +63,7 @@ extern struct inodes_stat_t inodes_stat;extern int leases_enable, lease_break_time;extern int sysctl_protected_symlinks;extern int sysctl_protected_hardlinks; +extern int sysctl_protected_projects;struct buffer_head ; typedef int (get_block_t)(struct inode *inode, sector_t iblock,
@@ -1636,6 +1638,8 @@ struct super_operations {int (*bdev_try_to_free_page)(struct super_block *,struct page *,gfp_t );long (*nr_cached_objects)(struct super_block *,int );long (*free_cached_objects)(struct super_block *,long ,int ); +int (*get_projid)(struct inode *,kprojid_t *); +int (*set_projid)(struct inode *,kprojid_t ); };/*
include/linux/projid.h +4 -0
@@ -86,4 +86,8 @@ static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t proj#endif /* CONFIG_USER_NS */ +bool capable_set_inode_project (const struct inode *inode, +kprojid_t old_kprojid,kprojid_t kprojid); +bool capable_mix_inode_project (kprojid_t dir_kprojid,kprojid_t kprojid); +#endif /* _LINUX_PROJID_H */
include/uapi/linux/fcntl.h +6 -0
@@ -34,6 +34,12 @@#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)/* +* Get/Set project id +*/ +#define F_GET_PROJECT (F_LINUX_SPECIFIC_BASE + 11) +#define F_SET_PROJECT (F_LINUX_SPECIFIC_BASE + 12) + +/* * Types of seals */ #define F_SEAL_SEAL 0x0001/* prevent further seals from being set */
kernel/capability.c +62 -0
65 lines not on this page · raw message
kernel/sysctl.c +9 -0
@@ -1649,6 +1649,15 @@ static struct ctl_table fs_table[] = { .extra2 = &one, }, { + .procname = "protected_projects", + .data = &sysctl_protected_projects, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one, + }, + { .procname = "suid_dumpable", .data = &suid_dumpable, .maxlen = sizeof(int),
kernel/user_namespace.c +2 -2
@@ -807,8 +807,8 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf,if ((seq_ns != ns) && (seq_ns != ns->parent))return -EPERM ; -/* Anyone can set any valid project id no capability needed */ -return map_write (file, buf, size, ppos,-1 , +return map_write (file, buf, size, ppos, + sysctl_protected_projects ?CAP_SYS_RESOURCE :-1 , &ns->projid_map, &ns->parent->projid_map); }
RFC PATCH 2/6 quota: adds generic code for enforcing project quota limits
This patch adds support for a new quota type PRJQUOTA for project quota. [ Based on patch by Li Xi <[email protected]> ]
Permissions:Q_GETQUOTA: allows to query all projects present in current user-namespaceQ_SETQUOTA: requires system-wide capability CAP_SYS_ADMIN
--- fs/quota/dquot.c | 37 +++++++++++++++++++++++++++++++++++-- fs/quota/quota.c | 8 ++++++-- fs/quota/quotaio_v2.h | 6 ++++-- include/linux/quota.h | 1 + include/linux/quotaops.h | 1 + include/uapi/linux/quota.h | 6 ++++-- 6 files changed, 51 insertions(+), 8 deletions(-)
fs/quota/dquot.c +35 -2
@@ -1159,8 +1159,8 @@ static int need_print_warning(struct dquot_warn *warn)return uid_eq (current_fsuid (), warn->w_dq_id.uid);case GRPQUOTA :return in_group_p (warn->w_dq_id.gid); -case PRJQUOTA :/* Never taken... Just make gcc happy */ -return 0 ; +case PRJQUOTA : +return 1 ; }return 0 ; }
@@ -1399,6 +1399,8 @@ static void __dquot_initialize(struct inode *inode, int type)/* First get references to structures we might need. */ for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) {struct kqid qid; +kprojid_t projid; + got[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;
@@ -1409,6 +1411,10 @@ static void __dquot_initialize(struct inode *inode, int type)*/ if (i_dquot (inode)[cnt])continue ; + +if (!sb_has_quota_active (sb, cnt)) +continue ; + init_needed =1 ;switch (cnt) {
@@ -1418,6 +1424,13 @@ static void __dquot_initialize(struct inode *inode, int type)case GRPQUOTA : qid =make_kqid_gid (inode->i_gid);break ; +case PRJQUOTA : +if (!sb->s_op->get_projid) +continue ; +if (sb->s_op->get_projid (inode, &projid)) +continue ; + qid =make_kqid_projid (projid); +break ; } got[cnt] =dqget (sb, qid); }
@@ -1951,6 +1964,22 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)EXPORT_SYMBOL (dquot_transfer);/* +* Helper function for transferring inode into another project. +*/ +int dquot_transfer_project (struct inode *inode,kprojid_t projid) +{ +struct dquot *transfer_to[MAXQUOTAS ] = {}; +struct super_block *sb = inode->i_sb; +int ret; + + transfer_to[PRJQUOTA ] =dqget (sb,make_kqid_projid (projid)); + ret =__dquot_transfer (inode, transfer_to); +dqput_all (transfer_to); +return ret; +} +EXPORT_SYMBOL (dquot_transfer_project); + +/* * Write info of quota file to disk */ int dquot_commit_info (struct super_block *sb,int type)
@@ -2165,6 +2194,10 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, error = -EINVAL ; goto out_fmt; } +if (type ==PRJQUOTA && !sb->s_op->get_projid) { + error = -EINVAL ; + goto out_fmt; + }/* Usage always has to be set... */ if (!(flags &DQUOT_USAGE_ENABLED )) { error = -EINVAL ;
fs/quota/quota.c +6 -2
@@ -30,11 +30,15 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,case Q_XGETQSTATV :case Q_XQUOTASYNC :break ; -/* allow to query information for dquots we "own" */ +/* +* Allow to query information for user/group dquots we "own". +* Allow querying project quota present in our user-namespace. +*/ case Q_GETQUOTA :case Q_XGETQUOTA :if ((type ==USRQUOTA &&uid_eq (current_euid (),make_kuid (current_user_ns (), id))) || - (type ==GRPQUOTA &&in_egroup_p (make_kgid (current_user_ns (), id)))) + (type ==GRPQUOTA &&in_egroup_p (make_kgid (current_user_ns (), id))) || + (type ==PRJQUOTA &&projid_valid (make_kprojid (current_user_ns (), id))))break ;/*FALLTHROUGH*/ default :
fs/quota/quotaio_v2.h +4 -2
@@ -13,12 +13,14 @@*/ #define V2_INITQMAGICS {\ 0xd9c01f11,/* USRQUOTA */ \ - 0xd9c01927 /* GRPQUOTA */\ + 0xd9c01927, /* GRPQUOTA */\ + 0xd9c03f14, /* PRJQUOTA */\ } #define V2_INITQVERSIONS {\ 1, /* USRQUOTA */\ -1 /* GRPQUOTA */ \ + 1, /* GRPQUOTA */\ + 1, /* PRJQUOTA */\ } /* First generic header */
include/linux/quota.h +1 -0
@@ -50,6 +50,7 @@#undef USRQUOTA#undef GRPQUOTA +#undef PRJQUOTAenum quota_type {USRQUOTA =0 ,/* element used for user quotas */ GRPQUOTA =1 ,/* element used for group quotas */
include/linux/quotaops.h +1 -0
@@ -104,6 +104,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,int __dquot_transfer (struct inode *inode,struct dquot **transfer_to);int dquot_transfer (struct inode *inode,struct iattr *iattr); +int dquot_transfer_project (struct inode *inode,kprojid_t projid);static inline struct mem_dqinfo *sb_dqinfo (struct super_block *sb,int type) {
include/uapi/linux/quota.h +4 -2
@@ -36,11 +36,12 @@#include <linux/errno.h> #include <linux/types.h> -#define __DQUOT_VERSION__ "dquot_6.5.2" +#define __DQUOT_VERSION__ "dquot_6.6.0" -#define MAXQUOTAS 2 +#define MAXQUOTAS 3#define USRQUOTA 0/* element used for user quotas */ #define GRPQUOTA 1/* element used for group quotas */ +#define PRJQUOTA 2/* element used for project quotas */ /* * Definitions for the default names of the quotas files.
@@ -48,6 +49,7 @@#define INITQFNAMES { \ "user",/* USRQUOTA */ \"group" ,/* GRPQUOTA */ \ +"project" ,/* PRJQUOTA */ \ "undefined", \ };
RFC PATCH 2/6 quota: adds generic code for enforcing project quota limits
In reply to Konstantin KhlebnikovThis patch adds support for a new quota type PRJQUOTA for project quota. [ Based on patch by Li Xi <[email protected]> ]
Permissions:Q_GETQUOTA: allows to query all projects present in current user-namespaceQ_SETQUOTA: requires system-wide capability CAP_SYS_ADMIN
--- fs/quota/dquot.c | 37 +++++++++++++++++++++++++++++++++++-- fs/quota/quota.c | 8 ++++++-- fs/quota/quotaio_v2.h | 6 ++++-- include/linux/quota.h | 1 + include/linux/quotaops.h | 1 + include/uapi/linux/quota.h | 6 ++++-- 6 files changed, 51 insertions(+), 8 deletions(-)
fs/quota/dquot.c +35 -2
@@ -1159,8 +1159,8 @@ static int need_print_warning(struct dquot_warn *warn)return uid_eq (current_fsuid (), warn->w_dq_id.uid);case GRPQUOTA :return in_group_p (warn->w_dq_id.gid); -case PRJQUOTA :/* Never taken... Just make gcc happy */ -return 0 ; +case PRJQUOTA : +return 1 ; }return 0 ; }
@@ -1399,6 +1399,8 @@ static void __dquot_initialize(struct inode *inode, int type)/* First get references to structures we might need. */ for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) {struct kqid qid; +kprojid_t projid; + got[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;
@@ -1409,6 +1411,10 @@ static void __dquot_initialize(struct inode *inode, int type)*/ if (i_dquot (inode)[cnt])continue ; + +if (!sb_has_quota_active (sb, cnt)) +continue ; + init_needed =1 ;switch (cnt) {
@@ -1418,6 +1424,13 @@ static void __dquot_initialize(struct inode *inode, int type)case GRPQUOTA : qid =make_kqid_gid (inode->i_gid);break ; +case PRJQUOTA : +if (!sb->s_op->get_projid) +continue ; +if (sb->s_op->get_projid (inode, &projid)) +continue ; + qid =make_kqid_projid (projid); +break ; } got[cnt] =dqget (sb, qid); }
@@ -1951,6 +1964,22 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)EXPORT_SYMBOL (dquot_transfer);/* +* Helper function for transferring inode into another project. +*/ +int dquot_transfer_project (struct inode *inode,kprojid_t projid) +{ +struct dquot *transfer_to[MAXQUOTAS ] = {}; +struct super_block *sb = inode->i_sb; +int ret; + + transfer_to[PRJQUOTA ] =dqget (sb,make_kqid_projid (projid)); + ret =__dquot_transfer (inode, transfer_to); +dqput_all (transfer_to); +return ret; +} +EXPORT_SYMBOL (dquot_transfer_project); + +/* * Write info of quota file to disk */ int dquot_commit_info (struct super_block *sb,int type)
@@ -2165,6 +2194,10 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id, error = -EINVAL ; goto out_fmt; } +if (type ==PRJQUOTA && !sb->s_op->get_projid) { + error = -EINVAL ; + goto out_fmt; + }/* Usage always has to be set... */ if (!(flags &DQUOT_USAGE_ENABLED )) { error = -EINVAL ;
fs/quota/quota.c +6 -2
@@ -30,11 +30,15 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,case Q_XGETQSTATV :case Q_XQUOTASYNC :break ; -/* allow to query information for dquots we "own" */ +/* +* Allow to query information for user/group dquots we "own". +* Allow querying project quota present in our user-namespace. +*/ case Q_GETQUOTA :case Q_XGETQUOTA :if ((type ==USRQUOTA &&uid_eq (current_euid (),make_kuid (current_user_ns (), id))) || - (type ==GRPQUOTA &&in_egroup_p (make_kgid (current_user_ns (), id)))) + (type ==GRPQUOTA &&in_egroup_p (make_kgid (current_user_ns (), id))) || + (type ==PRJQUOTA &&projid_valid (make_kprojid (current_user_ns (), id))))break ;/*FALLTHROUGH*/ default :
fs/quota/quotaio_v2.h +4 -2
@@ -13,12 +13,14 @@*/ #define V2_INITQMAGICS {\ 0xd9c01f11,/* USRQUOTA */ \ - 0xd9c01927 /* GRPQUOTA */\ + 0xd9c01927, /* GRPQUOTA */\ + 0xd9c03f14, /* PRJQUOTA */\ } #define V2_INITQVERSIONS {\ 1, /* USRQUOTA */\ -1 /* GRPQUOTA */ \ + 1, /* GRPQUOTA */\ + 1, /* PRJQUOTA */\ } /* First generic header */
include/linux/quota.h +1 -0
@@ -50,6 +50,7 @@#undef USRQUOTA#undef GRPQUOTA +#undef PRJQUOTAenum quota_type {USRQUOTA =0 ,/* element used for user quotas */ GRPQUOTA =1 ,/* element used for group quotas */
include/linux/quotaops.h +1 -0
@@ -104,6 +104,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,int __dquot_transfer (struct inode *inode,struct dquot **transfer_to);int dquot_transfer (struct inode *inode,struct iattr *iattr); +int dquot_transfer_project (struct inode *inode,kprojid_t projid);static inline struct mem_dqinfo *sb_dqinfo (struct super_block *sb,int type) {
include/uapi/linux/quota.h +4 -2
@@ -36,11 +36,12 @@#include <linux/errno.h> #include <linux/types.h> -#define __DQUOT_VERSION__ "dquot_6.5.2" +#define __DQUOT_VERSION__ "dquot_6.6.0" -#define MAXQUOTAS 2 +#define MAXQUOTAS 3#define USRQUOTA 0/* element used for user quotas */ #define GRPQUOTA 1/* element used for group quotas */ +#define PRJQUOTA 2/* element used for project quotas */ /* * Definitions for the default names of the quotas files.
@@ -48,6 +49,7 @@#define INITQFNAMES { \ "user",/* USRQUOTA */ \"group" ,/* GRPQUOTA */ \ +"project" ,/* PRJQUOTA */ \ "undefined", \ };
RFC PATCH 3/6 quota: mangle statfs result according to project quota usage and limits
In reply to Konstantin KhlebnikovThis patch updates amount of available space and inodes returned by vfs_statfs() according to project quota for this directory. This works only if sysctl fs.protected_projects = 1.
--- fs/quota/dquot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++-- fs/statfs.c | 5 +++- include/linux/quotaops.h | 5 ++++ 3 files changed, 63 insertions(+), 3 deletions(-)
fs/quota/dquot.c +54 -2
@@ -65,6 +65,7 @@#include <linux/stat.h> #include <linux/tty.h> #include <linux/file.h> +#include <linux/statfs.h> #include <linux/slab.h> #include <linux/sysctl.h> #include <linux/init.h>
@@ -1242,15 +1243,20 @@ static void flush_warnings(struct dquot_warn *warn) } } -static int ignore_hardlimit (struct dquot *dquot) +static bool sb_ignore_hardlimit (struct super_block *sb,int type) { -struct mem_dqinfo *info = &sb_dqopt (dquot->dq_sb)->info[dquot->dq_id.type]; +struct mem_dqinfo *info =sb_dqinfo (sb, type);return capable (CAP_SYS_RESOURCE ) && (info->dqi_format->qf_fmt_id !=QFMT_VFS_OLD || !(info->dqi_flags &DQF_ROOT_SQUASH )); } +static bool ignore_hardlimit (struct dquot *dquot) +{ +return sb_ignore_hardlimit (dquot->dq_sb, dquot->dq_id.type); +} +/* needs dq_data_lock */ static int check_idq (struct dquot *dquot,qsize_t inodes,struct dquot_warn *warn)
@@ -2022,6 +2028,52 @@ int dquot_file_open(struct inode *inode, struct file *file) }EXPORT_SYMBOL (dquot_file_open); +void dquot_mangle_statfs (const struct path *path,struct kstatfs *buf) +{ +struct inode *inode = path->dentry->d_inode; +struct super_block *sb = inode->i_sb; +u64 blimit =0 , ilimit =0 , busage, iusage; +struct dquot **dquots; + +if (!sysctl_protected_projects || + !sb_has_quota_limits_enabled (sb,PRJQUOTA ) || +sb_ignore_hardlimit (sb,PRJQUOTA )) +return ; + + dquots =i_dquot (inode); +if (!dquots[PRJQUOTA ]) +return ; + +spin_lock (&dq_data_lock); +if (dquots[PRJQUOTA ]) { +struct mem_dqblk *dm = &(dquots[PRJQUOTA ]->dq_dqb); + + blimit = dm->dqb_bsoftlimit ?: dm->dqb_bhardlimit; + busage = dm->dqb_curspace + dm->dqb_rsvspace; + ilimit = dm->dqb_isoftlimit ?: dm->dqb_ihardlimit; + iusage = dm->dqb_curinodes; + } +spin_unlock (&dq_data_lock); + +if (blimit) { +u64 bavail = (blimit <= busage) ?0 : +div64_long (blimit - busage, buf->f_bsize); + +if (buf->f_bavail > bavail) + buf->f_bavail = bavail; + } + +if (ilimit) { +u64 iavail = (ilimit <= iusage) ?0 : (ilimit - iusage); + +if (buf->f_ffree > iavail) { +/* Cut count of "free" inodes but keep "used" */ + buf->f_files -= buf->f_ffree - iavail; + buf->f_ffree = iavail; + } + } +} +/* * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) */
fs/statfs.c +4 -1
@@ -7,6 +7,7 @@#include <linux/statfs.h> #include <linux/security.h> #include <linux/uaccess.h> +#include <linux/quotaops.h> #include "internal.h" static int flags_by_mnt (int mnt_flags)
@@ -68,8 +69,10 @@ int vfs_statfs(struct path *path, struct kstatfs *buf)int error; error =statfs_by_dentry (path->dentry, buf); -if (!error) +if (!error) { buf->f_flags =calculate_f_flags (path->mnt); +dquot_mangle_statfs (path, buf); + }return error; }EXPORT_SYMBOL (vfs_statfs);
include/linux/quotaops.h +5 -0
@@ -85,6 +85,7 @@ int dquot_commit_info(struct super_block *sb, int type);int dquot_mark_dquot_dirty (struct dquot *dquot);int dquot_file_open (struct inode *inode,struct file *file); +void dquot_mangle_statfs (const struct path *path,struct kstatfs *buf);int dquot_enable (struct inode *inode,int type,int format_id,unsigned int flags);
@@ -275,6 +276,10 @@ static inline int dquot_resume(struct super_block *sb, int type)#define dquot_file_open generic_file_open +static inline void dquot_mangle_statfs (struct path *path,struct kstatfs *buf) +{ +} +static inline int dquot_writeback_dquots (struct super_block *sb,int type) {return 0 ;
RFC PATCH 3/6 quota: mangle statfs result according to project quota usage and limits
In reply to Konstantin KhlebnikovThis patch updates amount of available space and inodes returned by vfs_statfs() according to project quota for this directory. This works only if sysctl fs.protected_projects = 1.
--- fs/quota/dquot.c | 56 ++++++++++++++++++++++++++++++++++++++++++++-- fs/statfs.c | 5 +++- include/linux/quotaops.h | 5 ++++ 3 files changed, 63 insertions(+), 3 deletions(-)
fs/quota/dquot.c +54 -2
@@ -65,6 +65,7 @@#include <linux/stat.h> #include <linux/tty.h> #include <linux/file.h> +#include <linux/statfs.h> #include <linux/slab.h> #include <linux/sysctl.h> #include <linux/init.h>
@@ -1242,15 +1243,20 @@ static void flush_warnings(struct dquot_warn *warn) } } -static int ignore_hardlimit (struct dquot *dquot) +static bool sb_ignore_hardlimit (struct super_block *sb,int type) { -struct mem_dqinfo *info = &sb_dqopt (dquot->dq_sb)->info[dquot->dq_id.type]; +struct mem_dqinfo *info =sb_dqinfo (sb, type);return capable (CAP_SYS_RESOURCE ) && (info->dqi_format->qf_fmt_id !=QFMT_VFS_OLD || !(info->dqi_flags &DQF_ROOT_SQUASH )); } +static bool ignore_hardlimit (struct dquot *dquot) +{ +return sb_ignore_hardlimit (dquot->dq_sb, dquot->dq_id.type); +} +/* needs dq_data_lock */ static int check_idq (struct dquot *dquot,qsize_t inodes,struct dquot_warn *warn)
@@ -2022,6 +2028,52 @@ int dquot_file_open(struct inode *inode, struct file *file) }EXPORT_SYMBOL (dquot_file_open); +void dquot_mangle_statfs (const struct path *path,struct kstatfs *buf) +{ +struct inode *inode = path->dentry->d_inode; +struct super_block *sb = inode->i_sb; +u64 blimit =0 , ilimit =0 , busage, iusage; +struct dquot **dquots; + +if (!sysctl_protected_projects || + !sb_has_quota_limits_enabled (sb,PRJQUOTA ) || +sb_ignore_hardlimit (sb,PRJQUOTA )) +return ; + + dquots =i_dquot (inode); +if (!dquots[PRJQUOTA ]) +return ; + +spin_lock (&dq_data_lock); +if (dquots[PRJQUOTA ]) { +struct mem_dqblk *dm = &(dquots[PRJQUOTA ]->dq_dqb); + + blimit = dm->dqb_bsoftlimit ?: dm->dqb_bhardlimit; + busage = dm->dqb_curspace + dm->dqb_rsvspace; + ilimit = dm->dqb_isoftlimit ?: dm->dqb_ihardlimit; + iusage = dm->dqb_curinodes; + } +spin_unlock (&dq_data_lock); + +if (blimit) { +u64 bavail = (blimit <= busage) ?0 : +div64_long (blimit - busage, buf->f_bsize); + +if (buf->f_bavail > bavail) + buf->f_bavail = bavail; + } + +if (ilimit) { +u64 iavail = (ilimit <= iusage) ?0 : (ilimit - iusage); + +if (buf->f_ffree > iavail) { +/* Cut count of "free" inodes but keep "used" */ + buf->f_files -= buf->f_ffree - iavail; + buf->f_ffree = iavail; + } + } +} +/* * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) */
fs/statfs.c +4 -1
@@ -7,6 +7,7 @@#include <linux/statfs.h> #include <linux/security.h> #include <linux/uaccess.h> +#include <linux/quotaops.h> #include "internal.h" static int flags_by_mnt (int mnt_flags)
@@ -68,8 +69,10 @@ int vfs_statfs(struct path *path, struct kstatfs *buf)int error; error =statfs_by_dentry (path->dentry, buf); -if (!error) +if (!error) { buf->f_flags =calculate_f_flags (path->mnt); +dquot_mangle_statfs (path, buf); + }return error; }EXPORT_SYMBOL (vfs_statfs);
include/linux/quotaops.h +5 -0
@@ -85,6 +85,7 @@ int dquot_commit_info(struct super_block *sb, int type);int dquot_mark_dquot_dirty (struct dquot *dquot);int dquot_file_open (struct inode *inode,struct file *file); +void dquot_mangle_statfs (const struct path *path,struct kstatfs *buf);int dquot_enable (struct inode *inode,int type,int format_id,unsigned int flags);
@@ -275,6 +276,10 @@ static inline int dquot_resume(struct super_block *sb, int type)#define dquot_file_open generic_file_open +static inline void dquot_mangle_statfs (struct path *path,struct kstatfs *buf) +{ +} +static inline int dquot_writeback_dquots (struct super_block *sb,int type) {return 0 ;
RFC PATCH 4/6 ext4: add project id support
In reply to Konstantin KhlebnikovThis patch adds a new internal field of ext4 inode to save project identifier.
--- fs/ext4/ext4.h | 13 ++++++++++- fs/ext4/ialloc.c | 6 +++++ fs/ext4/inode.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/namei.c | 14 ++++++++++++ fs/ext4/super.c | 2 ++ 5 files changed, 99 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +12 -1
@@ -683,6 +683,7 @@ struct ext4_inode {__le32 i_crtime;/* File Creation time */ __le32 i_crtime_extra;/* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi;/* high 32 bits for 64-bit version */ +__le32 i_projid;/* Project ID */ };struct move_extent {
@@ -938,6 +939,7 @@ struct ext4_inode_info {/* Precomputed uuid+inum+igen checksum for seeding inode checksums */ __u32 i_csum_seed; +kprojid_t i_projid; };/*
@@ -1522,6 +1524,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)* GDT_CSUM bits are mutually exclusive. */ #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400 +#define EXT4_FEATURE_RO_COMPAT_PROJECT 0x1000/* Project ID */ #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -1571,7 +1574,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)EXT4_FEATURE_RO_COMPAT_HUGE_FILE |\EXT4_FEATURE_RO_COMPAT_BIGALLOC |\EXT4_FEATURE_RO_COMPAT_METADATA_CSUM |\ - EXT4_FEATURE_RO_COMPAT_QUOTA) +EXT4_FEATURE_RO_COMPAT_QUOTA |\ + EXT4_FEATURE_RO_COMPAT_PROJECT)/* * Default values for user and/or group using reserved blocks
@@ -1579,6 +1583,11 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)#define EXT4_DEF_RESUID 0#define EXT4_DEF_RESGID 0 +/* +* Default project ID +*/ +#define EXT4_DEF_PROJID 0 +#define EXT4_DEF_INODE_READAHEAD_BLKS 32/*
@@ -2131,6 +2140,8 @@ extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, loff_t lstart, loff_t lend);extern int ext4_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf);extern qsize_t *ext4_get_reserved_space (struct inode *inode); +extern int ext4_get_projid (struct inode *inode,kprojid_t *projid); +extern int ext4_set_projid (struct inode *inode,kprojid_t projid);extern void ext4_da_update_reserve_space (struct inode *inode,int used,int quota_claim);
fs/ext4/ialloc.c +6 -0
@@ -756,6 +756,12 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, inode->i_gid = dir->i_gid; }else inode_init_owner (inode, dir, mode); + +if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_PROJECT )) + ei->i_projid =EXT4_I (dir)->i_projid; +else + ei->i_projid =KPROJIDT_INIT (EXT4_DEF_PROJID ); +dquot_initialize (inode);if (!goal)
fs/ext4/inode.c +65 -0
95 lines not on this page · raw message
fs/ext4/namei.c +14 -0
@@ -2938,6 +2938,10 @@ static int ext4_link(struct dentry *old_dentry,if (inode->i_nlink >=EXT4_LINK_MAX )return -EMLINK ; +if (!capable_mix_inode_project (EXT4_I (dir)->i_projid, +EXT4_I (inode)->i_projid)) +return -EXDEV ; +dquot_initialize (dir); retry:
@@ -3217,6 +3221,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,int credits;u8 old_file_type; +if (!capable_mix_inode_project (EXT4_I (new.dir)->i_projid, +EXT4_I (old.inode)->i_projid)) +return -EXDEV ; +dquot_initialize (old.dir);dquot_initialize (new.dir);
@@ -3395,6 +3403,12 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,u8 new_file_type;int retval; +if (!capable_mix_inode_project (EXT4_I (new.dir)->i_projid, +EXT4_I (old.inode)->i_projid) || + !capable_mix_inode_project (EXT4_I (old.dir)->i_projid, +EXT4_I (new.inode)->i_projid)) +return -EXDEV ; +dquot_initialize (old.dir);dquot_initialize (new.dir);
fs/ext4/super.c +2 -0
@@ -1103,6 +1103,8 @@ static const struct super_operations ext4_sops = { .get_dquots = ext4_get_dquots, #endif .bdev_try_to_free_page = bdev_try_to_free_page, + .get_projid = ext4_get_projid, + .set_projid = ext4_set_projid, }; static const struct export_operations ext4_export_ops = {
RFC PATCH 4/6 ext4: add project id support
In reply to Konstantin KhlebnikovThis patch adds a new internal field of ext4 inode to save project identifier.
--- fs/ext4/ext4.h | 13 ++++++++++- fs/ext4/ialloc.c | 6 +++++ fs/ext4/inode.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/namei.c | 14 ++++++++++++ fs/ext4/super.c | 2 ++ 5 files changed, 99 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +12 -1
@@ -683,6 +683,7 @@ struct ext4_inode {__le32 i_crtime;/* File Creation time */ __le32 i_crtime_extra;/* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi;/* high 32 bits for 64-bit version */ +__le32 i_projid;/* Project ID */ };struct move_extent {
@@ -938,6 +939,7 @@ struct ext4_inode_info {/* Precomputed uuid+inum+igen checksum for seeding inode checksums */ __u32 i_csum_seed; +kprojid_t i_projid; };/*
@@ -1522,6 +1524,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)* GDT_CSUM bits are mutually exclusive. */ #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400 +#define EXT4_FEATURE_RO_COMPAT_PROJECT 0x1000/* Project ID */ #define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -1571,7 +1574,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)EXT4_FEATURE_RO_COMPAT_HUGE_FILE |\EXT4_FEATURE_RO_COMPAT_BIGALLOC |\EXT4_FEATURE_RO_COMPAT_METADATA_CSUM |\ - EXT4_FEATURE_RO_COMPAT_QUOTA) +EXT4_FEATURE_RO_COMPAT_QUOTA |\ + EXT4_FEATURE_RO_COMPAT_PROJECT)/* * Default values for user and/or group using reserved blocks
@@ -1579,6 +1583,11 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)#define EXT4_DEF_RESUID 0#define EXT4_DEF_RESGID 0 +/* +* Default project ID +*/ +#define EXT4_DEF_PROJID 0 +#define EXT4_DEF_INODE_READAHEAD_BLKS 32/*
@@ -2131,6 +2140,8 @@ extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, loff_t lstart, loff_t lend);extern int ext4_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf);extern qsize_t *ext4_get_reserved_space (struct inode *inode); +extern int ext4_get_projid (struct inode *inode,kprojid_t *projid); +extern int ext4_set_projid (struct inode *inode,kprojid_t projid);extern void ext4_da_update_reserve_space (struct inode *inode,int used,int quota_claim);
fs/ext4/ialloc.c +6 -0
@@ -756,6 +756,12 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, inode->i_gid = dir->i_gid; }else inode_init_owner (inode, dir, mode); + +if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_PROJECT )) + ei->i_projid =EXT4_I (dir)->i_projid; +else + ei->i_projid =KPROJIDT_INIT (EXT4_DEF_PROJID ); +dquot_initialize (inode);if (!goal)
fs/ext4/inode.c +65 -0
95 lines not on this page · raw message
fs/ext4/namei.c +14 -0
@@ -2938,6 +2938,10 @@ static int ext4_link(struct dentry *old_dentry,if (inode->i_nlink >=EXT4_LINK_MAX )return -EMLINK ; +if (!capable_mix_inode_project (EXT4_I (dir)->i_projid, +EXT4_I (inode)->i_projid)) +return -EXDEV ; +dquot_initialize (dir); retry:
@@ -3217,6 +3221,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,int credits;u8 old_file_type; +if (!capable_mix_inode_project (EXT4_I (new.dir)->i_projid, +EXT4_I (old.inode)->i_projid)) +return -EXDEV ; +dquot_initialize (old.dir);dquot_initialize (new.dir);
@@ -3395,6 +3403,12 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,u8 new_file_type;int retval; +if (!capable_mix_inode_project (EXT4_I (new.dir)->i_projid, +EXT4_I (old.inode)->i_projid) || + !capable_mix_inode_project (EXT4_I (old.dir)->i_projid, +EXT4_I (new.inode)->i_projid)) +return -EXDEV ; +dquot_initialize (old.dir);dquot_initialize (new.dir);
fs/ext4/super.c +2 -0
@@ -1103,6 +1103,8 @@ static const struct super_operations ext4_sops = { .get_dquots = ext4_get_dquots, #endif .bdev_try_to_free_page = bdev_try_to_free_page, + .get_projid = ext4_get_projid, + .set_projid = ext4_set_projid, }; static const struct export_operations ext4_export_ops = {
RFC PATCH 5/6 ext4: adds project quota support
In reply to Konstantin KhlebnikovThis patch adds mount options for enabling/disabling project quota accounting and enforcement. A new specific inode is also used for project quota accounting.
[ Mostly unchanged patch from Li Xi <[email protected]> ]
--- fs/ext4/ext4.h | 8 ++++++-- fs/ext4/inode.c | 12 +++++++++++- fs/ext4/super.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 14 deletions(-)
fs/ext4/ext4.h +6 -2
@@ -208,6 +208,7 @@ struct ext4_io_submit {#define EXT4_UNDEL_DIR_INO 6/* Undelete directory inode */ #define EXT4_RESIZE_INO 7/* Reserved group descriptors inode */ #define EXT4_JOURNAL_INO 8/* Journal inode */ +#define EXT4_PRJ_QUOTA_INO 9/* Project quota inode */ /* First non-reserved inode for old ext4 filesystems */ #define EXT4_GOOD_OLD_FIRST_INO 11
@@ -983,6 +984,7 @@ struct ext4_inode_info {#define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000/* Enable support for dio read nolocking */ #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000/* Journal checksums */ #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000/* Journal Async Commit */ +#define EXT4_MOUNT_PRJQUOTA 0x2000000/* Project quota support */ #define EXT4_MOUNT_DELALLOC 0x8000000/* Delalloc support */ #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000/* Abort on file data write */ #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000/* Block validity checking */
@@ -1158,7 +1160,8 @@ struct ext4_super_block {__le32 s_grp_quota_inum;/* inode for tracking group quota */ __le32 s_overhead_clusters;/* overhead blocks/clusters in fs */ __le32 s_backup_bgs[2 ];/* groups with sparse_super2 SBs */ -__le32 s_reserved[106 ];/* Padding to the end of the block */ +__le32 s_prj_quota_inum;/* inode for tracking project quota */ +__le32 s_reserved[105 ];/* Padding to the end of the block */ __le32 s_checksum;/* crc32c(superblock) */ };
@@ -1173,7 +1176,7 @@ struct ext4_super_block {#define EXT4_MF_FS_ABORTED 0x0002/* Fatal error detected */ /* Number of quota types we support */ -#define EXT4_MAXQUOTAS 2 +#define EXT4_MAXQUOTAS 3/* * fourth extended-fs super-block data in memory
@@ -1365,6 +1368,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) ino ==EXT4_BOOT_LOADER_INO || ino ==EXT4_JOURNAL_INO || ino ==EXT4_RESIZE_INO || + ino ==EXT4_PRJ_QUOTA_INO || (ino >=EXT4_FIRST_INO (sb) && ino <=le32_to_cpu (EXT4_SB (sb)->s_es->s_inodes_count)); }
fs/ext4/inode.c +11 -1
@@ -3894,9 +3894,18 @@ int ext4_set_projid(struct inode *inode, kprojid_t projid)if (projid_eq (EXT4_I (inode)->i_projid, projid))return 0 ; - handle =ext4_journal_start (inode,EXT4_HT_INODE ,1 ); +dquot_initialize (inode); + + handle =ext4_journal_start (inode,EXT4_HT_INODE ,1 + +EXT4_QUOTA_INIT_BLOCKS (sb) + +EXT4_QUOTA_DEL_BLOCKS (sb));if (IS_ERR (handle))return PTR_ERR (handle); + + err =dquot_transfer_project (inode, projid); +if (err) + goto out; + err =ext4_reserve_inode_write (handle, inode, &iloc);if (!err) { inode->i_ctime =ext4_current_time (inode);
@@ -3905,6 +3914,7 @@ int ext4_set_projid(struct inode *inode, kprojid_t projid) }if (IS_SYNC (inode))ext4_handle_sync (handle); +out:ext4_journal_stop (handle);return err;
fs/ext4/super.c +42 -11
146 lines not on this page · raw message
RFC PATCH 5/6 ext4: adds project quota support
In reply to Konstantin KhlebnikovThis patch adds mount options for enabling/disabling project quota accounting and enforcement. A new specific inode is also used for project quota accounting.
[ Mostly unchanged patch from Li Xi <[email protected]> ]
--- fs/ext4/ext4.h | 8 ++++++-- fs/ext4/inode.c | 12 +++++++++++- fs/ext4/super.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 14 deletions(-)
fs/ext4/ext4.h +6 -2
@@ -208,6 +208,7 @@ struct ext4_io_submit {#define EXT4_UNDEL_DIR_INO 6/* Undelete directory inode */ #define EXT4_RESIZE_INO 7/* Reserved group descriptors inode */ #define EXT4_JOURNAL_INO 8/* Journal inode */ +#define EXT4_PRJ_QUOTA_INO 9/* Project quota inode */ /* First non-reserved inode for old ext4 filesystems */ #define EXT4_GOOD_OLD_FIRST_INO 11
@@ -983,6 +984,7 @@ struct ext4_inode_info {#define EXT4_MOUNT_DIOREAD_NOLOCK 0x400000/* Enable support for dio read nolocking */ #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000/* Journal checksums */ #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000/* Journal Async Commit */ +#define EXT4_MOUNT_PRJQUOTA 0x2000000/* Project quota support */ #define EXT4_MOUNT_DELALLOC 0x8000000/* Delalloc support */ #define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000/* Abort on file data write */ #define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000/* Block validity checking */
@@ -1158,7 +1160,8 @@ struct ext4_super_block {__le32 s_grp_quota_inum;/* inode for tracking group quota */ __le32 s_overhead_clusters;/* overhead blocks/clusters in fs */ __le32 s_backup_bgs[2 ];/* groups with sparse_super2 SBs */ -__le32 s_reserved[106 ];/* Padding to the end of the block */ +__le32 s_prj_quota_inum;/* inode for tracking project quota */ +__le32 s_reserved[105 ];/* Padding to the end of the block */ __le32 s_checksum;/* crc32c(superblock) */ };
@@ -1173,7 +1176,7 @@ struct ext4_super_block {#define EXT4_MF_FS_ABORTED 0x0002/* Fatal error detected */ /* Number of quota types we support */ -#define EXT4_MAXQUOTAS 2 +#define EXT4_MAXQUOTAS 3/* * fourth extended-fs super-block data in memory
@@ -1365,6 +1368,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) ino ==EXT4_BOOT_LOADER_INO || ino ==EXT4_JOURNAL_INO || ino ==EXT4_RESIZE_INO || + ino ==EXT4_PRJ_QUOTA_INO || (ino >=EXT4_FIRST_INO (sb) && ino <=le32_to_cpu (EXT4_SB (sb)->s_es->s_inodes_count)); }
fs/ext4/inode.c +11 -1
@@ -3894,9 +3894,18 @@ int ext4_set_projid(struct inode *inode, kprojid_t projid)if (projid_eq (EXT4_I (inode)->i_projid, projid))return 0 ; - handle =ext4_journal_start (inode,EXT4_HT_INODE ,1 ); +dquot_initialize (inode); + + handle =ext4_journal_start (inode,EXT4_HT_INODE ,1 + +EXT4_QUOTA_INIT_BLOCKS (sb) + +EXT4_QUOTA_DEL_BLOCKS (sb));if (IS_ERR (handle))return PTR_ERR (handle); + + err =dquot_transfer_project (inode, projid); +if (err) + goto out; + err =ext4_reserve_inode_write (handle, inode, &iloc);if (!err) { inode->i_ctime =ext4_current_time (inode);
@@ -3905,6 +3914,7 @@ int ext4_set_projid(struct inode *inode, kprojid_t projid) }if (IS_SYNC (inode))ext4_handle_sync (handle); +out:ext4_journal_stop (handle);return err;
fs/ext4/super.c +42 -11
146 lines not on this page · raw message
RFC PATCH 6/6 tools/quota/project_quota: sample tool for early adopters
In reply to Konstantin KhlebnikovUsage: ./project_quota <command> <path> [args]...
Commands:
init <path> initialize quota file on <path> turn on off <path> turn off info <path> show project, usage and limits project <path> [<id>] get / set project id limit <path> [<bytes>] get / set space limit ilimit <path> [<inodes>] get / set inodes limit
How to enable feature using debugfs tool:
# debugfs debugfs: open -w <disk> debugfs: feature +FEATURE_R12 debugfs: quit # mount ... # project_quota init <mountpoint> # project_quota on <mountpoint>
--- tools/quota/.gitignore | 1 tools/quota/Makefile | 6 + tools/quota/project_quota.c | 324 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 331 insertions(+) create mode 100644 tools/quota/.gitignore create mode 100644 tools/quota/Makefile create mode 100644 tools/quota/project_quota.c
tools/quota/.gitignore new file +1 -0
@@ -0,0 +1 @@ +project_quota
tools/quota/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +CFLAGS=-Wall -W + +project_quota: + +clean: + rm project_quota
tools/quota/project_quota.c new file +324 -0
324 lines not on this page · raw message
RFC PATCH 6/6 tools/quota/project_quota: sample tool for early adopters
In reply to Konstantin KhlebnikovUsage: ./project_quota <command> <path> [args]...
Commands:
init <path> initialize quota file on <path> turn on off <path> turn off info <path> show project, usage and limits project <path> [<id>] get / set project id limit <path> [<bytes>] get / set space limit ilimit <path> [<inodes>] get / set inodes limit
How to enable feature using debugfs tool:
# debugfs debugfs: open -w <disk> debugfs: feature +FEATURE_R12 debugfs: quit # mount ... # project_quota init <mountpoint> # project_quota on <mountpoint>
--- tools/quota/.gitignore | 1 tools/quota/Makefile | 6 + tools/quota/project_quota.c | 324 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 331 insertions(+) create mode 100644 tools/quota/.gitignore create mode 100644 tools/quota/Makefile create mode 100644 tools/quota/project_quota.c
tools/quota/.gitignore new file +1 -0
@@ -0,0 +1 @@ +project_quota
tools/quota/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +CFLAGS=-Wall -W + +project_quota: + +clean: + rm project_quota
tools/quota/project_quota.c new file +324 -0
324 lines not on this page · raw message