All of lore.kernel.org
 help / color / mirror / Atom feed
* [v15 0/4] ext4: add project quota support
@ 2015-09-13 12:20 Li Xi
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
                   ` (4 more replies)
  0 siblings, 5 replies; 45+ messages in thread
From: Li Xi @ 2015-09-13 12:20 UTC (permalink / raw)
  To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
	adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

The following patches propose an implementation of project quota
support for ext4. A project is an aggregate of unrelated inodes
which might scatter in different directories. Inodes that belong
to the same project possess an identical identification i.e.
'project ID', just like every inode has its user/group
identification. The following patches add project quota as
supplement to the former uer/group quota types.

The semantics of ext4 project quota is consistent with XFS. Each
directory can have EXT4_INODE_PROJINHERIT flag set. When the
EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
newly created inode under that directory will have a default project
ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
When this flag is set on a directory, following rules will be kept:

1) The newly created inode under that directory will inherit both
the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
directory.

2) Hard-linking a inode with different project ID into that directory
will fail with errno EXDEV.

3) Renaming a inode with different project ID into that directory
will fail with errno EXDEV. However, 'mv' command will detect this
failure and copy the renamed inode to a new inode in the directory.
Thus, this new inode will inherit both the project ID and
EXT4_INODE_PROJINHERIT flag.

4) If the project quota of that ID is being enforced, statfs() on
that directory will take the quotas as another upper limits along
with the capacity of the file system, i.e. the total block/inode
number will be the minimum of the quota limits and file system
capacity.

Changelog:
* v15 <- v14:
 - Rebase to newest master branch of git repository (b0a1ea51b).
* v14 <- v13:
 - Cleanup ioctl of setting project ID;
 - Do not check project quota inode number specially;
 - Check isize when extract project ID from disk;
 - Rebase to latest kernel (4.0.0)
* v13 <- v12:
 - Update inode size check of project ID.
* v12 <- v11:
 - Relax the permission check when setting project ID.
* v11 <- v10:
 - Remove project quota mount option;
 - Fix permission check when setting project ID.
* v10 <- v9:
 - Remove non-journaled project quota interface;
 - Only allow admin to read project quota info;
 - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
* v9 <- v8:
 - Remove non-journaled project quota;
 - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
* v8 <- v7:
 - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
* v7 <- v6:
 - Map ext4 inode flags to xflags of struct fsxattr;
 - Add patch to cleanup ext4 inode flag definitions.
* v6 <- v5:
 - Add project ID check for cross rename;
 - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
* v5 <- v4:
 - Check project feature when set/get project ID;
 - Do not check project feature for project quota;
 - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
* v4 <- v3:
 - Do not check project feature when set/get project ID;
 - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
 - Remove unnecessary change of fs/quota/dquot.c;
 - Remove CONFIG_QUOTA_PROJECT.
* v3 <- v2:
 - Add EXT4_INODE_PROJINHERIT semantics.
* v2 <- v1:
 - Add ioctl interface for setting/getting project;
 - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
 - Add get_projid() method in struct dquot_operations;
 - Add error check of ext4_inode_projid_set/get().

v14: http://article.gmane.org/gmane.linux.kernel.api/10345
v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
v5: http://www.spinics.net/lists/linux-api/msg04840.html
v4: http://lwn.net/Articles/612972/
v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153

Any comments or feedbacks are appreciated.

Regards,
                                         - Li Xi

Li Xi (4):
  ext4: adds project ID support
  ext4: adds project quota support
  ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
  ext4: cleanup inode flag definitions

 fs/ext4/ext4.h          |   85 +++++++----
 fs/ext4/ialloc.c        |    7 +
 fs/ext4/inode.c         |   28 ++++
 fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
 fs/ext4/namei.c         |   19 +++
 fs/ext4/super.c         |   57 +++++++-
 fs/xfs/libxfs/xfs_fs.h  |   47 +++----
 include/uapi/linux/fs.h |   33 +++++
 8 files changed, 490 insertions(+), 153 deletions(-)

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [v15 1/4] ext4: adds project ID support
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
@ 2015-09-13 12:20   ` Li Xi
       [not found]     ` <1442146833-13652-2-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
  2015-09-13 12:20   ` [v15 2/4] ext4: adds project quota support Li Xi
  2015-09-24 17:12   ` [v15 0/4] ext4: add " Andreas Dilger
  2 siblings, 1 reply; 45+ messages in thread
From: Li Xi @ 2015-09-13 12:20 UTC (permalink / raw)
  To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
	adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

This patch adds a new internal field of ext4 inode to save project
identifier. Also a new flag EXT4_INODE_PROJINHERIT is added for
inheriting project ID from parent directory.

Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
Reviewed-by: Andreas Dilger <adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>
Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
---
 fs/ext4/ext4.h          |   21 +++++++++++++++++----
 fs/ext4/ialloc.c        |    7 +++++++
 fs/ext4/inode.c         |   28 ++++++++++++++++++++++++++++
 fs/ext4/namei.c         |   19 +++++++++++++++++++
 fs/ext4/super.c         |    1 +
 include/uapi/linux/fs.h |    1 +
 6 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index fd1f28b..96d6e4c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -374,16 +374,18 @@ struct flex_groups {
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
+#define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE		0x004BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE		0x004380FF /* User modifiable flags */
+#define EXT4_FL_USER_VISIBLE		0x304BDFFF /* User visible flags */
+#define EXT4_FL_USER_MODIFIABLE		0x204380FF /* User modifiable flags */
 
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
 			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
-			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL)
+			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
+			   EXT4_PROJINHERIT_FL)
 
 /* Flags that are appropriate for regular files (all but dir-specific ones). */
 #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL))
@@ -431,6 +433,7 @@ enum {
 	EXT4_INODE_EA_INODE	= 21,	/* Inode used for large EA */
 	EXT4_INODE_EOFBLOCKS	= 22,	/* Blocks allocated beyond EOF */
 	EXT4_INODE_INLINE_DATA	= 28,	/* Data in inode. */
+	EXT4_INODE_PROJINHERIT	= 29,	/* Create with parents projid */
 	EXT4_INODE_RESERVED	= 31,	/* reserved for ext4 lib */
 };
 
@@ -692,6 +695,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 {
@@ -952,6 +956,7 @@ struct ext4_inode_info {
 	/* Encryption params */
 	struct ext4_crypt_info *i_crypt_info;
 #endif
+	kprojid_t i_projid;
 };
 
 /*
@@ -1566,6 +1571,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
  */
 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
 #define EXT4_FEATURE_RO_COMPAT_READONLY		0x1000
+#define EXT4_FEATURE_RO_COMPAT_PROJECT		0x2000
 
 #define EXT4_FEATURE_INCOMPAT_COMPRESSION	0x0001
 #define EXT4_FEATURE_INCOMPAT_FILETYPE		0x0002
@@ -1617,7 +1623,8 @@ static inline int ext4_encrypted_inode(struct inode *inode)
 					 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
@@ -1625,6 +1632,11 @@ static inline int ext4_encrypted_inode(struct inode *inode)
 #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
 
 /*
@@ -2317,6 +2329,7 @@ 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 void ext4_da_update_reserve_space(struct inode *inode,
 					int used, int quota_claim);
 
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 619bfc1..692b50f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -769,6 +769,13 @@ 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) &&
+	    ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT))
+		ei->i_projid = EXT4_I(dir)->i_projid;
+	else
+		ei->i_projid = make_kprojid(&init_user_ns, EXT4_DEF_PROJID);
+
 	err = dquot_initialize(inode);
 	if (err)
 		goto out;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 612fbcf..5836a3d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4035,6 +4035,14 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
 		EXT4_I(inode)->i_inline_off = 0;
 }
 
+int ext4_get_projid(struct inode *inode, kprojid_t *projid)
+{
+	if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_RO_COMPAT_PROJECT))
+		return -EOPNOTSUPP;
+	*projid = EXT4_I(inode)->i_projid;
+	return 0;
+}
+
 struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 {
 	struct ext4_iloc iloc;
@@ -4046,6 +4054,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	int block;
 	uid_t i_uid;
 	gid_t i_gid;
+	projid_t i_projid;
 
 	inode = iget_locked(sb, ino);
 	if (!inode)
@@ -4095,12 +4104,20 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
 	i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
 	i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
+	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT) &&
+	    EXT4_INODE_SIZE(sb) > EXT4_GOOD_OLD_INODE_SIZE &&
+	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
+		i_projid = (projid_t)le32_to_cpu(raw_inode->i_projid);
+	else
+		i_projid = EXT4_DEF_PROJID;
+
 	if (!(test_opt(inode->i_sb, NO_UID32))) {
 		i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
 		i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
 	}
 	i_uid_write(inode, i_uid);
 	i_gid_write(inode, i_gid);
+	ei->i_projid = make_kprojid(&init_user_ns, i_projid);
 	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
 
 	ext4_clear_state_flags(ei);	/* Only relevant on 32-bit archs */
@@ -4398,6 +4415,7 @@ static int ext4_do_update_inode(handle_t *handle,
 	int need_datasync = 0, set_large_file = 0;
 	uid_t i_uid;
 	gid_t i_gid;
+	projid_t i_projid;
 
 	spin_lock(&ei->i_raw_lock);
 
@@ -4410,6 +4428,7 @@ static int ext4_do_update_inode(handle_t *handle,
 	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
 	i_uid = i_uid_read(inode);
 	i_gid = i_gid_read(inode);
+	i_projid = from_kprojid(&init_user_ns, ei->i_projid);
 	if (!(test_opt(inode->i_sb, NO_UID32))) {
 		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
 		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
@@ -4488,6 +4507,15 @@ static int ext4_do_update_inode(handle_t *handle,
 				cpu_to_le16(ei->i_extra_isize);
 		}
 	}
+
+	BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+			EXT4_FEATURE_RO_COMPAT_PROJECT) &&
+	       i_projid != EXT4_DEF_PROJID);
+
+	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
+	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
+		raw_inode->i_projid = cpu_to_le32(i_projid);
+
 	ext4_inode_csum_set(inode, raw_inode, ei);
 	spin_unlock(&ei->i_raw_lock);
 	if (inode->i_sb->s_flags & MS_LAZYTIME)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 9f61e76..61694ad 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3215,6 +3215,12 @@ static int ext4_link(struct dentry *old_dentry,
 	if (ext4_encrypted_inode(dir) &&
 	    !ext4_is_child_context_consistent_with_parent(dir, inode))
 		return -EPERM;
+
+       if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
+	   (!projid_eq(EXT4_I(dir)->i_projid,
+		       EXT4_I(old_dentry->d_inode)->i_projid)))
+		return -EXDEV;
+
 	err = dquot_initialize(dir);
 	if (err)
 		return err;
@@ -3496,6 +3502,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
 	int credits;
 	u8 old_file_type;
 
+	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT)) &&
+	    (!projid_eq(EXT4_I(new_dir)->i_projid,
+			EXT4_I(old_dentry->d_inode)->i_projid)))
+		return -EXDEV;
+
 	retval = dquot_initialize(old.dir);
 	if (retval)
 		return retval;
@@ -3705,6 +3716,14 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 							   new.inode)))
 		return -EPERM;
 
+	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
+	     !projid_eq(EXT4_I(new_dir)->i_projid,
+			EXT4_I(old_dentry->d_inode)->i_projid)) ||
+	    (ext4_test_inode_flag(old_dir, EXT4_INODE_PROJINHERIT) &&
+	     !projid_eq(EXT4_I(old_dir)->i_projid,
+			EXT4_I(new_dentry->d_inode)->i_projid)))
+		return -EXDEV;
+
 	retval = dquot_initialize(old.dir);
 	if (retval)
 		return retval;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index a63c7b0..d07445e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1097,6 +1097,7 @@ static const struct dquot_operations ext4_quota_operations = {
 	.write_info	= ext4_write_info,
 	.alloc_dquot	= dquot_alloc,
 	.destroy_dquot	= dquot_destroy,
+	.get_projid	= ext4_get_projid,
 };
 
 static const struct quotactl_ops ext4_qctl_operations = {
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 9b964a5..f15d980 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -197,6 +197,7 @@ struct inodes_stat_t {
 #define FS_EXTENT_FL			0x00080000 /* Extents */
 #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
 #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
+#define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
 
 #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [v15 2/4] ext4: adds project quota support
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
  2015-09-13 12:20   ` [v15 1/4] ext4: adds project ID support Li Xi
@ 2015-09-13 12:20   ` Li Xi
  2015-09-24 17:12   ` [v15 0/4] ext4: add " Andreas Dilger
  2 siblings, 0 replies; 45+ messages in thread
From: Li Xi @ 2015-09-13 12:20 UTC (permalink / raw)
  To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
	adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

This patch adds mount options for enabling/disabling project quota
accounting and enforcement. A new specific inode is also used for
project quota accounting.

Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
Signed-off-by: Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Reviewed-by: Andreas Dilger <adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>
Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
---
 fs/ext4/ext4.h  |    5 ++-
 fs/ext4/super.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 96d6e4c..9efbb4b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1184,7 +1184,8 @@ struct ext4_super_block {
 	__u8	s_encrypt_algos[4];	/* Encryption algorithms in use  */
 	__u8	s_encrypt_pw_salt[16];	/* Salt used for string2key algorithm */
 	__le32	s_lpf_ino;		/* Location of the lost+found inode */
-	__le32	s_reserved[100];	/* Padding to the end of the block */
+	__le32	s_prj_quota_inum;	/* inode for tracking project quota */
+	__le32	s_reserved[99];		/* Padding to the end of the block */
 	__le32	s_checksum;		/* crc32c(superblock) */
 };
 
@@ -1207,7 +1208,7 @@ struct ext4_super_block {
 #endif
 
 /* Number of quota types we support */
-#define EXT4_MAXQUOTAS 2
+#define EXT4_MAXQUOTAS 3
 
 /*
  * fourth extended-fs super-block data in memory
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d07445e..4040263 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1063,8 +1063,8 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
 }
 
 #ifdef CONFIG_QUOTA
-#define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group")
-#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
+static char *quotatypes[] = INITQFNAMES;
+#define QTYPE2NAME(t) (quotatypes[t])
 
 static int ext4_write_dquot(struct dquot *dquot);
 static int ext4_acquire_dquot(struct dquot *dquot);
@@ -4012,7 +4012,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		sb->s_qcop = &dquot_quotactl_sysfile_ops;
 	else
 		sb->s_qcop = &ext4_qctl_operations;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
 #endif
 	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 
@@ -5145,6 +5145,46 @@ restore_opts:
 	return err;
 }
 
+static int ext4_statfs_project(struct super_block *sb,
+			       kprojid_t projid, struct kstatfs *buf)
+{
+	struct kqid qid;
+	struct dquot *dquot;
+	u64 limit;
+	u64 curblock;
+
+	qid = make_kqid_projid(projid);
+	dquot = dqget(sb, qid);
+	if (!dquot)
+		return -ESRCH;
+	spin_lock(&dq_data_lock);
+
+	limit = dquot->dq_dqb.dqb_bsoftlimit ?
+		dquot->dq_dqb.dqb_bsoftlimit :
+		dquot->dq_dqb.dqb_bhardlimit;
+	if (limit && buf->f_blocks * buf->f_bsize > limit) {
+		curblock = dquot->dq_dqb.dqb_curspace / buf->f_bsize;
+		buf->f_blocks = limit / buf->f_bsize;
+		buf->f_bfree = buf->f_bavail =
+			(buf->f_blocks > curblock) ?
+			 (buf->f_blocks - curblock) : 0;
+	}
+
+	limit = dquot->dq_dqb.dqb_isoftlimit ?
+		dquot->dq_dqb.dqb_isoftlimit :
+		dquot->dq_dqb.dqb_ihardlimit;
+	if (limit && buf->f_files > limit) {
+		buf->f_files = limit;
+		buf->f_ffree =
+			(buf->f_files > dquot->dq_dqb.dqb_curinodes) ?
+			 (buf->f_files - dquot->dq_dqb.dqb_curinodes) : 0;
+	}
+
+	spin_unlock(&dq_data_lock);
+	dqput(dquot);
+	return 0;
+}
+
 static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
 	struct super_block *sb = dentry->d_sb;
@@ -5153,6 +5193,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	ext4_fsblk_t overhead = 0, resv_blocks;
 	u64 fsid;
 	s64 bfree;
+	struct inode *inode = dentry->d_inode;
 	resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
 
 	if (!test_opt(sb, MINIX_DF))
@@ -5177,6 +5218,9 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
 	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
 
+	if (ext4_test_inode_flag(inode, EXT4_INODE_PROJINHERIT) &&
+	    sb_has_quota_limits_enabled(sb, PRJQUOTA))
+		ext4_statfs_project(sb, EXT4_I(inode)->i_projid, buf);
 	return 0;
 }
 
@@ -5341,7 +5385,8 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
 	struct inode *qf_inode;
 	unsigned long qf_inums[EXT4_MAXQUOTAS] = {
 		le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
-		le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
+		le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum),
+		le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum)
 	};
 
 	BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA));
@@ -5369,7 +5414,8 @@ static int ext4_enable_quotas(struct super_block *sb)
 	int type, err = 0;
 	unsigned long qf_inums[EXT4_MAXQUOTAS] = {
 		le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
-		le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
+		le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum),
+		le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum)
 	};
 
 	sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [v15 3/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
  2015-09-13 12:20 [v15 0/4] ext4: add project quota support Li Xi
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
@ 2015-09-13 12:20 ` Li Xi
  2016-01-03 23:05   ` [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion Dave Chinner
  2015-09-13 12:20 ` [v15 4/4] ext4: cleanup inode flag definitions Li Xi
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 45+ messages in thread
From: Li Xi @ 2015-09-13 12:20 UTC (permalink / raw)
  To: linux-fsdevel, linux-ext4, linux-api, tytso, adilger, jack, viro,
	hch, dmonakhov

This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
support for ext4. The interface is kept consistent with
XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.

Signed-off-by: Li Xi <lixi@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/ext4.h          |    9 ++
 fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
 fs/xfs/libxfs/xfs_fs.h  |   47 +++----
 include/uapi/linux/fs.h |   32 ++++
 4 files changed, 338 insertions(+), 117 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9efbb4b..6e45175 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -380,6 +380,13 @@ struct flex_groups {
 #define EXT4_FL_USER_VISIBLE		0x304BDFFF /* User visible flags */
 #define EXT4_FL_USER_MODIFIABLE		0x204380FF /* User modifiable flags */
 
+#define EXT4_FL_XFLAG_VISIBLE		(EXT4_SYNC_FL | \
+					 EXT4_IMMUTABLE_FL | \
+					 EXT4_APPEND_FL | \
+					 EXT4_NODUMP_FL | \
+					 EXT4_NOATIME_FL | \
+					 EXT4_PROJINHERIT_FL)
+
 /* Flags that should be inherited by new inodes from their parent. */
 #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
 			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
@@ -614,6 +621,8 @@ enum {
 #define EXT4_IOC_SET_ENCRYPTION_POLICY	_IOR('f', 19, struct ext4_encryption_policy)
 #define EXT4_IOC_GET_ENCRYPTION_PWSALT	_IOW('f', 20, __u8[16])
 #define EXT4_IOC_GET_ENCRYPTION_POLICY	_IOW('f', 21, struct ext4_encryption_policy)
+#define EXT4_IOC_FSGETXATTR		FS_IOC_FSGETXATTR
+#define EXT4_IOC_FSSETXATTR		FS_IOC_FSSETXATTR
 
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 1346cfa..49c1aaf 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -14,6 +14,7 @@
 #include <linux/mount.h>
 #include <linux/file.h>
 #include <linux/random.h>
+#include <linux/quotaops.h>
 #include <asm/uaccess.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
@@ -203,6 +204,229 @@ static int uuid_is_zero(__u8 u[16])
 	return 1;
 }
 
+static int ext4_ioctl_setflags(struct inode *inode,
+			       unsigned int flags)
+{
+	struct ext4_inode_info *ei = EXT4_I(inode);
+	handle_t *handle = NULL;
+	int err = EPERM, migrate = 0;
+	struct ext4_iloc iloc;
+	unsigned int oldflags, mask, i;
+	unsigned int jflag;
+
+	/* Is it quota file? Do not allow user to mess with it */
+	if (IS_NOQUOTA(inode))
+		goto flags_out;
+
+	oldflags = ei->i_flags;
+
+	/* The JOURNAL_DATA flag is modifiable only by root */
+	jflag = flags & EXT4_JOURNAL_DATA_FL;
+
+	/*
+	 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
+	 * the relevant capability.
+	 *
+	 * This test looks nicer. Thanks to Pauline Middelink
+	 */
+	if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
+		if (!capable(CAP_LINUX_IMMUTABLE))
+			goto flags_out;
+	}
+
+	/*
+	 * The JOURNAL_DATA flag can only be changed by
+	 * the relevant capability.
+	 */
+	if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
+		if (!capable(CAP_SYS_RESOURCE))
+			goto flags_out;
+	}
+	if ((flags ^ oldflags) & EXT4_EXTENTS_FL)
+		migrate = 1;
+
+	if (flags & EXT4_EOFBLOCKS_FL) {
+		/* we don't support adding EOFBLOCKS flag */
+		if (!(oldflags & EXT4_EOFBLOCKS_FL)) {
+			err = -EOPNOTSUPP;
+			goto flags_out;
+		}
+	} else if (oldflags & EXT4_EOFBLOCKS_FL)
+		ext4_truncate(inode);
+
+	handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		goto flags_out;
+	}
+	if (IS_SYNC(inode))
+		ext4_handle_sync(handle);
+	err = ext4_reserve_inode_write(handle, inode, &iloc);
+	if (err)
+		goto flags_err;
+
+	for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
+		if (!(mask & EXT4_FL_USER_MODIFIABLE))
+			continue;
+		if (mask & flags)
+			ext4_set_inode_flag(inode, i);
+		else
+			ext4_clear_inode_flag(inode, i);
+	}
+
+	ext4_set_inode_flags(inode);
+	inode->i_ctime = ext4_current_time(inode);
+
+	err = ext4_mark_iloc_dirty(handle, inode, &iloc);
+flags_err:
+	ext4_journal_stop(handle);
+	if (err)
+		goto flags_out;
+
+	if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
+		err = ext4_change_inode_journal_flag(inode, jflag);
+	if (err)
+		goto flags_out;
+	if (migrate) {
+		if (flags & EXT4_EXTENTS_FL)
+			err = ext4_ext_migrate(inode);
+		else
+			err = ext4_ind_migrate(inode);
+	}
+
+flags_out:
+	return err;
+}
+
+static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
+{
+	struct inode *inode = file_inode(filp);
+	struct super_block *sb = inode->i_sb;
+	struct ext4_inode_info *ei = EXT4_I(inode);
+	int err, rc;
+	handle_t *handle;
+	kprojid_t kprojid;
+	struct ext4_iloc iloc;
+	struct ext4_inode *raw_inode;
+	struct dquot *transfer_to[EXT4_MAXQUOTAS] = { };
+
+	if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
+			EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+		BUG_ON(__kprojid_val(EXT4_I(inode)->i_projid)
+		       != EXT4_DEF_PROJID);
+		if (projid != EXT4_DEF_PROJID)
+			return -EOPNOTSUPP;
+		else
+			return 0;
+	}
+
+	if (EXT4_INODE_SIZE(sb) <= EXT4_GOOD_OLD_INODE_SIZE)
+	    	return -EOPNOTSUPP;
+
+	kprojid = make_kprojid(&init_user_ns, (projid_t)projid);
+
+	if (projid_eq(kprojid, EXT4_I(inode)->i_projid))
+		return 0;
+
+	err = mnt_want_write_file(filp);
+	if (err)
+		return err;
+
+	err = -EPERM;
+	mutex_lock(&inode->i_mutex);
+	/* Is it quota file? Do not allow user to mess with it */
+	if (IS_NOQUOTA(inode))
+		goto out_unlock;
+
+	err = ext4_get_inode_loc(inode, &iloc);
+	if (err)
+		goto out_unlock;
+
+	raw_inode = ext4_raw_inode(&iloc);
+	if (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid)) {
+	    	err = -EOVERFLOW;
+	    	brelse(iloc.bh);
+	    	goto out_unlock;
+	}
+	brelse(iloc.bh);
+
+	dquot_initialize(inode);
+
+	handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
+		EXT4_QUOTA_INIT_BLOCKS(sb) +
+		EXT4_QUOTA_DEL_BLOCKS(sb) + 3);
+	if (IS_ERR(handle)) {
+		err = PTR_ERR(handle);
+		goto out_unlock;
+	}
+
+	err = ext4_reserve_inode_write(handle, inode, &iloc);
+	if (err)
+		goto out_stop;
+
+	transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
+	if (transfer_to[PRJQUOTA]) {
+		err = __dquot_transfer(inode, transfer_to);
+		dqput(transfer_to[PRJQUOTA]);
+		if (err)
+			goto out_dirty;
+	}
+
+	EXT4_I(inode)->i_projid = kprojid;
+	inode->i_ctime = ext4_current_time(inode);
+out_dirty:
+	rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
+	if (!err)
+		err = rc;
+out_stop:
+	ext4_journal_stop(handle);
+out_unlock:
+	mutex_unlock(&inode->i_mutex);
+	mnt_drop_write_file(filp);
+	return err;
+}
+
+/* Transfer internal flags to xflags */
+static inline __u32 ext4_iflags_to_xflags(unsigned long iflags)
+{
+	__u32 xflags = 0;
+
+	if (iflags & EXT4_SYNC_FL)
+		xflags |= FS_XFLAG_SYNC;
+	if (iflags & EXT4_IMMUTABLE_FL)
+		xflags |= FS_XFLAG_IMMUTABLE;
+	if (iflags & EXT4_APPEND_FL)
+		xflags |= FS_XFLAG_APPEND;
+	if (iflags & EXT4_NODUMP_FL)
+		xflags |= FS_XFLAG_NODUMP;
+	if (iflags & EXT4_NOATIME_FL)
+		xflags |= FS_XFLAG_NOATIME;
+	if (iflags & EXT4_PROJINHERIT_FL)
+		xflags |= FS_XFLAG_PROJINHERIT;
+	return xflags;
+}
+
+/* Transfer xflags flags to internal */
+static inline unsigned long ext4_xflags_to_iflags(__u32 xflags)
+{
+	unsigned long iflags = 0;
+
+	if (xflags & FS_XFLAG_SYNC)
+		iflags |= EXT4_SYNC_FL;
+	if (xflags & FS_XFLAG_IMMUTABLE)
+		iflags |= EXT4_IMMUTABLE_FL;
+	if (xflags & FS_XFLAG_APPEND)
+		iflags |= EXT4_APPEND_FL;
+	if (xflags & FS_XFLAG_NODUMP)
+		iflags |= EXT4_NODUMP_FL;
+	if (xflags & FS_XFLAG_NOATIME)
+		iflags |= EXT4_NOATIME_FL;
+	if (xflags & FS_XFLAG_PROJINHERIT)
+		iflags |= EXT4_PROJINHERIT_FL;
+
+	return iflags;
+}
+
 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -218,11 +442,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
 		return put_user(flags, (int __user *) arg);
 	case EXT4_IOC_SETFLAGS: {
-		handle_t *handle = NULL;
-		int err, migrate = 0;
-		struct ext4_iloc iloc;
-		unsigned int oldflags, mask, i;
-		unsigned int jflag;
+		int err;
 
 		if (!inode_owner_or_capable(inode))
 			return -EACCES;
@@ -236,89 +456,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 		flags = ext4_mask_flags(inode->i_mode, flags);
 
-		err = -EPERM;
 		mutex_lock(&inode->i_mutex);
-		/* Is it quota file? Do not allow user to mess with it */
-		if (IS_NOQUOTA(inode))
-			goto flags_out;
-
-		oldflags = ei->i_flags;
-
-		/* The JOURNAL_DATA flag is modifiable only by root */
-		jflag = flags & EXT4_JOURNAL_DATA_FL;
-
-		/*
-		 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
-		 * the relevant capability.
-		 *
-		 * This test looks nicer. Thanks to Pauline Middelink
-		 */
-		if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
-			if (!capable(CAP_LINUX_IMMUTABLE))
-				goto flags_out;
-		}
-
-		/*
-		 * The JOURNAL_DATA flag can only be changed by
-		 * the relevant capability.
-		 */
-		if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
-			if (!capable(CAP_SYS_RESOURCE))
-				goto flags_out;
-		}
-		if ((flags ^ oldflags) & EXT4_EXTENTS_FL)
-			migrate = 1;
-
-		if (flags & EXT4_EOFBLOCKS_FL) {
-			/* we don't support adding EOFBLOCKS flag */
-			if (!(oldflags & EXT4_EOFBLOCKS_FL)) {
-				err = -EOPNOTSUPP;
-				goto flags_out;
-			}
-		} else if (oldflags & EXT4_EOFBLOCKS_FL)
-			ext4_truncate(inode);
-
-		handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
-		if (IS_ERR(handle)) {
-			err = PTR_ERR(handle);
-			goto flags_out;
-		}
-		if (IS_SYNC(inode))
-			ext4_handle_sync(handle);
-		err = ext4_reserve_inode_write(handle, inode, &iloc);
-		if (err)
-			goto flags_err;
-
-		for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {
-			if (!(mask & EXT4_FL_USER_MODIFIABLE))
-				continue;
-			if (mask & flags)
-				ext4_set_inode_flag(inode, i);
-			else
-				ext4_clear_inode_flag(inode, i);
-		}
-
-		ext4_set_inode_flags(inode);
-		inode->i_ctime = ext4_current_time(inode);
-
-		err = ext4_mark_iloc_dirty(handle, inode, &iloc);
-flags_err:
-		ext4_journal_stop(handle);
-		if (err)
-			goto flags_out;
-
-		if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
-			err = ext4_change_inode_journal_flag(inode, jflag);
-		if (err)
-			goto flags_out;
-		if (migrate) {
-			if (flags & EXT4_EXTENTS_FL)
-				err = ext4_ext_migrate(inode);
-			else
-				err = ext4_ind_migrate(inode);
-		}
-
-flags_out:
+		err = ext4_ioctl_setflags(inode, flags);
 		mutex_unlock(&inode->i_mutex);
 		mnt_drop_write_file(filp);
 		return err;
@@ -694,6 +833,60 @@ encryption_policy_out:
 		return -EOPNOTSUPP;
 #endif
 	}
+	case EXT4_IOC_FSGETXATTR:
+	{
+		struct fsxattr fa;
+
+		memset(&fa, 0, sizeof(struct fsxattr));
+		ext4_get_inode_flags(ei);
+		fa.fsx_xflags = ext4_iflags_to_xflags(ei->i_flags & EXT4_FL_USER_VISIBLE);
+
+		if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+				EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+			fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
+				EXT4_I(inode)->i_projid);
+		}
+
+		if (copy_to_user((struct fsxattr __user *)arg,
+				 &fa, sizeof(fa)))
+			return -EFAULT;
+		return 0;
+	}
+	case EXT4_IOC_FSSETXATTR:
+	{
+		struct fsxattr fa;
+		int err;
+
+		if (copy_from_user(&fa, (struct fsxattr __user *)arg,
+				   sizeof(fa)))
+			return -EFAULT;
+
+		/* Make sure caller has proper permission */
+		if (!inode_owner_or_capable(inode))
+			return -EACCES;
+
+		err = mnt_want_write_file(filp);
+		if (err)
+			return err;
+
+		flags = ext4_xflags_to_iflags(fa.fsx_xflags);
+		flags = ext4_mask_flags(inode->i_mode, flags);
+
+		mutex_lock(&inode->i_mutex);
+		flags = (ei->i_flags & ~EXT4_FL_XFLAG_VISIBLE) |
+			 (flags & EXT4_FL_XFLAG_VISIBLE);
+		err = ext4_ioctl_setflags(inode, flags);
+		mutex_unlock(&inode->i_mutex);
+		mnt_drop_write_file(filp);
+		if (err)
+			return err;
+
+		err = ext4_ioctl_setproject(filp, fa.fsx_projid);
+		if (err)
+			return err;
+
+		return 0;
+	}
 	default:
 		return -ENOTTY;
 	}
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index 89689c6..115d317 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -36,38 +36,25 @@ struct dioattr {
 #endif
 
 /*
- * Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR.
- */
-#ifndef HAVE_FSXATTR
-struct fsxattr {
-	__u32		fsx_xflags;	/* xflags field value (get/set) */
-	__u32		fsx_extsize;	/* extsize field value (get/set)*/
-	__u32		fsx_nextents;	/* nextents field value (get)	*/
-	__u32		fsx_projid;	/* project identifier (get/set) */
-	unsigned char	fsx_pad[12];
-};
-#endif
-
-/*
  * Flags for the bs_xflags/fsx_xflags field
  * There should be a one-to-one correspondence between these flags and the
  * XFS_DIFLAG_s.
  */
-#define XFS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
-#define XFS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
-#define XFS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
-#define XFS_XFLAG_APPEND	0x00000010	/* all writes append */
-#define XFS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
-#define XFS_XFLAG_NOATIME	0x00000040	/* do not update access time */
-#define XFS_XFLAG_NODUMP	0x00000080	/* do not include in backups */
-#define XFS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
-#define XFS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
-#define XFS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
-#define XFS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
-#define XFS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
-#define XFS_XFLAG_NODEFRAG	0x00002000  	/* do not defragment */
-#define XFS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
-#define XFS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
+#define XFS_XFLAG_REALTIME	FS_XFLAG_REALTIME	/* data in realtime volume */
+#define XFS_XFLAG_PREALLOC	FS_XFLAG_PREALLOC	/* preallocated file extents */
+#define XFS_XFLAG_IMMUTABLE	FS_XFLAG_IMMUTABLE	/* file cannot be modified */
+#define XFS_XFLAG_APPEND	FS_XFLAG_APPEND		/* all writes append */
+#define XFS_XFLAG_SYNC		FS_XFLAG_SYNC		/* all writes synchronous */
+#define XFS_XFLAG_NOATIME	FS_XFLAG_NOATIME	/* do not update access time */
+#define XFS_XFLAG_NODUMP	FS_XFLAG_NODUMP		/* do not include in backups */
+#define XFS_XFLAG_RTINHERIT	FS_XFLAG_RTINHERIT	/* create with rt bit set */
+#define XFS_XFLAG_PROJINHERIT	FS_XFLAG_PROJINHERIT	/* create with parents projid */
+#define XFS_XFLAG_NOSYMLINKS	FS_XFLAG_NOSYMLINKS	/* disallow symlink creation */
+#define XFS_XFLAG_EXTSIZE	FS_XFLAG_EXTSIZE	/* extent size allocator hint */
+#define XFS_XFLAG_EXTSZINHERIT	FS_XFLAG_EXTSZINHERIT	/* inherit inode extent size */
+#define XFS_XFLAG_NODEFRAG	FS_XFLAG_NODEFRAG  	/* do not defragment */
+#define XFS_XFLAG_FILESTREAM	FS_XFLAG_FILESTREAM	/* use filestream allocator */
+#define XFS_XFLAG_HASATTR	FS_XFLAG_HASATTR	/* no DIFLAG for this	*/
 
 /*
  * Structure for XFS_IOC_GETBMAP.
@@ -504,8 +491,8 @@ typedef struct xfs_swapext
 #define XFS_IOC_ALLOCSP		_IOW ('X', 10, struct xfs_flock64)
 #define XFS_IOC_FREESP		_IOW ('X', 11, struct xfs_flock64)
 #define XFS_IOC_DIOINFO		_IOR ('X', 30, struct dioattr)
-#define XFS_IOC_FSGETXATTR	_IOR ('X', 31, struct fsxattr)
-#define XFS_IOC_FSSETXATTR	_IOW ('X', 32, struct fsxattr)
+#define XFS_IOC_FSGETXATTR	FS_IOC_FSGETXATTR
+#define XFS_IOC_FSSETXATTR	FS_IOC_FSSETXATTR
 #define XFS_IOC_ALLOCSP64	_IOW ('X', 36, struct xfs_flock64)
 #define XFS_IOC_FREESP64	_IOW ('X', 37, struct xfs_flock64)
 #define XFS_IOC_GETBMAP		_IOWR('X', 38, struct getbmap)
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index f15d980..627f58e 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -58,6 +58,36 @@ struct inodes_stat_t {
 	long dummy[5];		/* padding for sysctl ABI compatibility */
 };
 
+/*
+ * Structure for FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR.
+ */
+struct fsxattr {
+	__u32		fsx_xflags;	/* xflags field value (get/set) */
+	__u32		fsx_extsize;	/* extsize field value (get/set)*/
+	__u32		fsx_nextents;	/* nextents field value (get)	*/
+	__u32		fsx_projid;	/* project identifier (get/set) */
+	unsigned char	fsx_pad[12];
+};
+
+/*
+ * Flags for the fsx_xflags field
+ */
+#define FS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
+#define FS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
+#define FS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
+#define FS_XFLAG_APPEND		0x00000010	/* all writes append */
+#define FS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
+#define FS_XFLAG_NOATIME	0x00000040	/* do not update access time */
+#define FS_XFLAG_NODUMP		0x00000080	/* do not include in backups */
+#define FS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
+#define FS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
+#define FS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
+#define FS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
+#define FS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
+#define FS_XFLAG_NODEFRAG	0x00002000  	/* do not defragment */
+#define FS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
+#define FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this */
+
 
 #define NR_FILE  8192	/* this can well be larger on a larger system */
 
@@ -165,6 +195,8 @@ struct inodes_stat_t {
 #define	FS_IOC_GETVERSION		_IOR('v', 1, long)
 #define	FS_IOC_SETVERSION		_IOW('v', 2, long)
 #define FS_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
+#define FS_IOC_FSGETXATTR		_IOR('X', 31, struct fsxattr)
+#define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)
 #define FS_IOC32_GETFLAGS		_IOR('f', 1, int)
 #define FS_IOC32_SETFLAGS		_IOW('f', 2, int)
 #define FS_IOC32_GETVERSION		_IOR('v', 1, int)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [v15 4/4] ext4: cleanup inode flag definitions
  2015-09-13 12:20 [v15 0/4] ext4: add project quota support Li Xi
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
  2015-09-13 12:20 ` [v15 3/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support Li Xi
@ 2015-09-13 12:20 ` Li Xi
  2015-12-28 15:23     ` Theodore Ts'o
  2015-09-23 12:31 ` [v15 0/4] ext4: add project quota support Jan Kara
  2015-10-18  1:01 ` Theodore Ts'o
  4 siblings, 1 reply; 45+ messages in thread
From: Li Xi @ 2015-09-13 12:20 UTC (permalink / raw)
  To: linux-fsdevel, linux-ext4, linux-api, tytso, adilger, jack, viro,
	hch, dmonakhov

The inode flags defined in uapi/linux/fs.h were migrated from
ext4.h. This patch changes the inode flag definitions in ext4.h
to VFS definitions to make the gaps between them clearer.

Signed-off-by: Li Xi <lixi@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
---
 fs/ext4/ext4.h |   50 +++++++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 6e45175..170faa3 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -348,34 +348,34 @@ struct flex_groups {
 /*
  * Inode flags
  */
-#define	EXT4_SECRM_FL			0x00000001 /* Secure deletion */
-#define	EXT4_UNRM_FL			0x00000002 /* Undelete */
-#define	EXT4_COMPR_FL			0x00000004 /* Compress file */
-#define EXT4_SYNC_FL			0x00000008 /* Synchronous updates */
-#define EXT4_IMMUTABLE_FL		0x00000010 /* Immutable file */
-#define EXT4_APPEND_FL			0x00000020 /* writes to file may only append */
-#define EXT4_NODUMP_FL			0x00000040 /* do not dump file */
-#define EXT4_NOATIME_FL			0x00000080 /* do not update atime */
+#define	EXT4_SECRM_FL			FS_SECRM_FL        /* Secure deletion */
+#define	EXT4_UNRM_FL			FS_UNRM_FL         /* Undelete */
+#define	EXT4_COMPR_FL			FS_COMPR_FL        /* Compress file */
+#define EXT4_SYNC_FL			FS_SYNC_FL         /* Synchronous updates */
+#define EXT4_IMMUTABLE_FL		FS_IMMUTABLE_FL    /* Immutable file */
+#define EXT4_APPEND_FL			FS_APPEND_FL       /* writes to file may only append */
+#define EXT4_NODUMP_FL			FS_NODUMP_FL       /* do not dump file */
+#define EXT4_NOATIME_FL			FS_NOATIME_FL      /* do not update atime */
 /* Reserved for compression usage... */
-#define EXT4_DIRTY_FL			0x00000100
-#define EXT4_COMPRBLK_FL		0x00000200 /* One or more compressed clusters */
-#define EXT4_NOCOMPR_FL			0x00000400 /* Don't compress */
+#define EXT4_DIRTY_FL			FS_DIRTY_FL
+#define EXT4_COMPRBLK_FL		FS_COMPRBLK_FL     /* One or more compressed clusters */
+#define EXT4_NOCOMPR_FL			FS_NOCOMP_FL       /* Don't compress */
 	/* nb: was previously EXT2_ECOMPR_FL */
-#define EXT4_ENCRYPT_FL			0x00000800 /* encrypted file */
+#define EXT4_ENCRYPT_FL			0x00000800         /* encrypted file */
 /* End compression flags --- maybe not all used */
-#define EXT4_INDEX_FL			0x00001000 /* hash-indexed directory */
-#define EXT4_IMAGIC_FL			0x00002000 /* AFS directory */
-#define EXT4_JOURNAL_DATA_FL		0x00004000 /* file data should be journaled */
-#define EXT4_NOTAIL_FL			0x00008000 /* file tail should not be merged */
-#define EXT4_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
-#define EXT4_TOPDIR_FL			0x00020000 /* Top of directory hierarchies*/
-#define EXT4_HUGE_FILE_FL               0x00040000 /* Set to each huge file */
-#define EXT4_EXTENTS_FL			0x00080000 /* Inode uses extents */
-#define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
-#define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
-#define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
-#define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
-#define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
+#define EXT4_INDEX_FL			FS_INDEX_FL        /* hash-indexed directory */
+#define EXT4_IMAGIC_FL			FS_IMAGIC_FL       /* AFS directory */
+#define EXT4_JOURNAL_DATA_FL		FS_JOURNAL_DATA_FL /* file data should be journaled */
+#define EXT4_NOTAIL_FL			FS_NOTAIL_FL       /* file tail should not be merged */
+#define EXT4_DIRSYNC_FL			FS_DIRSYNC_FL      /* dirsync behaviour (directories only) */
+#define EXT4_TOPDIR_FL			FS_TOPDIR_FL       /* Top of directory hierarchies*/
+#define EXT4_HUGE_FILE_FL               0x00040000         /* Set to each huge file */
+#define EXT4_EXTENTS_FL			FS_EXTENT_FL       /* Inode uses extents */
+#define EXT4_EA_INODE_FL	        0x00200000         /* Inode used for large EA */
+#define EXT4_EOFBLOCKS_FL		0x00400000         /* Blocks allocated beyond EOF */
+#define EXT4_INLINE_DATA_FL		0x10000000         /* Inode has inline data. */
+#define EXT4_PROJINHERIT_FL		FS_PROJINHERIT_FL  /* Create with parents projid */
+#define EXT4_RESERVED_FL		FS_RESERVED_FL     /* reserved for ext4 lib */
 
 #define EXT4_FL_USER_VISIBLE		0x304BDFFF /* User visible flags */
 #define EXT4_FL_USER_MODIFIABLE		0x204380FF /* User modifiable flags */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-09-13 12:20 [v15 0/4] ext4: add project quota support Li Xi
                   ` (2 preceding siblings ...)
  2015-09-13 12:20 ` [v15 4/4] ext4: cleanup inode flag definitions Li Xi
@ 2015-09-23 12:31 ` Jan Kara
       [not found]   ` <20150923123119.GA13946-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
  2015-10-18  1:01 ` Theodore Ts'o
  4 siblings, 1 reply; 45+ messages in thread
From: Jan Kara @ 2015-09-23 12:31 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel, linux-ext4, linux-api, tytso, adilger, jack, viro,
	hch, dmonakhov

On Sun 13-09-15 21:20:29, Li Xi wrote:
> The following patches propose an implementation of project quota
> support for ext4. A project is an aggregate of unrelated inodes
> which might scatter in different directories. Inodes that belong
> to the same project possess an identical identification i.e.
> 'project ID', just like every inode has its user/group
> identification. The following patches add project quota as
> supplement to the former uer/group quota types.

With the last version of the patches, there was only one outstanding issue
and that was whether xfstests for XFS pass correctly (especially the
project quota related ones). Have you been able to verify this?

								Honza

> 
> The semantics of ext4 project quota is consistent with XFS. Each
> directory can have EXT4_INODE_PROJINHERIT flag set. When the
> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
> newly created inode under that directory will have a default project
> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
> When this flag is set on a directory, following rules will be kept:
> 
> 1) The newly created inode under that directory will inherit both
> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
> directory.
> 
> 2) Hard-linking a inode with different project ID into that directory
> will fail with errno EXDEV.
> 
> 3) Renaming a inode with different project ID into that directory
> will fail with errno EXDEV. However, 'mv' command will detect this
> failure and copy the renamed inode to a new inode in the directory.
> Thus, this new inode will inherit both the project ID and
> EXT4_INODE_PROJINHERIT flag.
> 
> 4) If the project quota of that ID is being enforced, statfs() on
> that directory will take the quotas as another upper limits along
> with the capacity of the file system, i.e. the total block/inode
> number will be the minimum of the quota limits and file system
> capacity.
> 
> Changelog:
> * v15 <- v14:
>  - Rebase to newest master branch of git repository (b0a1ea51b).
> * v14 <- v13:
>  - Cleanup ioctl of setting project ID;
>  - Do not check project quota inode number specially;
>  - Check isize when extract project ID from disk;
>  - Rebase to latest kernel (4.0.0)
> * v13 <- v12:
>  - Update inode size check of project ID.
> * v12 <- v11:
>  - Relax the permission check when setting project ID.
> * v11 <- v10:
>  - Remove project quota mount option;
>  - Fix permission check when setting project ID.
> * v10 <- v9:
>  - Remove non-journaled project quota interface;
>  - Only allow admin to read project quota info;
>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
> * v9 <- v8:
>  - Remove non-journaled project quota;
>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
> * v8 <- v7:
>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
> * v7 <- v6:
>  - Map ext4 inode flags to xflags of struct fsxattr;
>  - Add patch to cleanup ext4 inode flag definitions.
> * v6 <- v5:
>  - Add project ID check for cross rename;
>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
> * v5 <- v4:
>  - Check project feature when set/get project ID;
>  - Do not check project feature for project quota;
>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
> * v4 <- v3:
>  - Do not check project feature when set/get project ID;
>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>  - Remove unnecessary change of fs/quota/dquot.c;
>  - Remove CONFIG_QUOTA_PROJECT.
> * v3 <- v2:
>  - Add EXT4_INODE_PROJINHERIT semantics.
> * v2 <- v1:
>  - Add ioctl interface for setting/getting project;
>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>  - Add get_projid() method in struct dquot_operations;
>  - Add error check of ext4_inode_projid_set/get().
> 
> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
> v5: http://www.spinics.net/lists/linux-api/msg04840.html
> v4: http://lwn.net/Articles/612972/
> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
> 
> Any comments or feedbacks are appreciated.
> 
> Regards,
>                                          - Li Xi
> 
> Li Xi (4):
>   ext4: adds project ID support
>   ext4: adds project quota support
>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>   ext4: cleanup inode flag definitions
> 
>  fs/ext4/ext4.h          |   85 +++++++----
>  fs/ext4/ialloc.c        |    7 +
>  fs/ext4/inode.c         |   28 ++++
>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>  fs/ext4/namei.c         |   19 +++
>  fs/ext4/super.c         |   57 +++++++-
>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>  include/uapi/linux/fs.h |   33 +++++
>  8 files changed, 490 insertions(+), 153 deletions(-)
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 1/4] ext4: adds project ID support
       [not found]     ` <1442146833-13652-2-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
@ 2015-09-23 12:34       ` Dmitry Monakhov
  2015-09-23 18:17         ` Jan Kara
  0 siblings, 1 reply; 45+ messages in thread
From: Dmitry Monakhov @ 2015-09-23 12:34 UTC (permalink / raw)
  To: Li Xi, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, tytso-3s7WtUTddSA,
	adilger-m1MBpc4rdrD3fQ9qLvQP4Q, jack-AlSwsSmVLrQ,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ

[-- Attachment #1: Type: text/plain, Size: 11339 bytes --]

Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> This patch adds a new internal field of ext4 inode to save project
> identifier. Also a new flag EXT4_INODE_PROJINHERIT is added for
> inheriting project ID from parent directory.
>
> Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
> Reviewed-by: Andreas Dilger <adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>
> Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
> ---
>  fs/ext4/ext4.h          |   21 +++++++++++++++++----
>  fs/ext4/ialloc.c        |    7 +++++++
>  fs/ext4/inode.c         |   28 ++++++++++++++++++++++++++++
>  fs/ext4/namei.c         |   19 +++++++++++++++++++
>  fs/ext4/super.c         |    1 +
>  include/uapi/linux/fs.h |    1 +
>  6 files changed, 73 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index fd1f28b..96d6e4c 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -374,16 +374,18 @@ struct flex_groups {
>  #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
>  #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
>  #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
> +#define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
>  #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
>  
> -#define EXT4_FL_USER_VISIBLE		0x004BDFFF /* User visible flags */
> -#define EXT4_FL_USER_MODIFIABLE		0x004380FF /* User modifiable flags */
> +#define EXT4_FL_USER_VISIBLE		0x304BDFFF /* User visible flags */
> +#define EXT4_FL_USER_MODIFIABLE		0x204380FF /* User modifiable flags */
>  
>  /* Flags that should be inherited by new inodes from their parent. */
>  #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\
>  			   EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\
>  			   EXT4_NOCOMPR_FL | EXT4_JOURNAL_DATA_FL |\
> -			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL)
> +			   EXT4_NOTAIL_FL | EXT4_DIRSYNC_FL |\
> +			   EXT4_PROJINHERIT_FL)
>  
>  /* Flags that are appropriate for regular files (all but dir-specific ones). */
>  #define EXT4_REG_FLMASK (~(EXT4_DIRSYNC_FL | EXT4_TOPDIR_FL))
> @@ -431,6 +433,7 @@ enum {
>  	EXT4_INODE_EA_INODE	= 21,	/* Inode used for large EA */
>  	EXT4_INODE_EOFBLOCKS	= 22,	/* Blocks allocated beyond EOF */
>  	EXT4_INODE_INLINE_DATA	= 28,	/* Data in inode. */
> +	EXT4_INODE_PROJINHERIT	= 29,	/* Create with parents projid */
>  	EXT4_INODE_RESERVED	= 31,	/* reserved for ext4 lib */
>  };
>  
> @@ -692,6 +695,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 */
So you are about to extend dist_inode structure(not xattr). I do understand that
his is ridiculous question for 15'th version of the patch, but still.
Personally I think that his is good idea, but can not find a
confirmation from Theodore and Jan that they are agree with that.
Guys please ACK that statement explicitly,so later we can  refer on this mail as decision made.
>  };
>  
>  struct move_extent {
> @@ -952,6 +956,7 @@ struct ext4_inode_info {
>  	/* Encryption params */
>  	struct ext4_crypt_info *i_crypt_info;
>  #endif
> +	kprojid_t i_projid;
>  };
>  
>  /*
> @@ -1566,6 +1571,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
>   */
>  #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
>  #define EXT4_FEATURE_RO_COMPAT_READONLY		0x1000
> +#define EXT4_FEATURE_RO_COMPAT_PROJECT		0x2000
>  
>  #define EXT4_FEATURE_INCOMPAT_COMPRESSION	0x0001
>  #define EXT4_FEATURE_INCOMPAT_FILETYPE		0x0002
> @@ -1617,7 +1623,8 @@ static inline int ext4_encrypted_inode(struct inode *inode)
>  					 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
> @@ -1625,6 +1632,11 @@ static inline int ext4_encrypted_inode(struct inode *inode)
>  #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
>  
>  /*
> @@ -2317,6 +2329,7 @@ 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 void ext4_da_update_reserve_space(struct inode *inode,
>  					int used, int quota_claim);
>  
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index 619bfc1..692b50f 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -769,6 +769,13 @@ 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) &&
> +	    ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT))
> +		ei->i_projid = EXT4_I(dir)->i_projid;
> +	else
> +		ei->i_projid = make_kprojid(&init_user_ns, EXT4_DEF_PROJID);
> +
>  	err = dquot_initialize(inode);
>  	if (err)
>  		goto out;
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 612fbcf..5836a3d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4035,6 +4035,14 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
>  		EXT4_I(inode)->i_inline_off = 0;
>  }
>  
> +int ext4_get_projid(struct inode *inode, kprojid_t *projid)
> +{
> +	if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_RO_COMPAT_PROJECT))
> +		return -EOPNOTSUPP;
> +	*projid = EXT4_I(inode)->i_projid;
> +	return 0;
> +}
> +
>  struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>  {
>  	struct ext4_iloc iloc;
> @@ -4046,6 +4054,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>  	int block;
>  	uid_t i_uid;
>  	gid_t i_gid;
> +	projid_t i_projid;
>  
>  	inode = iget_locked(sb, ino);
>  	if (!inode)
> @@ -4095,12 +4104,20 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>  	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
>  	i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
>  	i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
> +	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT) &&
> +	    EXT4_INODE_SIZE(sb) > EXT4_GOOD_OLD_INODE_SIZE &&
> +	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
> +		i_projid = (projid_t)le32_to_cpu(raw_inode->i_projid);
> +	else
> +		i_projid = EXT4_DEF_PROJID;
> +
>  	if (!(test_opt(inode->i_sb, NO_UID32))) {
>  		i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
>  		i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
>  	}
>  	i_uid_write(inode, i_uid);
>  	i_gid_write(inode, i_gid);
> +	ei->i_projid = make_kprojid(&init_user_ns, i_projid);
>  	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
>  
>  	ext4_clear_state_flags(ei);	/* Only relevant on 32-bit archs */
> @@ -4398,6 +4415,7 @@ static int ext4_do_update_inode(handle_t *handle,
>  	int need_datasync = 0, set_large_file = 0;
>  	uid_t i_uid;
>  	gid_t i_gid;
> +	projid_t i_projid;
>  
>  	spin_lock(&ei->i_raw_lock);
>  
> @@ -4410,6 +4428,7 @@ static int ext4_do_update_inode(handle_t *handle,
>  	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
>  	i_uid = i_uid_read(inode);
>  	i_gid = i_gid_read(inode);
> +	i_projid = from_kprojid(&init_user_ns, ei->i_projid);
>  	if (!(test_opt(inode->i_sb, NO_UID32))) {
>  		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
>  		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
> @@ -4488,6 +4507,15 @@ static int ext4_do_update_inode(handle_t *handle,
>  				cpu_to_le16(ei->i_extra_isize);
>  		}
>  	}
> +
> +	BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
> +			EXT4_FEATURE_RO_COMPAT_PROJECT) &&
> +	       i_projid != EXT4_DEF_PROJID);
> +
> +	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
> +	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
> +		raw_inode->i_projid = cpu_to_le32(i_projid);
> +
>  	ext4_inode_csum_set(inode, raw_inode, ei);
>  	spin_unlock(&ei->i_raw_lock);
>  	if (inode->i_sb->s_flags & MS_LAZYTIME)
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 9f61e76..61694ad 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -3215,6 +3215,12 @@ static int ext4_link(struct dentry *old_dentry,
>  	if (ext4_encrypted_inode(dir) &&
>  	    !ext4_is_child_context_consistent_with_parent(dir, inode))
>  		return -EPERM;
> +
> +       if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
> +	   (!projid_eq(EXT4_I(dir)->i_projid,
> +		       EXT4_I(old_dentry->d_inode)->i_projid)))
> +		return -EXDEV;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -3496,6 +3502,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	int credits;
>  	u8 old_file_type;
>  
> +	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT)) &&
> +	    (!projid_eq(EXT4_I(new_dir)->i_projid,
> +			EXT4_I(old_dentry->d_inode)->i_projid)))
> +		return -EXDEV;
> +
>  	retval = dquot_initialize(old.dir);
>  	if (retval)
>  		return retval;
> @@ -3705,6 +3716,14 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  							   new.inode)))
>  		return -EPERM;
>  
> +	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
> +	     !projid_eq(EXT4_I(new_dir)->i_projid,
> +			EXT4_I(old_dentry->d_inode)->i_projid)) ||
> +	    (ext4_test_inode_flag(old_dir, EXT4_INODE_PROJINHERIT) &&
> +	     !projid_eq(EXT4_I(old_dir)->i_projid,
> +			EXT4_I(new_dentry->d_inode)->i_projid)))
> +		return -EXDEV;
> +
>  	retval = dquot_initialize(old.dir);
>  	if (retval)
>  		return retval;
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index a63c7b0..d07445e 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1097,6 +1097,7 @@ static const struct dquot_operations ext4_quota_operations = {
>  	.write_info	= ext4_write_info,
>  	.alloc_dquot	= dquot_alloc,
>  	.destroy_dquot	= dquot_destroy,
> +	.get_projid	= ext4_get_projid,
>  };
>  
>  static const struct quotactl_ops ext4_qctl_operations = {
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index 9b964a5..f15d980 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -197,6 +197,7 @@ struct inodes_stat_t {
>  #define FS_EXTENT_FL			0x00080000 /* Extents */
>  #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
>  #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
> +#define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
>  #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
>  
>  #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
> -- 
> 1.7.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found]   ` <20150923123119.GA13946-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
@ 2015-09-23 13:17     ` Li Xi
       [not found]       ` <CAPTn0cBB7h89R7NB+zg+J+TVvKXut_Usixs==S=AWs-v7kZExg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 45+ messages in thread
From: Li Xi @ 2015-09-23 13:17 UTC (permalink / raw)
  To: Jan Kara
  Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Ext4 Developers List,
	linux-api-u79uwXL29TY76Z2rM5mHXA, Theodore Ts'o,
	Andreas Dilger, viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, Dmitry Monakhov

Hi Jan Kara,

Sorry, I forgot to mention that we run the xfstests for both XFS and
Ext4 with and without these patches. And still, some (but not too
many) of the tests fails, but the failed tests are the same no matter
the patches are applied or not. And we didn't see any project quota
related tests fails.

Regards,
Li Xi

On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
> On Sun 13-09-15 21:20:29, Li Xi wrote:
>> The following patches propose an implementation of project quota
>> support for ext4. A project is an aggregate of unrelated inodes
>> which might scatter in different directories. Inodes that belong
>> to the same project possess an identical identification i.e.
>> 'project ID', just like every inode has its user/group
>> identification. The following patches add project quota as
>> supplement to the former uer/group quota types.
>
> With the last version of the patches, there was only one outstanding issue
> and that was whether xfstests for XFS pass correctly (especially the
> project quota related ones). Have you been able to verify this?
>
>                                                                 Honza
>
>>
>> The semantics of ext4 project quota is consistent with XFS. Each
>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>> newly created inode under that directory will have a default project
>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>> When this flag is set on a directory, following rules will be kept:
>>
>> 1) The newly created inode under that directory will inherit both
>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>> directory.
>>
>> 2) Hard-linking a inode with different project ID into that directory
>> will fail with errno EXDEV.
>>
>> 3) Renaming a inode with different project ID into that directory
>> will fail with errno EXDEV. However, 'mv' command will detect this
>> failure and copy the renamed inode to a new inode in the directory.
>> Thus, this new inode will inherit both the project ID and
>> EXT4_INODE_PROJINHERIT flag.
>>
>> 4) If the project quota of that ID is being enforced, statfs() on
>> that directory will take the quotas as another upper limits along
>> with the capacity of the file system, i.e. the total block/inode
>> number will be the minimum of the quota limits and file system
>> capacity.
>>
>> Changelog:
>> * v15 <- v14:
>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>> * v14 <- v13:
>>  - Cleanup ioctl of setting project ID;
>>  - Do not check project quota inode number specially;
>>  - Check isize when extract project ID from disk;
>>  - Rebase to latest kernel (4.0.0)
>> * v13 <- v12:
>>  - Update inode size check of project ID.
>> * v12 <- v11:
>>  - Relax the permission check when setting project ID.
>> * v11 <- v10:
>>  - Remove project quota mount option;
>>  - Fix permission check when setting project ID.
>> * v10 <- v9:
>>  - Remove non-journaled project quota interface;
>>  - Only allow admin to read project quota info;
>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>> * v9 <- v8:
>>  - Remove non-journaled project quota;
>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>> * v8 <- v7:
>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>> * v7 <- v6:
>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>  - Add patch to cleanup ext4 inode flag definitions.
>> * v6 <- v5:
>>  - Add project ID check for cross rename;
>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>> * v5 <- v4:
>>  - Check project feature when set/get project ID;
>>  - Do not check project feature for project quota;
>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>> * v4 <- v3:
>>  - Do not check project feature when set/get project ID;
>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>  - Remove unnecessary change of fs/quota/dquot.c;
>>  - Remove CONFIG_QUOTA_PROJECT.
>> * v3 <- v2:
>>  - Add EXT4_INODE_PROJINHERIT semantics.
>> * v2 <- v1:
>>  - Add ioctl interface for setting/getting project;
>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>  - Add get_projid() method in struct dquot_operations;
>>  - Add error check of ext4_inode_projid_set/get().
>>
>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>> v4: http://lwn.net/Articles/612972/
>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>
>> Any comments or feedbacks are appreciated.
>>
>> Regards,
>>                                          - Li Xi
>>
>> Li Xi (4):
>>   ext4: adds project ID support
>>   ext4: adds project quota support
>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>   ext4: cleanup inode flag definitions
>>
>>  fs/ext4/ext4.h          |   85 +++++++----
>>  fs/ext4/ialloc.c        |    7 +
>>  fs/ext4/inode.c         |   28 ++++
>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>  fs/ext4/namei.c         |   19 +++
>>  fs/ext4/super.c         |   57 +++++++-
>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>  include/uapi/linux/fs.h |   33 +++++
>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>
> --
> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
> SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found]       ` <CAPTn0cBB7h89R7NB+zg+J+TVvKXut_Usixs==S=AWs-v7kZExg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-09-23 13:32           ` Dmitry Monakhov
  0 siblings, 0 replies; 45+ messages in thread
From: Dmitry Monakhov @ 2015-09-23 13:32 UTC (permalink / raw)
  To: Li Xi, Jan Kara
  Cc: linux-fsdevel@vger.kernel.org, Ext4 Developers List,
	linux-api@vger.kernel.org, Theodore Ts'o, Andreas Dilger,
	viro@zeniv.linux.org.uk, hch@infradead.org

[-- Attachment #1: Type: text/plain, Size: 6303 bytes --]

Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi Jan Kara,
>
> Sorry, I forgot to mention that we run the xfstests for both XFS and
> Ext4 with and without these patches. And still, some (but not too
> many) of the tests fails, but the failed tests are the same no matter
> the patches are applied or not. And we didn't see any project quota
> related tests fails.
BTW. Where I can find userspace tools to play with this feature?
>
> Regards,
> Li Xi
>
> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>> The following patches propose an implementation of project quota
>>> support for ext4. A project is an aggregate of unrelated inodes
>>> which might scatter in different directories. Inodes that belong
>>> to the same project possess an identical identification i.e.
>>> 'project ID', just like every inode has its user/group
>>> identification. The following patches add project quota as
>>> supplement to the former uer/group quota types.
>>
>> With the last version of the patches, there was only one outstanding issue
>> and that was whether xfstests for XFS pass correctly (especially the
>> project quota related ones). Have you been able to verify this?
>>
>>                                                                 Honza
>>
>>>
>>> The semantics of ext4 project quota is consistent with XFS. Each
>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>> newly created inode under that directory will have a default project
>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>> When this flag is set on a directory, following rules will be kept:
>>>
>>> 1) The newly created inode under that directory will inherit both
>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>> directory.
>>>
>>> 2) Hard-linking a inode with different project ID into that directory
>>> will fail with errno EXDEV.
>>>
>>> 3) Renaming a inode with different project ID into that directory
>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>> failure and copy the renamed inode to a new inode in the directory.
>>> Thus, this new inode will inherit both the project ID and
>>> EXT4_INODE_PROJINHERIT flag.
>>>
>>> 4) If the project quota of that ID is being enforced, statfs() on
>>> that directory will take the quotas as another upper limits along
>>> with the capacity of the file system, i.e. the total block/inode
>>> number will be the minimum of the quota limits and file system
>>> capacity.
>>>
>>> Changelog:
>>> * v15 <- v14:
>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>> * v14 <- v13:
>>>  - Cleanup ioctl of setting project ID;
>>>  - Do not check project quota inode number specially;
>>>  - Check isize when extract project ID from disk;
>>>  - Rebase to latest kernel (4.0.0)
>>> * v13 <- v12:
>>>  - Update inode size check of project ID.
>>> * v12 <- v11:
>>>  - Relax the permission check when setting project ID.
>>> * v11 <- v10:
>>>  - Remove project quota mount option;
>>>  - Fix permission check when setting project ID.
>>> * v10 <- v9:
>>>  - Remove non-journaled project quota interface;
>>>  - Only allow admin to read project quota info;
>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>> * v9 <- v8:
>>>  - Remove non-journaled project quota;
>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>> * v8 <- v7:
>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>> * v7 <- v6:
>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>  - Add patch to cleanup ext4 inode flag definitions.
>>> * v6 <- v5:
>>>  - Add project ID check for cross rename;
>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>> * v5 <- v4:
>>>  - Check project feature when set/get project ID;
>>>  - Do not check project feature for project quota;
>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>> * v4 <- v3:
>>>  - Do not check project feature when set/get project ID;
>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>  - Remove CONFIG_QUOTA_PROJECT.
>>> * v3 <- v2:
>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>> * v2 <- v1:
>>>  - Add ioctl interface for setting/getting project;
>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>  - Add get_projid() method in struct dquot_operations;
>>>  - Add error check of ext4_inode_projid_set/get().
>>>
>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>> v4: http://lwn.net/Articles/612972/
>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>
>>> Any comments or feedbacks are appreciated.
>>>
>>> Regards,
>>>                                          - Li Xi
>>>
>>> Li Xi (4):
>>>   ext4: adds project ID support
>>>   ext4: adds project quota support
>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>   ext4: cleanup inode flag definitions
>>>
>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>  fs/ext4/ialloc.c        |    7 +
>>>  fs/ext4/inode.c         |   28 ++++
>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>  fs/ext4/namei.c         |   19 +++
>>>  fs/ext4/super.c         |   57 +++++++-
>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>  include/uapi/linux/fs.h |   33 +++++
>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>
>> --
>> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
>> SUSE Labs, CR

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-09-23 13:32           ` Dmitry Monakhov
  0 siblings, 0 replies; 45+ messages in thread
From: Dmitry Monakhov @ 2015-09-23 13:32 UTC (permalink / raw)
  To: Li Xi, Jan Kara
  Cc: linux-fsdevel@vger.kernel.org, Ext4 Developers List,
	linux-api@vger.kernel.org, Theodore Ts'o, Andreas Dilger,
	viro@zeniv.linux.org.uk, hch@infradead.org

[-- Attachment #1: Type: text/plain, Size: 6303 bytes --]

Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi Jan Kara,
>
> Sorry, I forgot to mention that we run the xfstests for both XFS and
> Ext4 with and without these patches. And still, some (but not too
> many) of the tests fails, but the failed tests are the same no matter
> the patches are applied or not. And we didn't see any project quota
> related tests fails.
BTW. Where I can find userspace tools to play with this feature?
>
> Regards,
> Li Xi
>
> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>> The following patches propose an implementation of project quota
>>> support for ext4. A project is an aggregate of unrelated inodes
>>> which might scatter in different directories. Inodes that belong
>>> to the same project possess an identical identification i.e.
>>> 'project ID', just like every inode has its user/group
>>> identification. The following patches add project quota as
>>> supplement to the former uer/group quota types.
>>
>> With the last version of the patches, there was only one outstanding issue
>> and that was whether xfstests for XFS pass correctly (especially the
>> project quota related ones). Have you been able to verify this?
>>
>>                                                                 Honza
>>
>>>
>>> The semantics of ext4 project quota is consistent with XFS. Each
>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>> newly created inode under that directory will have a default project
>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>> When this flag is set on a directory, following rules will be kept:
>>>
>>> 1) The newly created inode under that directory will inherit both
>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>> directory.
>>>
>>> 2) Hard-linking a inode with different project ID into that directory
>>> will fail with errno EXDEV.
>>>
>>> 3) Renaming a inode with different project ID into that directory
>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>> failure and copy the renamed inode to a new inode in the directory.
>>> Thus, this new inode will inherit both the project ID and
>>> EXT4_INODE_PROJINHERIT flag.
>>>
>>> 4) If the project quota of that ID is being enforced, statfs() on
>>> that directory will take the quotas as another upper limits along
>>> with the capacity of the file system, i.e. the total block/inode
>>> number will be the minimum of the quota limits and file system
>>> capacity.
>>>
>>> Changelog:
>>> * v15 <- v14:
>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>> * v14 <- v13:
>>>  - Cleanup ioctl of setting project ID;
>>>  - Do not check project quota inode number specially;
>>>  - Check isize when extract project ID from disk;
>>>  - Rebase to latest kernel (4.0.0)
>>> * v13 <- v12:
>>>  - Update inode size check of project ID.
>>> * v12 <- v11:
>>>  - Relax the permission check when setting project ID.
>>> * v11 <- v10:
>>>  - Remove project quota mount option;
>>>  - Fix permission check when setting project ID.
>>> * v10 <- v9:
>>>  - Remove non-journaled project quota interface;
>>>  - Only allow admin to read project quota info;
>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>> * v9 <- v8:
>>>  - Remove non-journaled project quota;
>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>> * v8 <- v7:
>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>> * v7 <- v6:
>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>  - Add patch to cleanup ext4 inode flag definitions.
>>> * v6 <- v5:
>>>  - Add project ID check for cross rename;
>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>> * v5 <- v4:
>>>  - Check project feature when set/get project ID;
>>>  - Do not check project feature for project quota;
>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>> * v4 <- v3:
>>>  - Do not check project feature when set/get project ID;
>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>  - Remove CONFIG_QUOTA_PROJECT.
>>> * v3 <- v2:
>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>> * v2 <- v1:
>>>  - Add ioctl interface for setting/getting project;
>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>  - Add get_projid() method in struct dquot_operations;
>>>  - Add error check of ext4_inode_projid_set/get().
>>>
>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>> v4: http://lwn.net/Articles/612972/
>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>
>>> Any comments or feedbacks are appreciated.
>>>
>>> Regards,
>>>                                          - Li Xi
>>>
>>> Li Xi (4):
>>>   ext4: adds project ID support
>>>   ext4: adds project quota support
>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>   ext4: cleanup inode flag definitions
>>>
>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>  fs/ext4/ialloc.c        |    7 +
>>>  fs/ext4/inode.c         |   28 ++++
>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>  fs/ext4/namei.c         |   19 +++
>>>  fs/ext4/super.c         |   57 +++++++-
>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>  include/uapi/linux/fs.h |   33 +++++
>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>
>> --
>> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
>> SUSE Labs, CR

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-09-23 13:32           ` Dmitry Monakhov
  (?)
@ 2015-09-23 13:57           ` Li Xi
       [not found]             ` <CAPTn0cC=1xWCcUMVqhAx4pvqqX9rXC8p6B4Jt7cpm4HfuaFOMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2015-09-24 12:09             ` Jan Kara
  -1 siblings, 2 replies; 45+ messages in thread
From: Li Xi @ 2015-09-23 13:57 UTC (permalink / raw)
  To: Dmitry Monakhov
  Cc: Jan Kara, linux-fsdevel, Ext4 Developers List, linux-api,
	Theodore Ts'o, Andreas Dilger, viro, hch

Hi Dmitry,

Please check following linkage. It includes all the patches I've made
for ext4 project quota. Unfortunately, multiple tools need to be
patched, including 1) patch e2fsprogs 2) patch quota-tools 3) patch
linux kernel 4) compile project_manage.

Please let me know if there is any problem.

Thanks,
Li Xi

On Wed, Sep 23, 2015 at 9:32 PM, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> Li Xi <pkuelelixi@gmail.com> writes:
>
>> Hi Jan Kara,
>>
>> Sorry, I forgot to mention that we run the xfstests for both XFS and
>> Ext4 with and without these patches. And still, some (but not too
>> many) of the tests fails, but the failed tests are the same no matter
>> the patches are applied or not. And we didn't see any project quota
>> related tests fails.
> BTW. Where I can find userspace tools to play with this feature?
>>
>> Regards,
>> Li Xi
>>
>> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack@suse.cz> wrote:
>>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>>> The following patches propose an implementation of project quota
>>>> support for ext4. A project is an aggregate of unrelated inodes
>>>> which might scatter in different directories. Inodes that belong
>>>> to the same project possess an identical identification i.e.
>>>> 'project ID', just like every inode has its user/group
>>>> identification. The following patches add project quota as
>>>> supplement to the former uer/group quota types.
>>>
>>> With the last version of the patches, there was only one outstanding issue
>>> and that was whether xfstests for XFS pass correctly (especially the
>>> project quota related ones). Have you been able to verify this?
>>>
>>>                                                                 Honza
>>>
>>>>
>>>> The semantics of ext4 project quota is consistent with XFS. Each
>>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>>> newly created inode under that directory will have a default project
>>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>>> When this flag is set on a directory, following rules will be kept:
>>>>
>>>> 1) The newly created inode under that directory will inherit both
>>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>>> directory.
>>>>
>>>> 2) Hard-linking a inode with different project ID into that directory
>>>> will fail with errno EXDEV.
>>>>
>>>> 3) Renaming a inode with different project ID into that directory
>>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>>> failure and copy the renamed inode to a new inode in the directory.
>>>> Thus, this new inode will inherit both the project ID and
>>>> EXT4_INODE_PROJINHERIT flag.
>>>>
>>>> 4) If the project quota of that ID is being enforced, statfs() on
>>>> that directory will take the quotas as another upper limits along
>>>> with the capacity of the file system, i.e. the total block/inode
>>>> number will be the minimum of the quota limits and file system
>>>> capacity.
>>>>
>>>> Changelog:
>>>> * v15 <- v14:
>>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>>> * v14 <- v13:
>>>>  - Cleanup ioctl of setting project ID;
>>>>  - Do not check project quota inode number specially;
>>>>  - Check isize when extract project ID from disk;
>>>>  - Rebase to latest kernel (4.0.0)
>>>> * v13 <- v12:
>>>>  - Update inode size check of project ID.
>>>> * v12 <- v11:
>>>>  - Relax the permission check when setting project ID.
>>>> * v11 <- v10:
>>>>  - Remove project quota mount option;
>>>>  - Fix permission check when setting project ID.
>>>> * v10 <- v9:
>>>>  - Remove non-journaled project quota interface;
>>>>  - Only allow admin to read project quota info;
>>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>>> * v9 <- v8:
>>>>  - Remove non-journaled project quota;
>>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>>> * v8 <- v7:
>>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>>> * v7 <- v6:
>>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>>  - Add patch to cleanup ext4 inode flag definitions.
>>>> * v6 <- v5:
>>>>  - Add project ID check for cross rename;
>>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>>> * v5 <- v4:
>>>>  - Check project feature when set/get project ID;
>>>>  - Do not check project feature for project quota;
>>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>>> * v4 <- v3:
>>>>  - Do not check project feature when set/get project ID;
>>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>>  - Remove CONFIG_QUOTA_PROJECT.
>>>> * v3 <- v2:
>>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>>> * v2 <- v1:
>>>>  - Add ioctl interface for setting/getting project;
>>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>>  - Add get_projid() method in struct dquot_operations;
>>>>  - Add error check of ext4_inode_projid_set/get().
>>>>
>>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>>> v4: http://lwn.net/Articles/612972/
>>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>>
>>>> Any comments or feedbacks are appreciated.
>>>>
>>>> Regards,
>>>>                                          - Li Xi
>>>>
>>>> Li Xi (4):
>>>>   ext4: adds project ID support
>>>>   ext4: adds project quota support
>>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>>   ext4: cleanup inode flag definitions
>>>>
>>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>>  fs/ext4/ialloc.c        |    7 +
>>>>  fs/ext4/inode.c         |   28 ++++
>>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>>  fs/ext4/namei.c         |   19 +++
>>>>  fs/ext4/super.c         |   57 +++++++-
>>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>>  include/uapi/linux/fs.h |   33 +++++
>>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>>
>>> --
>>> Jan Kara <jack@suse.com>
>>> SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found]             ` <CAPTn0cC=1xWCcUMVqhAx4pvqqX9rXC8p6B4Jt7cpm4HfuaFOMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-09-23 13:58               ` Li Xi
  2015-09-23 14:13                 ` Dmitry Monakhov
  1 sibling, 0 replies; 45+ messages in thread
From: Li Xi @ 2015-09-23 13:58 UTC (permalink / raw)
  To: Dmitry Monakhov
  Cc: Jan Kara, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	Ext4 Developers List, linux-api-u79uwXL29TY76Z2rM5mHXA,
	Theodore Ts'o, Andreas Dilger,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ

Sorry, the linkage was missing.

https://github.com/ddn-lixi/project_quota_ext4_utils

On Wed, Sep 23, 2015 at 9:57 PM, Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi Dmitry,
>
> Please check following linkage. It includes all the patches I've made
> for ext4 project quota. Unfortunately, multiple tools need to be
> patched, including 1) patch e2fsprogs 2) patch quota-tools 3) patch
> linux kernel 4) compile project_manage.
>
> Please let me know if there is any problem.
>
> Thanks,
> Li Xi
>
> On Wed, Sep 23, 2015 at 9:32 PM, Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> wrote:
>> Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>> Hi Jan Kara,
>>>
>>> Sorry, I forgot to mention that we run the xfstests for both XFS and
>>> Ext4 with and without these patches. And still, some (but not too
>>> many) of the tests fails, but the failed tests are the same no matter
>>> the patches are applied or not. And we didn't see any project quota
>>> related tests fails.
>> BTW. Where I can find userspace tools to play with this feature?
>>>
>>> Regards,
>>> Li Xi
>>>
>>> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
>>>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>>>> The following patches propose an implementation of project quota
>>>>> support for ext4. A project is an aggregate of unrelated inodes
>>>>> which might scatter in different directories. Inodes that belong
>>>>> to the same project possess an identical identification i.e.
>>>>> 'project ID', just like every inode has its user/group
>>>>> identification. The following patches add project quota as
>>>>> supplement to the former uer/group quota types.
>>>>
>>>> With the last version of the patches, there was only one outstanding issue
>>>> and that was whether xfstests for XFS pass correctly (especially the
>>>> project quota related ones). Have you been able to verify this?
>>>>
>>>>                                                                 Honza
>>>>
>>>>>
>>>>> The semantics of ext4 project quota is consistent with XFS. Each
>>>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>>>> newly created inode under that directory will have a default project
>>>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>>>> When this flag is set on a directory, following rules will be kept:
>>>>>
>>>>> 1) The newly created inode under that directory will inherit both
>>>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>>>> directory.
>>>>>
>>>>> 2) Hard-linking a inode with different project ID into that directory
>>>>> will fail with errno EXDEV.
>>>>>
>>>>> 3) Renaming a inode with different project ID into that directory
>>>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>>>> failure and copy the renamed inode to a new inode in the directory.
>>>>> Thus, this new inode will inherit both the project ID and
>>>>> EXT4_INODE_PROJINHERIT flag.
>>>>>
>>>>> 4) If the project quota of that ID is being enforced, statfs() on
>>>>> that directory will take the quotas as another upper limits along
>>>>> with the capacity of the file system, i.e. the total block/inode
>>>>> number will be the minimum of the quota limits and file system
>>>>> capacity.
>>>>>
>>>>> Changelog:
>>>>> * v15 <- v14:
>>>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>>>> * v14 <- v13:
>>>>>  - Cleanup ioctl of setting project ID;
>>>>>  - Do not check project quota inode number specially;
>>>>>  - Check isize when extract project ID from disk;
>>>>>  - Rebase to latest kernel (4.0.0)
>>>>> * v13 <- v12:
>>>>>  - Update inode size check of project ID.
>>>>> * v12 <- v11:
>>>>>  - Relax the permission check when setting project ID.
>>>>> * v11 <- v10:
>>>>>  - Remove project quota mount option;
>>>>>  - Fix permission check when setting project ID.
>>>>> * v10 <- v9:
>>>>>  - Remove non-journaled project quota interface;
>>>>>  - Only allow admin to read project quota info;
>>>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>>>> * v9 <- v8:
>>>>>  - Remove non-journaled project quota;
>>>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>>>> * v8 <- v7:
>>>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>>>> * v7 <- v6:
>>>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>>>  - Add patch to cleanup ext4 inode flag definitions.
>>>>> * v6 <- v5:
>>>>>  - Add project ID check for cross rename;
>>>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>>>> * v5 <- v4:
>>>>>  - Check project feature when set/get project ID;
>>>>>  - Do not check project feature for project quota;
>>>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>>>> * v4 <- v3:
>>>>>  - Do not check project feature when set/get project ID;
>>>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>>>  - Remove CONFIG_QUOTA_PROJECT.
>>>>> * v3 <- v2:
>>>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>>>> * v2 <- v1:
>>>>>  - Add ioctl interface for setting/getting project;
>>>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>>>  - Add get_projid() method in struct dquot_operations;
>>>>>  - Add error check of ext4_inode_projid_set/get().
>>>>>
>>>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>>>> v4: http://lwn.net/Articles/612972/
>>>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>>>
>>>>> Any comments or feedbacks are appreciated.
>>>>>
>>>>> Regards,
>>>>>                                          - Li Xi
>>>>>
>>>>> Li Xi (4):
>>>>>   ext4: adds project ID support
>>>>>   ext4: adds project quota support
>>>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>>>   ext4: cleanup inode flag definitions
>>>>>
>>>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>>>  fs/ext4/ialloc.c        |    7 +
>>>>>  fs/ext4/inode.c         |   28 ++++
>>>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>>>  fs/ext4/namei.c         |   19 +++
>>>>>  fs/ext4/super.c         |   57 +++++++-
>>>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>>>  include/uapi/linux/fs.h |   33 +++++
>>>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>>>
>>>> --
>>>> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
>>>> SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found]             ` <CAPTn0cC=1xWCcUMVqhAx4pvqqX9rXC8p6B4Jt7cpm4HfuaFOMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-09-23 14:13                 ` Dmitry Monakhov
  2015-09-23 14:13                 ` Dmitry Monakhov
  1 sibling, 0 replies; 45+ messages in thread
From: Dmitry Monakhov @ 2015-09-23 14:13 UTC (permalink / raw)
  To: Li Xi
  Cc: Jan Kara, linux-fsdevel@vger.kernel.org, Ext4 Developers List,
	linux-api@vger.kernel.org, Theodore Ts'o, Andreas Dilger,
	viro@zeniv.linux.org.uk, hch@infradead.org

[-- Attachment #1: Type: text/plain, Size: 7662 bytes --]

Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi Dmitry,
>
> Please check following linkage. It includes all the patches I've made
Which link? According to annotation all links points to previous
versions of kernel part. Am I missing something?
> for ext4 project quota. Unfortunately, multiple tools need to be
> patched, including 1) patch e2fsprogs 2) patch quota-tools 3) patch
> linux kernel 4) compile project_manage.
I do believe that.
> Please let me know if there is any problem.
It would be very useful for whole community if you just add git-links
to modified tools. tools for example like follows:
kernel-pc: http://github.com/blabla/linus.git/prjquota/
e2fsprogs: http://github.com/blabla/e2fsprogs/prjquota/
quota-tools: http://github.com/blabla/quota-tools/prjquota/

This allow others to test whole bundle. For example xfstests-bld
users can simply change git-sources to yours and run full xfstests
>
> Thanks,
> Li Xi
>
> On Wed, Sep 23, 2015 at 9:32 PM, Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> wrote:
>> Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>> Hi Jan Kara,
>>>
>>> Sorry, I forgot to mention that we run the xfstests for both XFS and
>>> Ext4 with and without these patches. And still, some (but not too
>>> many) of the tests fails, but the failed tests are the same no matter
>>> the patches are applied or not. And we didn't see any project quota
>>> related tests fails.
>> BTW. Where I can find userspace tools to play with this feature?
>>>
>>> Regards,
>>> Li Xi
>>>
>>> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
>>>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>>>> The following patches propose an implementation of project quota
>>>>> support for ext4. A project is an aggregate of unrelated inodes
>>>>> which might scatter in different directories. Inodes that belong
>>>>> to the same project possess an identical identification i.e.
>>>>> 'project ID', just like every inode has its user/group
>>>>> identification. The following patches add project quota as
>>>>> supplement to the former uer/group quota types.
>>>>
>>>> With the last version of the patches, there was only one outstanding issue
>>>> and that was whether xfstests for XFS pass correctly (especially the
>>>> project quota related ones). Have you been able to verify this?
>>>>
>>>>                                                                 Honza
>>>>
>>>>>
>>>>> The semantics of ext4 project quota is consistent with XFS. Each
>>>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>>>> newly created inode under that directory will have a default project
>>>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>>>> When this flag is set on a directory, following rules will be kept:
>>>>>
>>>>> 1) The newly created inode under that directory will inherit both
>>>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>>>> directory.
>>>>>
>>>>> 2) Hard-linking a inode with different project ID into that directory
>>>>> will fail with errno EXDEV.
>>>>>
>>>>> 3) Renaming a inode with different project ID into that directory
>>>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>>>> failure and copy the renamed inode to a new inode in the directory.
>>>>> Thus, this new inode will inherit both the project ID and
>>>>> EXT4_INODE_PROJINHERIT flag.
>>>>>
>>>>> 4) If the project quota of that ID is being enforced, statfs() on
>>>>> that directory will take the quotas as another upper limits along
>>>>> with the capacity of the file system, i.e. the total block/inode
>>>>> number will be the minimum of the quota limits and file system
>>>>> capacity.
>>>>>
>>>>> Changelog:
>>>>> * v15 <- v14:
>>>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>>>> * v14 <- v13:
>>>>>  - Cleanup ioctl of setting project ID;
>>>>>  - Do not check project quota inode number specially;
>>>>>  - Check isize when extract project ID from disk;
>>>>>  - Rebase to latest kernel (4.0.0)
>>>>> * v13 <- v12:
>>>>>  - Update inode size check of project ID.
>>>>> * v12 <- v11:
>>>>>  - Relax the permission check when setting project ID.
>>>>> * v11 <- v10:
>>>>>  - Remove project quota mount option;
>>>>>  - Fix permission check when setting project ID.
>>>>> * v10 <- v9:
>>>>>  - Remove non-journaled project quota interface;
>>>>>  - Only allow admin to read project quota info;
>>>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>>>> * v9 <- v8:
>>>>>  - Remove non-journaled project quota;
>>>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>>>> * v8 <- v7:
>>>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>>>> * v7 <- v6:
>>>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>>>  - Add patch to cleanup ext4 inode flag definitions.
>>>>> * v6 <- v5:
>>>>>  - Add project ID check for cross rename;
>>>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>>>> * v5 <- v4:
>>>>>  - Check project feature when set/get project ID;
>>>>>  - Do not check project feature for project quota;
>>>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>>>> * v4 <- v3:
>>>>>  - Do not check project feature when set/get project ID;
>>>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>>>  - Remove CONFIG_QUOTA_PROJECT.
>>>>> * v3 <- v2:
>>>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>>>> * v2 <- v1:
>>>>>  - Add ioctl interface for setting/getting project;
>>>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>>>  - Add get_projid() method in struct dquot_operations;
>>>>>  - Add error check of ext4_inode_projid_set/get().
>>>>>
>>>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>>>> v4: http://lwn.net/Articles/612972/
>>>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>>>
>>>>> Any comments or feedbacks are appreciated.
>>>>>
>>>>> Regards,
>>>>>                                          - Li Xi
>>>>>
>>>>> Li Xi (4):
>>>>>   ext4: adds project ID support
>>>>>   ext4: adds project quota support
>>>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>>>   ext4: cleanup inode flag definitions
>>>>>
>>>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>>>  fs/ext4/ialloc.c        |    7 +
>>>>>  fs/ext4/inode.c         |   28 ++++
>>>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>>>  fs/ext4/namei.c         |   19 +++
>>>>>  fs/ext4/super.c         |   57 +++++++-
>>>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>>>  include/uapi/linux/fs.h |   33 +++++
>>>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>>>
>>>> --
>>>> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
>>>> SUSE Labs, CR

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-09-23 14:13                 ` Dmitry Monakhov
  0 siblings, 0 replies; 45+ messages in thread
From: Dmitry Monakhov @ 2015-09-23 14:13 UTC (permalink / raw)
  To: Li Xi
  Cc: Jan Kara, linux-fsdevel@vger.kernel.org, Ext4 Developers List,
	linux-api@vger.kernel.org, Theodore Ts'o, Andreas Dilger,
	viro@zeniv.linux.org.uk, hch@infradead.org

[-- Attachment #1: Type: text/plain, Size: 7662 bytes --]

Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi Dmitry,
>
> Please check following linkage. It includes all the patches I've made
Which link? According to annotation all links points to previous
versions of kernel part. Am I missing something?
> for ext4 project quota. Unfortunately, multiple tools need to be
> patched, including 1) patch e2fsprogs 2) patch quota-tools 3) patch
> linux kernel 4) compile project_manage.
I do believe that.
> Please let me know if there is any problem.
It would be very useful for whole community if you just add git-links
to modified tools. tools for example like follows:
kernel-pc: http://github.com/blabla/linus.git/prjquota/
e2fsprogs: http://github.com/blabla/e2fsprogs/prjquota/
quota-tools: http://github.com/blabla/quota-tools/prjquota/

This allow others to test whole bundle. For example xfstests-bld
users can simply change git-sources to yours and run full xfstests
>
> Thanks,
> Li Xi
>
> On Wed, Sep 23, 2015 at 9:32 PM, Dmitry Monakhov <dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> wrote:
>> Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>> Hi Jan Kara,
>>>
>>> Sorry, I forgot to mention that we run the xfstests for both XFS and
>>> Ext4 with and without these patches. And still, some (but not too
>>> many) of the tests fails, but the failed tests are the same no matter
>>> the patches are applied or not. And we didn't see any project quota
>>> related tests fails.
>> BTW. Where I can find userspace tools to play with this feature?
>>>
>>> Regards,
>>> Li Xi
>>>
>>> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
>>>> On Sun 13-09-15 21:20:29, Li Xi wrote:
>>>>> The following patches propose an implementation of project quota
>>>>> support for ext4. A project is an aggregate of unrelated inodes
>>>>> which might scatter in different directories. Inodes that belong
>>>>> to the same project possess an identical identification i.e.
>>>>> 'project ID', just like every inode has its user/group
>>>>> identification. The following patches add project quota as
>>>>> supplement to the former uer/group quota types.
>>>>
>>>> With the last version of the patches, there was only one outstanding issue
>>>> and that was whether xfstests for XFS pass correctly (especially the
>>>> project quota related ones). Have you been able to verify this?
>>>>
>>>>                                                                 Honza
>>>>
>>>>>
>>>>> The semantics of ext4 project quota is consistent with XFS. Each
>>>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
>>>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
>>>>> newly created inode under that directory will have a default project
>>>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
>>>>> When this flag is set on a directory, following rules will be kept:
>>>>>
>>>>> 1) The newly created inode under that directory will inherit both
>>>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
>>>>> directory.
>>>>>
>>>>> 2) Hard-linking a inode with different project ID into that directory
>>>>> will fail with errno EXDEV.
>>>>>
>>>>> 3) Renaming a inode with different project ID into that directory
>>>>> will fail with errno EXDEV. However, 'mv' command will detect this
>>>>> failure and copy the renamed inode to a new inode in the directory.
>>>>> Thus, this new inode will inherit both the project ID and
>>>>> EXT4_INODE_PROJINHERIT flag.
>>>>>
>>>>> 4) If the project quota of that ID is being enforced, statfs() on
>>>>> that directory will take the quotas as another upper limits along
>>>>> with the capacity of the file system, i.e. the total block/inode
>>>>> number will be the minimum of the quota limits and file system
>>>>> capacity.
>>>>>
>>>>> Changelog:
>>>>> * v15 <- v14:
>>>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
>>>>> * v14 <- v13:
>>>>>  - Cleanup ioctl of setting project ID;
>>>>>  - Do not check project quota inode number specially;
>>>>>  - Check isize when extract project ID from disk;
>>>>>  - Rebase to latest kernel (4.0.0)
>>>>> * v13 <- v12:
>>>>>  - Update inode size check of project ID.
>>>>> * v12 <- v11:
>>>>>  - Relax the permission check when setting project ID.
>>>>> * v11 <- v10:
>>>>>  - Remove project quota mount option;
>>>>>  - Fix permission check when setting project ID.
>>>>> * v10 <- v9:
>>>>>  - Remove non-journaled project quota interface;
>>>>>  - Only allow admin to read project quota info;
>>>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
>>>>> * v9 <- v8:
>>>>>  - Remove non-journaled project quota;
>>>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
>>>>> * v8 <- v7:
>>>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
>>>>> * v7 <- v6:
>>>>>  - Map ext4 inode flags to xflags of struct fsxattr;
>>>>>  - Add patch to cleanup ext4 inode flag definitions.
>>>>> * v6 <- v5:
>>>>>  - Add project ID check for cross rename;
>>>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
>>>>> * v5 <- v4:
>>>>>  - Check project feature when set/get project ID;
>>>>>  - Do not check project feature for project quota;
>>>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
>>>>> * v4 <- v3:
>>>>>  - Do not check project feature when set/get project ID;
>>>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
>>>>>  - Remove unnecessary change of fs/quota/dquot.c;
>>>>>  - Remove CONFIG_QUOTA_PROJECT.
>>>>> * v3 <- v2:
>>>>>  - Add EXT4_INODE_PROJINHERIT semantics.
>>>>> * v2 <- v1:
>>>>>  - Add ioctl interface for setting/getting project;
>>>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
>>>>>  - Add get_projid() method in struct dquot_operations;
>>>>>  - Add error check of ext4_inode_projid_set/get().
>>>>>
>>>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
>>>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
>>>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
>>>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
>>>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
>>>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
>>>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
>>>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
>>>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
>>>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
>>>>> v4: http://lwn.net/Articles/612972/
>>>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
>>>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
>>>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
>>>>>
>>>>> Any comments or feedbacks are appreciated.
>>>>>
>>>>> Regards,
>>>>>                                          - Li Xi
>>>>>
>>>>> Li Xi (4):
>>>>>   ext4: adds project ID support
>>>>>   ext4: adds project quota support
>>>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>>>>>   ext4: cleanup inode flag definitions
>>>>>
>>>>>  fs/ext4/ext4.h          |   85 +++++++----
>>>>>  fs/ext4/ialloc.c        |    7 +
>>>>>  fs/ext4/inode.c         |   28 ++++
>>>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
>>>>>  fs/ext4/namei.c         |   19 +++
>>>>>  fs/ext4/super.c         |   57 +++++++-
>>>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
>>>>>  include/uapi/linux/fs.h |   33 +++++
>>>>>  8 files changed, 490 insertions(+), 153 deletions(-)
>>>>>
>>>> --
>>>> Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
>>>> SUSE Labs, CR

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 1/4] ext4: adds project ID support
  2015-09-23 12:34       ` Dmitry Monakhov
@ 2015-09-23 18:17         ` Jan Kara
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-09-23 18:17 UTC (permalink / raw)
  To: Dmitry Monakhov
  Cc: Li Xi, linux-fsdevel, linux-ext4, linux-api, tytso, adilger,
	jack, viro, hch

On Wed 23-09-15 15:34:54, Dmitry Monakhov wrote:
> > @@ -692,6 +695,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 */
> So you are about to extend dist_inode structure(not xattr). I do understand that
> his is ridiculous question for 15'th version of the patch, but still.
> Personally I think that his is good idea, but can not find a
> confirmation from Theodore and Jan that they are agree with that.
> Guys please ACK that statement explicitly,so later we can  refer on this mail as decision made.

Yes, I agree with this.

								Honza

> >  };
> >  
> >  struct move_extent {
> > @@ -952,6 +956,7 @@ struct ext4_inode_info {
> >  	/* Encryption params */
> >  	struct ext4_crypt_info *i_crypt_info;
> >  #endif
> > +	kprojid_t i_projid;
> >  };
> >  
> >  /*
> > @@ -1566,6 +1571,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
> >   */
> >  #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
> >  #define EXT4_FEATURE_RO_COMPAT_READONLY		0x1000
> > +#define EXT4_FEATURE_RO_COMPAT_PROJECT		0x2000
> >  
> >  #define EXT4_FEATURE_INCOMPAT_COMPRESSION	0x0001
> >  #define EXT4_FEATURE_INCOMPAT_FILETYPE		0x0002
> > @@ -1617,7 +1623,8 @@ static inline int ext4_encrypted_inode(struct inode *inode)
> >  					 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
> > @@ -1625,6 +1632,11 @@ static inline int ext4_encrypted_inode(struct inode *inode)
> >  #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
> >  
> >  /*
> > @@ -2317,6 +2329,7 @@ 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 void ext4_da_update_reserve_space(struct inode *inode,
> >  					int used, int quota_claim);
> >  
> > diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> > index 619bfc1..692b50f 100644
> > --- a/fs/ext4/ialloc.c
> > +++ b/fs/ext4/ialloc.c
> > @@ -769,6 +769,13 @@ 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) &&
> > +	    ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT))
> > +		ei->i_projid = EXT4_I(dir)->i_projid;
> > +	else
> > +		ei->i_projid = make_kprojid(&init_user_ns, EXT4_DEF_PROJID);
> > +
> >  	err = dquot_initialize(inode);
> >  	if (err)
> >  		goto out;
> > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> > index 612fbcf..5836a3d 100644
> > --- a/fs/ext4/inode.c
> > +++ b/fs/ext4/inode.c
> > @@ -4035,6 +4035,14 @@ static inline void ext4_iget_extra_inode(struct inode *inode,
> >  		EXT4_I(inode)->i_inline_off = 0;
> >  }
> >  
> > +int ext4_get_projid(struct inode *inode, kprojid_t *projid)
> > +{
> > +	if (!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_RO_COMPAT_PROJECT))
> > +		return -EOPNOTSUPP;
> > +	*projid = EXT4_I(inode)->i_projid;
> > +	return 0;
> > +}
> > +
> >  struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
> >  {
> >  	struct ext4_iloc iloc;
> > @@ -4046,6 +4054,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
> >  	int block;
> >  	uid_t i_uid;
> >  	gid_t i_gid;
> > +	projid_t i_projid;
> >  
> >  	inode = iget_locked(sb, ino);
> >  	if (!inode)
> > @@ -4095,12 +4104,20 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
> >  	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
> >  	i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
> >  	i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
> > +	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_PROJECT) &&
> > +	    EXT4_INODE_SIZE(sb) > EXT4_GOOD_OLD_INODE_SIZE &&
> > +	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
> > +		i_projid = (projid_t)le32_to_cpu(raw_inode->i_projid);
> > +	else
> > +		i_projid = EXT4_DEF_PROJID;
> > +
> >  	if (!(test_opt(inode->i_sb, NO_UID32))) {
> >  		i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
> >  		i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
> >  	}
> >  	i_uid_write(inode, i_uid);
> >  	i_gid_write(inode, i_gid);
> > +	ei->i_projid = make_kprojid(&init_user_ns, i_projid);
> >  	set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
> >  
> >  	ext4_clear_state_flags(ei);	/* Only relevant on 32-bit archs */
> > @@ -4398,6 +4415,7 @@ static int ext4_do_update_inode(handle_t *handle,
> >  	int need_datasync = 0, set_large_file = 0;
> >  	uid_t i_uid;
> >  	gid_t i_gid;
> > +	projid_t i_projid;
> >  
> >  	spin_lock(&ei->i_raw_lock);
> >  
> > @@ -4410,6 +4428,7 @@ static int ext4_do_update_inode(handle_t *handle,
> >  	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
> >  	i_uid = i_uid_read(inode);
> >  	i_gid = i_gid_read(inode);
> > +	i_projid = from_kprojid(&init_user_ns, ei->i_projid);
> >  	if (!(test_opt(inode->i_sb, NO_UID32))) {
> >  		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
> >  		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
> > @@ -4488,6 +4507,15 @@ static int ext4_do_update_inode(handle_t *handle,
> >  				cpu_to_le16(ei->i_extra_isize);
> >  		}
> >  	}
> > +
> > +	BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
> > +			EXT4_FEATURE_RO_COMPAT_PROJECT) &&
> > +	       i_projid != EXT4_DEF_PROJID);
> > +
> > +	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
> > +	    EXT4_FITS_IN_INODE(raw_inode, ei, i_projid))
> > +		raw_inode->i_projid = cpu_to_le32(i_projid);
> > +
> >  	ext4_inode_csum_set(inode, raw_inode, ei);
> >  	spin_unlock(&ei->i_raw_lock);
> >  	if (inode->i_sb->s_flags & MS_LAZYTIME)
> > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> > index 9f61e76..61694ad 100644
> > --- a/fs/ext4/namei.c
> > +++ b/fs/ext4/namei.c
> > @@ -3215,6 +3215,12 @@ static int ext4_link(struct dentry *old_dentry,
> >  	if (ext4_encrypted_inode(dir) &&
> >  	    !ext4_is_child_context_consistent_with_parent(dir, inode))
> >  		return -EPERM;
> > +
> > +       if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) &&
> > +	   (!projid_eq(EXT4_I(dir)->i_projid,
> > +		       EXT4_I(old_dentry->d_inode)->i_projid)))
> > +		return -EXDEV;
> > +
> >  	err = dquot_initialize(dir);
> >  	if (err)
> >  		return err;
> > @@ -3496,6 +3502,11 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
> >  	int credits;
> >  	u8 old_file_type;
> >  
> > +	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT)) &&
> > +	    (!projid_eq(EXT4_I(new_dir)->i_projid,
> > +			EXT4_I(old_dentry->d_inode)->i_projid)))
> > +		return -EXDEV;
> > +
> >  	retval = dquot_initialize(old.dir);
> >  	if (retval)
> >  		return retval;
> > @@ -3705,6 +3716,14 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
> >  							   new.inode)))
> >  		return -EPERM;
> >  
> > +	if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
> > +	     !projid_eq(EXT4_I(new_dir)->i_projid,
> > +			EXT4_I(old_dentry->d_inode)->i_projid)) ||
> > +	    (ext4_test_inode_flag(old_dir, EXT4_INODE_PROJINHERIT) &&
> > +	     !projid_eq(EXT4_I(old_dir)->i_projid,
> > +			EXT4_I(new_dentry->d_inode)->i_projid)))
> > +		return -EXDEV;
> > +
> >  	retval = dquot_initialize(old.dir);
> >  	if (retval)
> >  		return retval;
> > diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> > index a63c7b0..d07445e 100644
> > --- a/fs/ext4/super.c
> > +++ b/fs/ext4/super.c
> > @@ -1097,6 +1097,7 @@ static const struct dquot_operations ext4_quota_operations = {
> >  	.write_info	= ext4_write_info,
> >  	.alloc_dquot	= dquot_alloc,
> >  	.destroy_dquot	= dquot_destroy,
> > +	.get_projid	= ext4_get_projid,
> >  };
> >  
> >  static const struct quotactl_ops ext4_qctl_operations = {
> > diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> > index 9b964a5..f15d980 100644
> > --- a/include/uapi/linux/fs.h
> > +++ b/include/uapi/linux/fs.h
> > @@ -197,6 +197,7 @@ struct inodes_stat_t {
> >  #define FS_EXTENT_FL			0x00080000 /* Extents */
> >  #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
> >  #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
> > +#define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
> >  #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
> >  
> >  #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
> > -- 
> > 1.7.1


-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-09-23 13:57           ` Li Xi
       [not found]             ` <CAPTn0cC=1xWCcUMVqhAx4pvqqX9rXC8p6B4Jt7cpm4HfuaFOMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-09-24 12:09             ` Jan Kara
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-09-24 12:09 UTC (permalink / raw)
  To: Li Xi
  Cc: Dmitry Monakhov, Jan Kara, linux-fsdevel, Ext4 Developers List,
	linux-api, Theodore Ts'o, Andreas Dilger, viro, hch

  Hi,

On Wed 23-09-15 21:57:06, Li Xi wrote:
> Please check following linkage. It includes all the patches I've made
> for ext4 project quota. Unfortunately, multiple tools need to be
> patched, including 1) patch e2fsprogs 2) patch quota-tools 3) patch
> linux kernel 4) compile project_manage.
> 
> Please let me know if there is any problem.

BTW, do you plan to submit e.g. quota-tools related changes? I've glanced
over what you have in your github repo and it looks sensible. Only you can
rip out prjjquota mount option and quotacheck support for project quota
since that will be all handled in kernel / e2fsprogs...

								Honza

> On Wed, Sep 23, 2015 at 9:32 PM, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> > Li Xi <pkuelelixi@gmail.com> writes:
> >
> >> Hi Jan Kara,
> >>
> >> Sorry, I forgot to mention that we run the xfstests for both XFS and
> >> Ext4 with and without these patches. And still, some (but not too
> >> many) of the tests fails, but the failed tests are the same no matter
> >> the patches are applied or not. And we didn't see any project quota
> >> related tests fails.
> > BTW. Where I can find userspace tools to play with this feature?
> >>
> >> Regards,
> >> Li Xi
> >>
> >> On Wed, Sep 23, 2015 at 8:31 PM, Jan Kara <jack@suse.cz> wrote:
> >>> On Sun 13-09-15 21:20:29, Li Xi wrote:
> >>>> The following patches propose an implementation of project quota
> >>>> support for ext4. A project is an aggregate of unrelated inodes
> >>>> which might scatter in different directories. Inodes that belong
> >>>> to the same project possess an identical identification i.e.
> >>>> 'project ID', just like every inode has its user/group
> >>>> identification. The following patches add project quota as
> >>>> supplement to the former uer/group quota types.
> >>>
> >>> With the last version of the patches, there was only one outstanding issue
> >>> and that was whether xfstests for XFS pass correctly (especially the
> >>> project quota related ones). Have you been able to verify this?
> >>>
> >>>                                                                 Honza
> >>>
> >>>>
> >>>> The semantics of ext4 project quota is consistent with XFS. Each
> >>>> directory can have EXT4_INODE_PROJINHERIT flag set. When the
> >>>> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
> >>>> newly created inode under that directory will have a default project
> >>>> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
> >>>> When this flag is set on a directory, following rules will be kept:
> >>>>
> >>>> 1) The newly created inode under that directory will inherit both
> >>>> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
> >>>> directory.
> >>>>
> >>>> 2) Hard-linking a inode with different project ID into that directory
> >>>> will fail with errno EXDEV.
> >>>>
> >>>> 3) Renaming a inode with different project ID into that directory
> >>>> will fail with errno EXDEV. However, 'mv' command will detect this
> >>>> failure and copy the renamed inode to a new inode in the directory.
> >>>> Thus, this new inode will inherit both the project ID and
> >>>> EXT4_INODE_PROJINHERIT flag.
> >>>>
> >>>> 4) If the project quota of that ID is being enforced, statfs() on
> >>>> that directory will take the quotas as another upper limits along
> >>>> with the capacity of the file system, i.e. the total block/inode
> >>>> number will be the minimum of the quota limits and file system
> >>>> capacity.
> >>>>
> >>>> Changelog:
> >>>> * v15 <- v14:
> >>>>  - Rebase to newest master branch of git repository (b0a1ea51b).
> >>>> * v14 <- v13:
> >>>>  - Cleanup ioctl of setting project ID;
> >>>>  - Do not check project quota inode number specially;
> >>>>  - Check isize when extract project ID from disk;
> >>>>  - Rebase to latest kernel (4.0.0)
> >>>> * v13 <- v12:
> >>>>  - Update inode size check of project ID.
> >>>> * v12 <- v11:
> >>>>  - Relax the permission check when setting project ID.
> >>>> * v11 <- v10:
> >>>>  - Remove project quota mount option;
> >>>>  - Fix permission check when setting project ID.
> >>>> * v10 <- v9:
> >>>>  - Remove non-journaled project quota interface;
> >>>>  - Only allow admin to read project quota info;
> >>>>  - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
> >>>> * v9 <- v8:
> >>>>  - Remove non-journaled project quota;
> >>>>  - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
> >>>> * v8 <- v7:
> >>>>  - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
> >>>> * v7 <- v6:
> >>>>  - Map ext4 inode flags to xflags of struct fsxattr;
> >>>>  - Add patch to cleanup ext4 inode flag definitions.
> >>>> * v6 <- v5:
> >>>>  - Add project ID check for cross rename;
> >>>>  - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
> >>>> * v5 <- v4:
> >>>>  - Check project feature when set/get project ID;
> >>>>  - Do not check project feature for project quota;
> >>>>  - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
> >>>> * v4 <- v3:
> >>>>  - Do not check project feature when set/get project ID;
> >>>>  - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
> >>>>  - Remove unnecessary change of fs/quota/dquot.c;
> >>>>  - Remove CONFIG_QUOTA_PROJECT.
> >>>> * v3 <- v2:
> >>>>  - Add EXT4_INODE_PROJINHERIT semantics.
> >>>> * v2 <- v1:
> >>>>  - Add ioctl interface for setting/getting project;
> >>>>  - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
> >>>>  - Add get_projid() method in struct dquot_operations;
> >>>>  - Add error check of ext4_inode_projid_set/get().
> >>>>
> >>>> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
> >>>> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
> >>>> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
> >>>> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
> >>>> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
> >>>> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
> >>>> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
> >>>> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
> >>>> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
> >>>> v5: http://www.spinics.net/lists/linux-api/msg04840.html
> >>>> v4: http://lwn.net/Articles/612972/
> >>>> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
> >>>> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
> >>>> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
> >>>>
> >>>> Any comments or feedbacks are appreciated.
> >>>>
> >>>> Regards,
> >>>>                                          - Li Xi
> >>>>
> >>>> Li Xi (4):
> >>>>   ext4: adds project ID support
> >>>>   ext4: adds project quota support
> >>>>   ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
> >>>>   ext4: cleanup inode flag definitions
> >>>>
> >>>>  fs/ext4/ext4.h          |   85 +++++++----
> >>>>  fs/ext4/ialloc.c        |    7 +
> >>>>  fs/ext4/inode.c         |   28 ++++
> >>>>  fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
> >>>>  fs/ext4/namei.c         |   19 +++
> >>>>  fs/ext4/super.c         |   57 +++++++-
> >>>>  fs/xfs/libxfs/xfs_fs.h  |   47 +++----
> >>>>  include/uapi/linux/fs.h |   33 +++++
> >>>>  8 files changed, 490 insertions(+), 153 deletions(-)
> >>>>
> >>> --
> >>> Jan Kara <jack@suse.com>
> >>> SUSE Labs, CR
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
  2015-09-13 12:20   ` [v15 1/4] ext4: adds project ID support Li Xi
  2015-09-13 12:20   ` [v15 2/4] ext4: adds project quota support Li Xi
@ 2015-09-24 17:12   ` Andreas Dilger
  2015-11-05 14:45     ` Li Xi
  2 siblings, 1 reply; 45+ messages in thread
From: Andreas Dilger @ 2015-09-24 17:12 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel, linux-ext4, Linux API, Theodore Ts'o,
	Jan Kara, Al Viro, Christoph Hellwig, Dave Chinner,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Sep 13, 2015, at 2:20 PM, Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 
> The following patches propose an implementation of project quota
> support for ext4. A project is an aggregate of unrelated inodes
> which might scatter in different directories. Inodes that belong
> to the same project possess an identical identification i.e.
> 'project ID', just like every inode has its user/group
> identification. The following patches add project quota as
> supplement to the former uer/group quota types.

We discussed this on the ext4 developer concall today and tried to
move the landing of these patches forward.  Some notes below:

- Ted: agreed to reserve EXT4_FEATURE_RO_COMPAT_PROJECT, s_prj_quota_inum,
  EXT4_PROJINHERIT_FL, and i_projid fields for use by project quota to
  avoid compatibility issues if patches are not landed immediately.
   - Ted: to do final check of inode flag value
   - ext4 project quota inode does not need to use a reserved inode, but
     could after Jan's patch to increase reserved inodes lands
- Li Xi: identify xfstests subtests that are exercising project quota
   - submit patches to xfstests that will activate them for ext4
   - keep in ext4 xfstests for testing until patches land upstream
   - this needs to be done before landing to ensure ext4 code works
- Li Xi: document the behaviour of project quota (if no existing
  document exists for XFS already), some of this is already below
   - update man pages for df(1) and statfs(2) for subdir with project ID
     (i.e. that it returns only quota usage and limit for project ID)
   - Ted: where should document go? linux/Documentation/fs? ext4 wiki?
   - not a requirement for testing, can be done after landing

- All: decide on a common tool for setting project ID on file/directory
   - don't want to require xfsutils in order to use project quota
   - start with chattr (using FS_IOC_FS{GET,SET}XATTR) in e2fsprogs
     - allows testing project quota with e2fsprogs/ext4
   - chproj (like chown/chgrp) would also be an option
     - needs more discussion/development effort, goes into fileutils
   - this doesn't need to be decided immediately, and both could be done

Ted, please add in anything that I forgot.

Cheers, Andreas

> The semantics of ext4 project quota is consistent with XFS. Each
> directory can have EXT4_INODE_PROJINHERIT flag set. When the
> EXT4_INODE_PROJINHERIT flag of a parent directory is not set, a
> newly created inode under that directory will have a default project
> ID (i.e. 0). And its EXT4_INODE_PROJINHERIT flag is not set either.
> When this flag is set on a directory, following rules will be kept:
> 
> 1) The newly created inode under that directory will inherit both
> the EXT4_INODE_PROJINHERIT flag and the project ID from its parent
> directory.
> 
> 2) Hard-linking a inode with different project ID into that directory
> will fail with errno EXDEV.
> 
> 3) Renaming a inode with different project ID into that directory
> will fail with errno EXDEV. However, 'mv' command will detect this
> failure and copy the renamed inode to a new inode in the directory.
> Thus, this new inode will inherit both the project ID and
> EXT4_INODE_PROJINHERIT flag.
> 
> 4) If the project quota of that ID is being enforced, statfs() on
> that directory will take the quotas as another upper limits along
> with the capacity of the file system, i.e. the total block/inode
> number will be the minimum of the quota limits and file system
> capacity.
> 
> Changelog:
> * v15 <- v14:
> - Rebase to newest master branch of git repository (b0a1ea51b).
> * v14 <- v13:
> - Cleanup ioctl of setting project ID;
> - Do not check project quota inode number specially;
> - Check isize when extract project ID from disk;
> - Rebase to latest kernel (4.0.0)
> * v13 <- v12:
> - Update inode size check of project ID.
> * v12 <- v11:
> - Relax the permission check when setting project ID.
> * v11 <- v10:
> - Remove project quota mount option;
> - Fix permission check when setting project ID.
> * v10 <- v9:
> - Remove non-journaled project quota interface;
> - Only allow admin to read project quota info;
> - Cleanup FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface.
> * v9 <- v8:
> - Remove non-journaled project quota;
> - Rebase to newest dev branch of ext4 repository (3.19.0-rc3).
> * v8 <- v7:
> - Rebase to newest dev branch of ext4 repository (3.18.0_rc3).
> * v7 <- v6:
> - Map ext4 inode flags to xflags of struct fsxattr;
> - Add patch to cleanup ext4 inode flag definitions.
> * v6 <- v5:
> - Add project ID check for cross rename;
> - Remove patch of EXT4_IOC_GETPROJECT/EXT4_IOC_SETPROJECT ioctl
> * v5 <- v4:
> - Check project feature when set/get project ID;
> - Do not check project feature for project quota;
> - Add support of FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR.
> * v4 <- v3:
> - Do not check project feature when set/get project ID;
> - Use EXT4_MAXQUOTAS instead of MAXQUOTAS in ext4 patches;
> - Remove unnecessary change of fs/quota/dquot.c;
> - Remove CONFIG_QUOTA_PROJECT.
> * v3 <- v2:
> - Add EXT4_INODE_PROJINHERIT semantics.
> * v2 <- v1:
> - Add ioctl interface for setting/getting project;
> - Add EXT4_FEATURE_RO_COMPAT_PROJECT;
> - Add get_projid() method in struct dquot_operations;
> - Add error check of ext4_inode_projid_set/get().
> 
> v14: http://article.gmane.org/gmane.linux.kernel.api/10345
> v13: http://www.spinics.net/lists/linux-fsdevel/msg85205.html
> v12: http://www.spinics.net/lists/linux-fsdevel/msg84905.html
> v11: http://www.spinics.net/lists/linux-ext4/msg47450.html
> v10: http://www.spinics.net/lists/linux-ext4/msg47413.html
> v9: http://www.spinics.net/lists/linux-ext4/msg47326.html
> v8: http://www.spinics.net/lists/linux-ext4/msg46545.html
> v7: http://www.spinics.net/lists/linux-fsdevel/msg80404.html
> v6: http://www.spinics.net/lists/linux-fsdevel/msg80022.html
> v5: http://www.spinics.net/lists/linux-api/msg04840.html
> v4: http://lwn.net/Articles/612972/
> v3: http://www.spinics.net/lists/linux-ext4/msg45184.html
> v2: http://www.spinics.net/lists/linux-ext4/msg44695.html
> v1: http://article.gmane.org/gmane.comp.file-systems.ext4/45153
> 
> Any comments or feedbacks are appreciated.
> 
> Regards,
>                                         - Li Xi
> 
> Li Xi (4):
>  ext4: adds project ID support
>  ext4: adds project quota support
>  ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support
>  ext4: cleanup inode flag definitions
> 
> fs/ext4/ext4.h          |   85 +++++++----
> fs/ext4/ialloc.c        |    7 +
> fs/ext4/inode.c         |   28 ++++
> fs/ext4/ioctl.c         |  367 ++++++++++++++++++++++++++++++++++++-----------
> fs/ext4/namei.c         |   19 +++
> fs/ext4/super.c         |   57 +++++++-
> fs/xfs/libxfs/xfs_fs.h  |   47 +++----
> include/uapi/linux/fs.h |   33 +++++
> 8 files changed, 490 insertions(+), 153 deletions(-)
> 


Cheers, Andreas

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-09-13 12:20 [v15 0/4] ext4: add project quota support Li Xi
                   ` (3 preceding siblings ...)
  2015-09-23 12:31 ` [v15 0/4] ext4: add project quota support Jan Kara
@ 2015-10-18  1:01 ` Theodore Ts'o
  2015-10-18  2:25   ` Li Xi
  4 siblings, 1 reply; 45+ messages in thread
From: Theodore Ts'o @ 2015-10-18  1:01 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel, linux-ext4, linux-api, adilger, jack, viro, hch,
	dmonakhov

This is a patch to reserve the code points used by the project quota
feature.  It should be the no different from the ones used by the
project quota patches; please let me know ASAP if you spot any
discrepancies, or anything else that I might have missed.

Cheers,

					- Ted


commit 8b4953e13f4c5d9a3c869f5fca7d51e1700e7db0
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Sat Oct 17 16:15:18 2015 -0400

    ext4: reserve code points for the project quota feature
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3f248c9..320f10e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -374,6 +374,7 @@ struct flex_groups {
 #define EXT4_EA_INODE_FL	        0x00200000 /* Inode used for large EA */
 #define EXT4_EOFBLOCKS_FL		0x00400000 /* Blocks allocated beyond EOF */
 #define EXT4_INLINE_DATA_FL		0x10000000 /* Inode has inline data. */
+#define EXT4_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define EXT4_RESERVED_FL		0x80000000 /* reserved for ext4 lib */
 
 #define EXT4_FL_USER_VISIBLE		0x004BDFFF /* User visible flags */
@@ -431,6 +432,7 @@ enum {
 	EXT4_INODE_EA_INODE	= 21,	/* Inode used for large EA */
 	EXT4_INODE_EOFBLOCKS	= 22,	/* Blocks allocated beyond EOF */
 	EXT4_INODE_INLINE_DATA	= 28,	/* Data in inode. */
+	EXT4_INODE_PROJINHERIT	= 29,	/* Create with parents projid */
 	EXT4_INODE_RESERVED	= 31,	/* reserved for ext4 lib */
 };
 
@@ -475,6 +477,7 @@ static inline void ext4_check_flag_values(void)
 	CHECK_FLAG_VALUE(EA_INODE);
 	CHECK_FLAG_VALUE(EOFBLOCKS);
 	CHECK_FLAG_VALUE(INLINE_DATA);
+	CHECK_FLAG_VALUE(PROJINHERIT);
 	CHECK_FLAG_VALUE(RESERVED);
 }
 
@@ -692,6 +695,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 {
@@ -1179,7 +1183,8 @@ struct ext4_super_block {
 	__u8	s_encrypt_algos[4];	/* Encryption algorithms in use  */
 	__u8	s_encrypt_pw_salt[16];	/* Salt used for string2key algorithm */
 	__le32	s_lpf_ino;		/* Location of the lost+found inode */
-	__le32	s_reserved[100];	/* Padding to the end of the block */
+	__le32	s_prj_quota_inum;	/* inode for tracking project quota */
+	__le32	s_reserved[99];		/* Padding to the end of the block */
 	__le32	s_checksum;		/* crc32c(superblock) */
 };
 
@@ -1566,6 +1571,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
  */
 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
 #define EXT4_FEATURE_RO_COMPAT_READONLY		0x1000
+#define EXT4_FEATURE_RO_COMPAT_PROJECT		0x2000
 
 #define EXT4_FEATURE_INCOMPAT_COMPRESSION	0x0001
 #define EXT4_FEATURE_INCOMPAT_FILETYPE		0x0002
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 9b964a5..f15d980 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -197,6 +197,7 @@ struct inodes_stat_t {
 #define FS_EXTENT_FL			0x00080000 /* Extents */
 #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
 #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
+#define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
 
 #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-10-18  1:01 ` Theodore Ts'o
@ 2015-10-18  2:25   ` Li Xi
  0 siblings, 0 replies; 45+ messages in thread
From: Li Xi @ 2015-10-18  2:25 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: linux-fsdevel, Ext4 Developers List, linux-api, Andreas Dilger,
	Jan Kara, viro, hch, Dmitry Monakhov

Hi Ted,

I checked it and didn't find anything missing or different.

Regards,
Li Xi

On Sun, Oct 18, 2015 at 9:01 AM, Theodore Ts'o <tytso@mit.edu> wrote:
> This is a patch to reserve the code points used by the project quota
> feature.  It should be the no different from the ones used by the
> project quota patches; please let me know ASAP if you spot any
> discrepancies, or anything else that I might have missed.
>
> Cheers,
>
>                                         - Ted
>
>
> commit 8b4953e13f4c5d9a3c869f5fca7d51e1700e7db0
> Author: Theodore Ts'o <tytso@mit.edu>
> Date:   Sat Oct 17 16:15:18 2015 -0400
>
>     ext4: reserve code points for the project quota feature
>
>     Signed-off-by: Theodore Ts'o <tytso@mit.edu>
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 3f248c9..320f10e 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -374,6 +374,7 @@ struct flex_groups {
>  #define EXT4_EA_INODE_FL               0x00200000 /* Inode used for large EA */
>  #define EXT4_EOFBLOCKS_FL              0x00400000 /* Blocks allocated beyond EOF */
>  #define EXT4_INLINE_DATA_FL            0x10000000 /* Inode has inline data. */
> +#define EXT4_PROJINHERIT_FL            0x20000000 /* Create with parents projid */
>  #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
>
>  #define EXT4_FL_USER_VISIBLE           0x004BDFFF /* User visible flags */
> @@ -431,6 +432,7 @@ enum {
>         EXT4_INODE_EA_INODE     = 21,   /* Inode used for large EA */
>         EXT4_INODE_EOFBLOCKS    = 22,   /* Blocks allocated beyond EOF */
>         EXT4_INODE_INLINE_DATA  = 28,   /* Data in inode. */
> +       EXT4_INODE_PROJINHERIT  = 29,   /* Create with parents projid */
>         EXT4_INODE_RESERVED     = 31,   /* reserved for ext4 lib */
>  };
>
> @@ -475,6 +477,7 @@ static inline void ext4_check_flag_values(void)
>         CHECK_FLAG_VALUE(EA_INODE);
>         CHECK_FLAG_VALUE(EOFBLOCKS);
>         CHECK_FLAG_VALUE(INLINE_DATA);
> +       CHECK_FLAG_VALUE(PROJINHERIT);
>         CHECK_FLAG_VALUE(RESERVED);
>  }
>
> @@ -692,6 +695,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 {
> @@ -1179,7 +1183,8 @@ struct ext4_super_block {
>         __u8    s_encrypt_algos[4];     /* Encryption algorithms in use  */
>         __u8    s_encrypt_pw_salt[16];  /* Salt used for string2key algorithm */
>         __le32  s_lpf_ino;              /* Location of the lost+found inode */
> -       __le32  s_reserved[100];        /* Padding to the end of the block */
> +       __le32  s_prj_quota_inum;       /* inode for tracking project quota */
> +       __le32  s_reserved[99];         /* Padding to the end of the block */
>         __le32  s_checksum;             /* crc32c(superblock) */
>  };
>
> @@ -1566,6 +1571,7 @@ static inline int ext4_encrypted_inode(struct inode *inode)
>   */
>  #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM   0x0400
>  #define EXT4_FEATURE_RO_COMPAT_READONLY                0x1000
> +#define EXT4_FEATURE_RO_COMPAT_PROJECT         0x2000
>
>  #define EXT4_FEATURE_INCOMPAT_COMPRESSION      0x0001
>  #define EXT4_FEATURE_INCOMPAT_FILETYPE         0x0002
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index 9b964a5..f15d980 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -197,6 +197,7 @@ struct inodes_stat_t {
>  #define FS_EXTENT_FL                   0x00080000 /* Extents */
>  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
>  #define FS_NOCOW_FL                    0x00800000 /* Do not cow file */
> +#define FS_PROJINHERIT_FL              0x20000000 /* Create with parents projid */
>  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
>
>  #define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-09-24 17:12   ` [v15 0/4] ext4: add " Andreas Dilger
@ 2015-11-05 14:45     ` Li Xi
  2015-11-05 15:13       ` Shuichi Ihara
  0 siblings, 1 reply; 45+ messages in thread
From: Li Xi @ 2015-11-05 14:45 UTC (permalink / raw)
  To: Andreas Dilger
  Cc: linux-fsdevel, linux-ext4, Linux API, Theodore Ts'o,
	Jan Kara, Al Viro, Christoph Hellwig, Dave Chinner,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Fri, Sep 25, 2015 at 1:12 AM, Andreas Dilger <adilger@dilger.ca> wrote:
> On Sep 13, 2015, at 2:20 PM, Li Xi <pkuelelixi@gmail.com> wrote:
>>
>> The following patches propose an implementation of project quota
>> support for ext4. A project is an aggregate of unrelated inodes
>> which might scatter in different directories. Inodes that belong
>> to the same project possess an identical identification i.e.
>> 'project ID', just like every inode has its user/group
>> identification. The following patches add project quota as
>> supplement to the former uer/group quota types.
>
> We discussed this on the ext4 developer concall today and tried to
> move the landing of these patches forward.  Some notes below:
>
> - Ted: agreed to reserve EXT4_FEATURE_RO_COMPAT_PROJECT, s_prj_quota_inum,
>   EXT4_PROJINHERIT_FL, and i_projid fields for use by project quota to
>   avoid compatibility issues if patches are not landed immediately.
>    - Ted: to do final check of inode flag value
>    - ext4 project quota inode does not need to use a reserved inode, but
>      could after Jan's patch to increase reserved inodes lands
> - Li Xi: identify xfstests subtests that are exercising project quota
>    - submit patches to xfstests that will activate them for ext4
>    - keep in ext4 xfstests for testing until patches land upstream
>    - this needs to be done before landing to ensure ext4 code works
> - Li Xi: document the behaviour of project quota (if no existing
>   document exists for XFS already), some of this is already below
>    - update man pages for df(1) and statfs(2) for subdir with project ID
>      (i.e. that it returns only quota usage and limit for project ID)
>    - Ted: where should document go? linux/Documentation/fs? ext4 wiki?
>    - not a requirement for testing, can be done after landing
>
> - All: decide on a common tool for setting project ID on file/directory
>    - don't want to require xfsutils in order to use project quota
>    - start with chattr (using FS_IOC_FS{GET,SET}XATTR) in e2fsprogs
>      - allows testing project quota with e2fsprogs/ext4
>    - chproj (like chown/chgrp) would also be an option
>      - needs more discussion/development effort, goes into fileutils
>    - this doesn't need to be decided immediately, and both could be done
>
Hi,

I've pushed the patch of Ext4 as well as e2fsprogs. Shilong has added test
suits for ext4 project quota in xfstest, and will push patches soon. I
will write
necessary documentation both for manual and linux/Documentation/fs.

Hopefully, at least the kernel patches of ext4 project quota will be merged
soon.

Regards,
Li Xi

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-05 14:45     ` Li Xi
@ 2015-11-05 15:13       ` Shuichi Ihara
       [not found]         ` <7360A48E-8576-49DB-878B-DFC2EFC83BC4-LfVdkaOWEx8@public.gmane.org>
  0 siblings, 1 reply; 45+ messages in thread
From: Shuichi Ihara @ 2015-11-05 15:13 UTC (permalink / raw)
  To: Li Xi, Andreas Dilger, Theodore Ts'o
  Cc: linux-fsdevel, linux-ext4, Linux API, Jan Kara, Al Viro,
	Christoph Hellwig, Dave Chinner,
	Дмитрий
	Монахов,
	Shuichi Ihara

Hello Ted, Andreas,



Shilong posted an email here a week ago below.
http://lists.openwall.net/linux-ext4/2015/10/30/2

we identified 10 project quota related xfstest and ported them into ext4/xxx.
test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.


We ported 9/10 tests into ext4/xxx
ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401

please check https://github.com/wangshilong/xfstests

An another patch was not valid since quota utility is different.


In order to run ported tests, patched quota-tools and Li Xi ported patch of e2fsprogs required.
https://github.com/wangshilong/quota-tools/commits/project
http://lists.openwall.net/linux-ext4/2015/10/29/2

Thanks
Ihara

11/5/15, 11:45 PM , "linux-ext4-owner@vger.kernel.org (Li Xi の代理)" <linux-ext4-owner@vger.kernel.org (pkuelelixi@gmail.com の代理)> wrote:

>On Fri, Sep 25, 2015 at 1:12 AM, Andreas Dilger <adilger@dilger.ca> wrote:
>> On Sep 13, 2015, at 2:20 PM, Li Xi <pkuelelixi@gmail.com> wrote:
>>>
>>> The following patches propose an implementation of project quota
>>> support for ext4. A project is an aggregate of unrelated inodes
>>> which might scatter in different directories. Inodes that belong
>>> to the same project possess an identical identification i.e.
>>> 'project ID', just like every inode has its user/group
>>> identification. The following patches add project quota as
>>> supplement to the former uer/group quota types.
>>
>> We discussed this on the ext4 developer concall today and tried to
>> move the landing of these patches forward.  Some notes below:
>>
>> - Ted: agreed to reserve EXT4_FEATURE_RO_COMPAT_PROJECT, s_prj_quota_inum,
>>   EXT4_PROJINHERIT_FL, and i_projid fields for use by project quota to
>>   avoid compatibility issues if patches are not landed immediately.
>>    - Ted: to do final check of inode flag value
>>    - ext4 project quota inode does not need to use a reserved inode, but
>>      could after Jan's patch to increase reserved inodes lands
>> - Li Xi: identify xfstests subtests that are exercising project quota
>>    - submit patches to xfstests that will activate them for ext4
>>    - keep in ext4 xfstests for testing until patches land upstream
>>    - this needs to be done before landing to ensure ext4 code works
>> - Li Xi: document the behaviour of project quota (if no existing
>>   document exists for XFS already), some of this is already below
>>    - update man pages for df(1) and statfs(2) for subdir with project ID
>>      (i.e. that it returns only quota usage and limit for project ID)
>>    - Ted: where should document go? linux/Documentation/fs? ext4 wiki?
>>    - not a requirement for testing, can be done after landing
>>
>> - All: decide on a common tool for setting project ID on file/directory
>>    - don't want to require xfsutils in order to use project quota
>>    - start with chattr (using FS_IOC_FS{GET,SET}XATTR) in e2fsprogs
>>      - allows testing project quota with e2fsprogs/ext4
>>    - chproj (like chown/chgrp) would also be an option
>>      - needs more discussion/development effort, goes into fileutils
>>    - this doesn't need to be decided immediately, and both could be done
>>
>Hi,
>
>I've pushed the patch of Ext4 as well as e2fsprogs. Shilong has added test
>suits for ext4 project quota in xfstest, and will push patches soon. I
>will write
>necessary documentation both for manual and linux/Documentation/fs.
>
>Hopefully, at least the kernel patches of ext4 project quota will be merged
>soon.
>
>Regards,
>Li Xi
>--
>To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
       [not found]         ` <7360A48E-8576-49DB-878B-DFC2EFC83BC4-LfVdkaOWEx8@public.gmane.org>
@ 2015-11-08 21:28           ` Dave Chinner
  2015-11-18 14:14             ` Shuichi Ihara
  0 siblings, 1 reply; 45+ messages in thread
From: Dave Chinner @ 2015-11-08 21:28 UTC (permalink / raw)
  To: Shuichi Ihara
  Cc: Li Xi, Andreas Dilger, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> Hello Ted, Andreas,
> 
> Shilong posted an email here a week ago below.
> http://lists.openwall.net/linux-ext4/2015/10/30/2
> 
> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> 
> 
> We ported 9/10 tests into ext4/xxx
> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401

Please make them generic tests - the ext4 project quota
functioanlity should work with those tests being completely
unchanged except for a "_requires_project_quota()" function...

Cheers,

Dave.
-- 
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-08 21:28           ` Dave Chinner
@ 2015-11-18 14:14             ` Shuichi Ihara
  2015-11-19 21:47               ` Dave Chinner
  0 siblings, 1 reply; 45+ messages in thread
From: Shuichi Ihara @ 2015-11-18 14:14 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Li Xi, Andreas Dilger, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara


11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:

>On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
>> Hello Ted, Andreas,
>> 
>> Shilong posted an email here a week ago below.
>> http://lists.openwall.net/linux-ext4/2015/10/30/2
>> 
>> we identified 10 project quota related xfstest and ported them into ext4/xxx.
>> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
>> 
>> 
>> We ported 9/10 tests into ext4/xxx
>> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
>
>Please make them generic tests - the ext4 project quota
>functioanlity should work with those tests being completely
>unchanged except for a "_requires_project_quota()" function...

Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
xfs uses own interface xfs_xx for project quota tests in xfs.
what interface are you looking at if we move ext4's project quota tests into generic tests?

Thanks
Ihara

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-18 14:14             ` Shuichi Ihara
@ 2015-11-19 21:47               ` Dave Chinner
  2015-11-23  1:45                   ` Andreas Dilger
  2015-11-23  9:25                   ` Jan Kara
  0 siblings, 2 replies; 45+ messages in thread
From: Dave Chinner @ 2015-11-19 21:47 UTC (permalink / raw)
  To: Shuichi Ihara
  Cc: Li Xi, Andreas Dilger, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> 
> 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
> 
> >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> >> Hello Ted, Andreas,
> >> 
> >> Shilong posted an email here a week ago below.
> >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> >> 
> >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> >> 
> >> 
> >> We ported 9/10 tests into ext4/xxx
> >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> >
> >Please make them generic tests - the ext4 project quota
> >functioanlity should work with those tests being completely
> >unchanged except for a "_requires_project_quota()" function...
> 
> Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> xfs uses own interface xfs_xx for project quota tests in xfs.
> what interface are you looking at if we move ext4's project quota tests into generic tests?

The project quota support in the generic quota tool should work XFS
as well as ext4. If it doesn't, then it's not a generic tool, right?
The whole point of having ext4 use the same userspace API as XFS is
so that all quotas can be managed with the one tool. Essentially, if
ext4 project quotas cannot be controlled by xfs_quota, then the ext4
code is not compatible with XFS and hence still needs work.

FWIW, if ext4 has implemented the kernel project quota interfaces
correctly, then it should not matter whether we use xfs_quota or the
generic quotatool because the kernel will translate the filesystem
information to whatever format the quota was requested in...

So, you should be able to simply use the xfs_quota tool in the tests
you make generic without needing any significant modification to the
tests to run them on ext4. Yes, that may mean you need to send a 5
line patch to make xfs_quota run on ext4, but that's trivial
compared to duplicating >10 tests and then having to maintain them
forever...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-19 21:47               ` Dave Chinner
@ 2015-11-23  1:45                   ` Andreas Dilger
  2015-11-23  9:25                   ` Jan Kara
  1 sibling, 0 replies; 45+ messages in thread
From: Andreas Dilger @ 2015-11-23  1:45 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Shuichi Ihara, Li Xi, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]

On Nov 19, 2015, at 2:47 PM, Dave Chinner <david@fromorbit.com> wrote:
> 
> On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
>> 
>> 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
>> 
>>> On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
>>>> Hello Ted, Andreas,
>>>> 
>>>> Shilong posted an email here a week ago below.
>>>> http://lists.openwall.net/linux-ext4/2015/10/30/2
>>>> 
>>>> we identified 10 project quota related xfstest and ported them into ext4/xxx.
>>>> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
>>>> 
>>>> 
>>>> We ported 9/10 tests into ext4/xxx
>>>> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
>>> 
>>> Please make them generic tests - the ext4 project quota
>>> functioanlity should work with those tests being completely
>>> unchanged except for a "_requires_project_quota()" function...
>> 
>> Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
>> xfs uses own interface xfs_xx for project quota tests in xfs.
>> what interface are you looking at if we move ext4's project quota tests into generic tests?
> 
> The project quota support in the generic quota tool should work XFS
> as well as ext4. If it doesn't, then it's not a generic tool, right?
> The whole point of having ext4 use the same userspace API as XFS is
> so that all quotas can be managed with the one tool. Essentially, if
> ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> code is not compatible with XFS and hence still needs work.
> 
> FWIW, if ext4 has implemented the kernel project quota interfaces
> correctly, then it should not matter whether we use xfs_quota or the
> generic quotatool because the kernel will translate the filesystem
> information to whatever format the quota was requested in...
> 
> So, you should be able to simply use the xfs_quota tool in the tests
> you make generic without needing any significant modification to the
> tests to run them on ext4. Yes, that may mean you need to send a 5
> line patch to make xfs_quota run on ext4, but that's trivial
> compared to duplicating >10 tests and then having to maintain them
> forever...

I think it also makes sense to have tests for the generic quota tools,
which is what current ext4 users will have installed, and not just
xfs_quota.  This applies to both ext4 and xfs using the generic quota
tools with the new interface.  In that light, it makes sense to add
new tests that use the new quota tools, in addition to testing xfs_quota
on XFS and ext4.

Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23  1:45                   ` Andreas Dilger
  0 siblings, 0 replies; 45+ messages in thread
From: Andreas Dilger @ 2015-11-23  1:45 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Shuichi Ihara, Li Xi, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

[-- Attachment #1: Type: text/plain, Size: 2754 bytes --]

On Nov 19, 2015, at 2:47 PM, Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> 
> On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
>> 
>> 11/9/15, 6:28 AM , "Dave Chinner" <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
>> 
>>> On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
>>>> Hello Ted, Andreas,
>>>> 
>>>> Shilong posted an email here a week ago below.
>>>> http://lists.openwall.net/linux-ext4/2015/10/30/2
>>>> 
>>>> we identified 10 project quota related xfstest and ported them into ext4/xxx.
>>>> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
>>>> 
>>>> 
>>>> We ported 9/10 tests into ext4/xxx
>>>> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
>>> 
>>> Please make them generic tests - the ext4 project quota
>>> functioanlity should work with those tests being completely
>>> unchanged except for a "_requires_project_quota()" function...
>> 
>> Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
>> xfs uses own interface xfs_xx for project quota tests in xfs.
>> what interface are you looking at if we move ext4's project quota tests into generic tests?
> 
> The project quota support in the generic quota tool should work XFS
> as well as ext4. If it doesn't, then it's not a generic tool, right?
> The whole point of having ext4 use the same userspace API as XFS is
> so that all quotas can be managed with the one tool. Essentially, if
> ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> code is not compatible with XFS and hence still needs work.
> 
> FWIW, if ext4 has implemented the kernel project quota interfaces
> correctly, then it should not matter whether we use xfs_quota or the
> generic quotatool because the kernel will translate the filesystem
> information to whatever format the quota was requested in...
> 
> So, you should be able to simply use the xfs_quota tool in the tests
> you make generic without needing any significant modification to the
> tests to run them on ext4. Yes, that may mean you need to send a 5
> line patch to make xfs_quota run on ext4, but that's trivial
> compared to duplicating >10 tests and then having to maintain them
> forever...

I think it also makes sense to have tests for the generic quota tools,
which is what current ext4 users will have installed, and not just
xfs_quota.  This applies to both ext4 and xfs using the generic quota
tools with the new interface.  In that light, it makes sense to add
new tests that use the new quota tools, in addition to testing xfs_quota
on XFS and ext4.

Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23  2:50                     ` Dave Chinner
  0 siblings, 0 replies; 45+ messages in thread
From: Dave Chinner @ 2015-11-23  2:50 UTC (permalink / raw)
  To: Andreas Dilger
  Cc: Shuichi Ihara, Li Xi, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Sun, Nov 22, 2015 at 06:45:24PM -0700, Andreas Dilger wrote:
> On Nov 19, 2015, at 2:47 PM, Dave Chinner <david@fromorbit.com> wrote:
> > 
> > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> >> 
> >> 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
> >> 
> >>> On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> >>>> Hello Ted, Andreas,
> >>>> 
> >>>> Shilong posted an email here a week ago below.
> >>>> http://lists.openwall.net/linux-ext4/2015/10/30/2
> >>>> 
> >>>> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> >>>> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> >>>> 
> >>>> 
> >>>> We ported 9/10 tests into ext4/xxx
> >>>> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> >>> 
> >>> Please make them generic tests - the ext4 project quota
> >>> functioanlity should work with those tests being completely
> >>> unchanged except for a "_requires_project_quota()" function...
> >> 
> >> Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> >> xfs uses own interface xfs_xx for project quota tests in xfs.
> >> what interface are you looking at if we move ext4's project quota tests into generic tests?
> > 
> > The project quota support in the generic quota tool should work XFS
> > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > The whole point of having ext4 use the same userspace API as XFS is
> > so that all quotas can be managed with the one tool. Essentially, if
> > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > code is not compatible with XFS and hence still needs work.
> > 
> > FWIW, if ext4 has implemented the kernel project quota interfaces
> > correctly, then it should not matter whether we use xfs_quota or the
> > generic quotatool because the kernel will translate the filesystem
> > information to whatever format the quota was requested in...
> > 
> > So, you should be able to simply use the xfs_quota tool in the tests
> > you make generic without needing any significant modification to the
> > tests to run them on ext4. Yes, that may mean you need to send a 5
> > line patch to make xfs_quota run on ext4, but that's trivial
> > compared to duplicating >10 tests and then having to maintain them
> > forever...
> 
> I think it also makes sense to have tests for the generic quota tools,
> which is what current ext4 users will have installed, and not just
> xfs_quota.  This applies to both ext4 and xfs using the generic quota
> tools with the new interface.

Yes, I said as much: "... it should not matter whether we use
xfs_quota or the generic quotatool ....". I've been saying that tool
compability is an absolute requirement for the ext4 project quota
implementation from the very start - I'm not about to say it doesn't
matter now.

Yes, eventually we need to have tests for the generic quotatool,
but only having generic quotatool tests run only on ext4 does not
prove anything about the compatibility of the new ext4 kernel code
with the pre-existing quota tools and kernel APIs.

> In that light, it makes sense to add
> new tests that use the new quota tools, in addition to testing xfs_quota
> on XFS and ext4.

The first step is not "duplicate all the tests with different
infrastructure as new one-filesystem-only specific tests".  We need
to ensure the APIs are compatible *before merging the kernel code*,
and these tests do no do that.

IOWs, like all the other tests we've made generic for kernel
functionality we've moved from XFS to generic code, the steps are:

	1. move the tests from tests/xfs to tests/generic
	2. make the xfs specific utilities work on non XFS
	   filesystems and, if necessary, use the new generic kernel
	   API.
	3. make the tests also run and passwork on non-XFS filesystems

	[ at this point we can say the new ext4 kernel code is good to
	  commit ]

	4. factor the generic tests so that the test core is
	   independent of the infrastructure that needs testing
	5. Duplicate the generic tests *as generic tests* using the
	   different tools that need testing /or/ make the
	   tooling selectable by environment/config file
	   variables.

After step 5, we should have tests that run on multiple filesystems
using multiple tools, and they all give the same results. The tests
as proposed don't provide us with any guarantee that the generic
quota tool will work on XFS, nor that ext4 has an API that is
compatible with XFS.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23  2:50                     ` Dave Chinner
  0 siblings, 0 replies; 45+ messages in thread
From: Dave Chinner @ 2015-11-23  2:50 UTC (permalink / raw)
  To: Andreas Dilger
  Cc: Shuichi Ihara, Li Xi, Theodore Ts'o, linux-fsdevel,
	linux-ext4, Linux API, Jan Kara, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Sun, Nov 22, 2015 at 06:45:24PM -0700, Andreas Dilger wrote:
> On Nov 19, 2015, at 2:47 PM, Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> > 
> > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> >> 
> >> 11/9/15, 6:28 AM , "Dave Chinner" <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> >> 
> >>> On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> >>>> Hello Ted, Andreas,
> >>>> 
> >>>> Shilong posted an email here a week ago below.
> >>>> http://lists.openwall.net/linux-ext4/2015/10/30/2
> >>>> 
> >>>> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> >>>> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> >>>> 
> >>>> 
> >>>> We ported 9/10 tests into ext4/xxx
> >>>> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> >>> 
> >>> Please make them generic tests - the ext4 project quota
> >>> functioanlity should work with those tests being completely
> >>> unchanged except for a "_requires_project_quota()" function...
> >> 
> >> Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> >> xfs uses own interface xfs_xx for project quota tests in xfs.
> >> what interface are you looking at if we move ext4's project quota tests into generic tests?
> > 
> > The project quota support in the generic quota tool should work XFS
> > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > The whole point of having ext4 use the same userspace API as XFS is
> > so that all quotas can be managed with the one tool. Essentially, if
> > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > code is not compatible with XFS and hence still needs work.
> > 
> > FWIW, if ext4 has implemented the kernel project quota interfaces
> > correctly, then it should not matter whether we use xfs_quota or the
> > generic quotatool because the kernel will translate the filesystem
> > information to whatever format the quota was requested in...
> > 
> > So, you should be able to simply use the xfs_quota tool in the tests
> > you make generic without needing any significant modification to the
> > tests to run them on ext4. Yes, that may mean you need to send a 5
> > line patch to make xfs_quota run on ext4, but that's trivial
> > compared to duplicating >10 tests and then having to maintain them
> > forever...
> 
> I think it also makes sense to have tests for the generic quota tools,
> which is what current ext4 users will have installed, and not just
> xfs_quota.  This applies to both ext4 and xfs using the generic quota
> tools with the new interface.

Yes, I said as much: "... it should not matter whether we use
xfs_quota or the generic quotatool ....". I've been saying that tool
compability is an absolute requirement for the ext4 project quota
implementation from the very start - I'm not about to say it doesn't
matter now.

Yes, eventually we need to have tests for the generic quotatool,
but only having generic quotatool tests run only on ext4 does not
prove anything about the compatibility of the new ext4 kernel code
with the pre-existing quota tools and kernel APIs.

> In that light, it makes sense to add
> new tests that use the new quota tools, in addition to testing xfs_quota
> on XFS and ext4.

The first step is not "duplicate all the tests with different
infrastructure as new one-filesystem-only specific tests".  We need
to ensure the APIs are compatible *before merging the kernel code*,
and these tests do no do that.

IOWs, like all the other tests we've made generic for kernel
functionality we've moved from XFS to generic code, the steps are:

	1. move the tests from tests/xfs to tests/generic
	2. make the xfs specific utilities work on non XFS
	   filesystems and, if necessary, use the new generic kernel
	   API.
	3. make the tests also run and passwork on non-XFS filesystems

	[ at this point we can say the new ext4 kernel code is good to
	  commit ]

	4. factor the generic tests so that the test core is
	   independent of the infrastructure that needs testing
	5. Duplicate the generic tests *as generic tests* using the
	   different tools that need testing /or/ make the
	   tooling selectable by environment/config file
	   variables.

After step 5, we should have tests that run on multiple filesystems
using multiple tools, and they all give the same results. The tests
as proposed don't provide us with any guarantee that the generic
quota tool will work on XFS, nor that ext4 has an API that is
compatible with XFS.

Cheers,

Dave.
-- 
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-19 21:47               ` Dave Chinner
@ 2015-11-23  9:25                   ` Jan Kara
  2015-11-23  9:25                   ` Jan Kara
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-11-23  9:25 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Shuichi Ihara, Li Xi, Andreas Dilger, Theodore Ts'o,
	linux-fsdevel, linux-ext4, Linux API, Jan Kara, Al Viro,
	Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > 
> > 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
> > 
> > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > >> Hello Ted, Andreas,
> > >> 
> > >> Shilong posted an email here a week ago below.
> > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > >> 
> > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > >> 
> > >> 
> > >> We ported 9/10 tests into ext4/xxx
> > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > >
> > >Please make them generic tests - the ext4 project quota
> > >functioanlity should work with those tests being completely
> > >unchanged except for a "_requires_project_quota()" function...
> > 
> > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > xfs uses own interface xfs_xx for project quota tests in xfs.
> > what interface are you looking at if we move ext4's project quota tests into generic tests?
> 
> The project quota support in the generic quota tool should work XFS
> as well as ext4. If it doesn't, then it's not a generic tool, right?
> The whole point of having ext4 use the same userspace API as XFS is
> so that all quotas can be managed with the one tool. Essentially, if
> ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> code is not compatible with XFS and hence still needs work.
> 
> FWIW, if ext4 has implemented the kernel project quota interfaces
> correctly, then it should not matter whether we use xfs_quota or the
> generic quotatool because the kernel will translate the filesystem
> information to whatever format the quota was requested in...
> 
> So, you should be able to simply use the xfs_quota tool in the tests
> you make generic without needing any significant modification to the
> tests to run them on ext4. Yes, that may mean you need to send a 5
> line patch to make xfs_quota run on ext4, but that's trivial
> compared to duplicating >10 tests and then having to maintain them
> forever...

Yeah, last time I tried the only modification xfs_quota tool needed to work
correctly with ext4 was to remove / modify the check for filesystem type
in fs_table_initialise_mounts(). The question is how to properly deal with
that. I don't think just removing the fs type check is the right way to go
as that will have unexpected side effects for operations working on
"all" filesystems - currently these are restricted to "all" *XFS*
filesystems.

Maybe we can add a command line option which will disable the fs type check
so that non-XFS filesystems can be handled. We used to have an option like
this for xfs_io but it seems it got removed so I'm not sure we want to add
that into xfs_quota though. Dave?

Another option would be to use generic quota-tools for project quota tests
once the patches land. But that would require some more work on xfstests
side and so far I didn't get an official submission of patches for
quota-tools to support project quota.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23  9:25                   ` Jan Kara
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-11-23  9:25 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Shuichi Ihara, Li Xi, Andreas Dilger, Theodore Ts'o,
	linux-fsdevel, linux-ext4, Linux API, Jan Kara, Al Viro,
	Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > 
> > 11/9/15, 6:28 AM , "Dave Chinner" <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> > 
> > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > >> Hello Ted, Andreas,
> > >> 
> > >> Shilong posted an email here a week ago below.
> > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > >> 
> > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > >> 
> > >> 
> > >> We ported 9/10 tests into ext4/xxx
> > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > >
> > >Please make them generic tests - the ext4 project quota
> > >functioanlity should work with those tests being completely
> > >unchanged except for a "_requires_project_quota()" function...
> > 
> > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > xfs uses own interface xfs_xx for project quota tests in xfs.
> > what interface are you looking at if we move ext4's project quota tests into generic tests?
> 
> The project quota support in the generic quota tool should work XFS
> as well as ext4. If it doesn't, then it's not a generic tool, right?
> The whole point of having ext4 use the same userspace API as XFS is
> so that all quotas can be managed with the one tool. Essentially, if
> ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> code is not compatible with XFS and hence still needs work.
> 
> FWIW, if ext4 has implemented the kernel project quota interfaces
> correctly, then it should not matter whether we use xfs_quota or the
> generic quotatool because the kernel will translate the filesystem
> information to whatever format the quota was requested in...
> 
> So, you should be able to simply use the xfs_quota tool in the tests
> you make generic without needing any significant modification to the
> tests to run them on ext4. Yes, that may mean you need to send a 5
> line patch to make xfs_quota run on ext4, but that's trivial
> compared to duplicating >10 tests and then having to maintain them
> forever...

Yeah, last time I tried the only modification xfs_quota tool needed to work
correctly with ext4 was to remove / modify the check for filesystem type
in fs_table_initialise_mounts(). The question is how to properly deal with
that. I don't think just removing the fs type check is the right way to go
as that will have unexpected side effects for operations working on
"all" filesystems - currently these are restricted to "all" *XFS*
filesystems.

Maybe we can add a command line option which will disable the fs type check
so that non-XFS filesystems can be handled. We used to have an option like
this for xfs_io but it seems it got removed so I'm not sure we want to add
that into xfs_quota though. Dave?

Another option would be to use generic quota-tools for project quota tests
once the patches land. But that would require some more work on xfstests
side and so far I didn't get an official submission of patches for
quota-tools to support project quota.

								Honza

-- 
Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23 20:15                     ` Dave Chinner
  0 siblings, 0 replies; 45+ messages in thread
From: Dave Chinner @ 2015-11-23 20:15 UTC (permalink / raw)
  To: Jan Kara
  Cc: Shuichi Ihara, Li Xi, Andreas Dilger, Theodore Ts'o,
	linux-fsdevel, linux-ext4, Linux API, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Mon, Nov 23, 2015 at 10:25:23AM +0100, Jan Kara wrote:
> On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > > 
> > > 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
> > > 
> > > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > > >> Hello Ted, Andreas,
> > > >> 
> > > >> Shilong posted an email here a week ago below.
> > > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > > >> 
> > > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > > >> 
> > > >> 
> > > >> We ported 9/10 tests into ext4/xxx
> > > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > > >
> > > >Please make them generic tests - the ext4 project quota
> > > >functioanlity should work with those tests being completely
> > > >unchanged except for a "_requires_project_quota()" function...
> > > 
> > > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > > xfs uses own interface xfs_xx for project quota tests in xfs.
> > > what interface are you looking at if we move ext4's project quota tests into generic tests?
> > 
> > The project quota support in the generic quota tool should work XFS
> > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > The whole point of having ext4 use the same userspace API as XFS is
> > so that all quotas can be managed with the one tool. Essentially, if
> > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > code is not compatible with XFS and hence still needs work.
> > 
> > FWIW, if ext4 has implemented the kernel project quota interfaces
> > correctly, then it should not matter whether we use xfs_quota or the
> > generic quotatool because the kernel will translate the filesystem
> > information to whatever format the quota was requested in...
> > 
> > So, you should be able to simply use the xfs_quota tool in the tests
> > you make generic without needing any significant modification to the
> > tests to run them on ext4. Yes, that may mean you need to send a 5
> > line patch to make xfs_quota run on ext4, but that's trivial
> > compared to duplicating >10 tests and then having to maintain them
> > forever...
> 
> Yeah, last time I tried the only modification xfs_quota tool needed to work
> correctly with ext4 was to remove / modify the check for filesystem type
> in fs_table_initialise_mounts(). The question is how to properly deal with
> that. I don't think just removing the fs type check is the right way to go
> as that will have unexpected side effects for operations working on
> "all" filesystems - currently these are restricted to "all" *XFS*
> filesystems.
> 
> Maybe we can add a command line option which will disable the fs type check
> so that non-XFS filesystems can be handled. We used to have an option like
> this for xfs_io but it seems it got removed so I'm not sure we want to add
> that into xfs_quota though. Dave?

The option is still there in xfs_io, we just ignore it because
we do the detection automatically now via:

                if (!platform_test_xfs_fd(c))
                        flags |= IO_FOREIGN;

The rest of the libxcmd infrastructure handles enabling/disabling
the commands for foreign filesystems  via the
io/init.c::init_check_command() function, which does:

        if (file && !(ct->flags & CMD_FOREIGN_OK) &&
                                        (file->flags & IO_FOREIGN)) {
                fprintf(stderr,
        _("foreign file active, %s command is for XFS filesystems only\n"),
                        ct->name);
                return 0;
        }


It is trivial to add this to xfs_quota (ok, it's 20 lines of code)
and so allow the relevant commands the tests need to operate on
foreign filesystems.

> Another option would be to use generic quota-tools for project quota tests
> once the patches land. But that would require some more work on xfstests
> side and so far I didn't get an official submission of patches for
> quota-tools to support project quota.

Eventually, yes. But we don't have to wait for that to happen if we
use the xfs-quota tool to begin with.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-23 20:15                     ` Dave Chinner
  0 siblings, 0 replies; 45+ messages in thread
From: Dave Chinner @ 2015-11-23 20:15 UTC (permalink / raw)
  To: Jan Kara
  Cc: Shuichi Ihara, Li Xi, Andreas Dilger, Theodore Ts'o,
	linux-fsdevel, linux-ext4, Linux API, Al Viro, Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Mon, Nov 23, 2015 at 10:25:23AM +0100, Jan Kara wrote:
> On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > > 
> > > 11/9/15, 6:28 AM , "Dave Chinner" <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> > > 
> > > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > > >> Hello Ted, Andreas,
> > > >> 
> > > >> Shilong posted an email here a week ago below.
> > > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > > >> 
> > > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > > >> 
> > > >> 
> > > >> We ported 9/10 tests into ext4/xxx
> > > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > > >
> > > >Please make them generic tests - the ext4 project quota
> > > >functioanlity should work with those tests being completely
> > > >unchanged except for a "_requires_project_quota()" function...
> > > 
> > > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > > xfs uses own interface xfs_xx for project quota tests in xfs.
> > > what interface are you looking at if we move ext4's project quota tests into generic tests?
> > 
> > The project quota support in the generic quota tool should work XFS
> > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > The whole point of having ext4 use the same userspace API as XFS is
> > so that all quotas can be managed with the one tool. Essentially, if
> > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > code is not compatible with XFS and hence still needs work.
> > 
> > FWIW, if ext4 has implemented the kernel project quota interfaces
> > correctly, then it should not matter whether we use xfs_quota or the
> > generic quotatool because the kernel will translate the filesystem
> > information to whatever format the quota was requested in...
> > 
> > So, you should be able to simply use the xfs_quota tool in the tests
> > you make generic without needing any significant modification to the
> > tests to run them on ext4. Yes, that may mean you need to send a 5
> > line patch to make xfs_quota run on ext4, but that's trivial
> > compared to duplicating >10 tests and then having to maintain them
> > forever...
> 
> Yeah, last time I tried the only modification xfs_quota tool needed to work
> correctly with ext4 was to remove / modify the check for filesystem type
> in fs_table_initialise_mounts(). The question is how to properly deal with
> that. I don't think just removing the fs type check is the right way to go
> as that will have unexpected side effects for operations working on
> "all" filesystems - currently these are restricted to "all" *XFS*
> filesystems.
> 
> Maybe we can add a command line option which will disable the fs type check
> so that non-XFS filesystems can be handled. We used to have an option like
> this for xfs_io but it seems it got removed so I'm not sure we want to add
> that into xfs_quota though. Dave?

The option is still there in xfs_io, we just ignore it because
we do the detection automatically now via:

                if (!platform_test_xfs_fd(c))
                        flags |= IO_FOREIGN;

The rest of the libxcmd infrastructure handles enabling/disabling
the commands for foreign filesystems  via the
io/init.c::init_check_command() function, which does:

        if (file && !(ct->flags & CMD_FOREIGN_OK) &&
                                        (file->flags & IO_FOREIGN)) {
                fprintf(stderr,
        _("foreign file active, %s command is for XFS filesystems only\n"),
                        ct->name);
                return 0;
        }


It is trivial to add this to xfs_quota (ok, it's 20 lines of code)
and so allow the relevant commands the tests need to operate on
foreign filesystems.

> Another option would be to use generic quota-tools for project quota tests
> once the patches land. But that would require some more work on xfstests
> side and so far I didn't get an official submission of patches for
> quota-tools to support project quota.

Eventually, yes. But we don't have to wait for that to happen if we
use the xfs-quota tool to begin with.

Cheers,

Dave.
-- 
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
  2015-11-23 20:15                     ` Dave Chinner
@ 2015-11-24  9:07                       ` Jan Kara
  -1 siblings, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-11-24  9:07 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Jan Kara, Shuichi Ihara, Li Xi, Andreas Dilger,
	Theodore Ts'o, linux-fsdevel, linux-ext4, Linux API, Al Viro,
	Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Tue 24-11-15 07:15:23, Dave Chinner wrote:
> On Mon, Nov 23, 2015 at 10:25:23AM +0100, Jan Kara wrote:
> > On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> > > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > > > 
> > > > 11/9/15, 6:28 AM , "Dave Chinner" <david@fromorbit.com> wrote:
> > > > 
> > > > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > > > >> Hello Ted, Andreas,
> > > > >> 
> > > > >> Shilong posted an email here a week ago below.
> > > > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > > > >> 
> > > > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > > > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > > > >> 
> > > > >> 
> > > > >> We ported 9/10 tests into ext4/xxx
> > > > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > > > >
> > > > >Please make them generic tests - the ext4 project quota
> > > > >functioanlity should work with those tests being completely
> > > > >unchanged except for a "_requires_project_quota()" function...
> > > > 
> > > > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > > > xfs uses own interface xfs_xx for project quota tests in xfs.
> > > > what interface are you looking at if we move ext4's project quota tests into generic tests?
> > > 
> > > The project quota support in the generic quota tool should work XFS
> > > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > > The whole point of having ext4 use the same userspace API as XFS is
> > > so that all quotas can be managed with the one tool. Essentially, if
> > > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > > code is not compatible with XFS and hence still needs work.
> > > 
> > > FWIW, if ext4 has implemented the kernel project quota interfaces
> > > correctly, then it should not matter whether we use xfs_quota or the
> > > generic quotatool because the kernel will translate the filesystem
> > > information to whatever format the quota was requested in...
> > > 
> > > So, you should be able to simply use the xfs_quota tool in the tests
> > > you make generic without needing any significant modification to the
> > > tests to run them on ext4. Yes, that may mean you need to send a 5
> > > line patch to make xfs_quota run on ext4, but that's trivial
> > > compared to duplicating >10 tests and then having to maintain them
> > > forever...
> > 
> > Yeah, last time I tried the only modification xfs_quota tool needed to work
> > correctly with ext4 was to remove / modify the check for filesystem type
> > in fs_table_initialise_mounts(). The question is how to properly deal with
> > that. I don't think just removing the fs type check is the right way to go
> > as that will have unexpected side effects for operations working on
> > "all" filesystems - currently these are restricted to "all" *XFS*
> > filesystems.
> > 
> > Maybe we can add a command line option which will disable the fs type check
> > so that non-XFS filesystems can be handled. We used to have an option like
> > this for xfs_io but it seems it got removed so I'm not sure we want to add
> > that into xfs_quota though. Dave?
> 
> The option is still there in xfs_io, we just ignore it because
> we do the detection automatically now via:
> 
>                 if (!platform_test_xfs_fd(c))
>                         flags |= IO_FOREIGN;
> 
> The rest of the libxcmd infrastructure handles enabling/disabling
> the commands for foreign filesystems  via the
> io/init.c::init_check_command() function, which does:
> 
>         if (file && !(ct->flags & CMD_FOREIGN_OK) &&
>                                         (file->flags & IO_FOREIGN)) {
>                 fprintf(stderr,
>         _("foreign file active, %s command is for XFS filesystems only\n"),
>                         ct->name);
>                 return 0;
>         }
> 
> 
> It is trivial to add this to xfs_quota (ok, it's 20 lines of code)
> and so allow the relevant commands the tests need to operate on
> foreign filesystems.

OK, then I agree that enabling xfs_quota to work for ext4 filesystems is
the easiest way to make xfstests project quota tests work for ext4.

For usability of project quota on ext4, we want the support in quota-tools
as soon as possible anyway but it is a separate issue...
	
								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 0/4] ext4: add project quota support
@ 2015-11-24  9:07                       ` Jan Kara
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Kara @ 2015-11-24  9:07 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Jan Kara, Shuichi Ihara, Li Xi, Andreas Dilger,
	Theodore Ts'o, linux-fsdevel, linux-ext4, Linux API, Al Viro,
	Christoph Hellwig,
	Дмитрий
	Монахов,
	Shuichi Ihara

On Tue 24-11-15 07:15:23, Dave Chinner wrote:
> On Mon, Nov 23, 2015 at 10:25:23AM +0100, Jan Kara wrote:
> > On Fri 20-11-15 08:47:27, Dave Chinner wrote:
> > > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> > > > 
> > > > 11/9/15, 6:28 AM , "Dave Chinner" <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> > > > 
> > > > >On Thu, Nov 05, 2015 at 03:13:10PM +0000, Shuichi Ihara wrote:
> > > > >> Hello Ted, Andreas,
> > > > >> 
> > > > >> Shilong posted an email here a week ago below.
> > > > >> http://lists.openwall.net/linux-ext4/2015/10/30/2
> > > > >> 
> > > > >> we identified 10 project quota related xfstest and ported them into ext4/xxx.
> > > > >> test number are 304, 305, 299, 244, 196, 134, 108, 107, 106, 050 in xfs.
> > > > >> 
> > > > >> 
> > > > >> We ported 9/10 tests into ext4/xxx
> > > > >> ext4/050 ext4/106 ext4/107 ext4/108 ext4/196 ext4/244 ext4/299 ext4/400 ext4/401
> > > > >
> > > > >Please make them generic tests - the ext4 project quota
> > > > >functioanlity should work with those tests being completely
> > > > >unchanged except for a "_requires_project_quota()" function...
> > > > 
> > > > Right now, we enhanced quotatool to support project quota and above project quota tests in ext4 uses that interface.
> > > > xfs uses own interface xfs_xx for project quota tests in xfs.
> > > > what interface are you looking at if we move ext4's project quota tests into generic tests?
> > > 
> > > The project quota support in the generic quota tool should work XFS
> > > as well as ext4. If it doesn't, then it's not a generic tool, right?
> > > The whole point of having ext4 use the same userspace API as XFS is
> > > so that all quotas can be managed with the one tool. Essentially, if
> > > ext4 project quotas cannot be controlled by xfs_quota, then the ext4
> > > code is not compatible with XFS and hence still needs work.
> > > 
> > > FWIW, if ext4 has implemented the kernel project quota interfaces
> > > correctly, then it should not matter whether we use xfs_quota or the
> > > generic quotatool because the kernel will translate the filesystem
> > > information to whatever format the quota was requested in...
> > > 
> > > So, you should be able to simply use the xfs_quota tool in the tests
> > > you make generic without needing any significant modification to the
> > > tests to run them on ext4. Yes, that may mean you need to send a 5
> > > line patch to make xfs_quota run on ext4, but that's trivial
> > > compared to duplicating >10 tests and then having to maintain them
> > > forever...
> > 
> > Yeah, last time I tried the only modification xfs_quota tool needed to work
> > correctly with ext4 was to remove / modify the check for filesystem type
> > in fs_table_initialise_mounts(). The question is how to properly deal with
> > that. I don't think just removing the fs type check is the right way to go
> > as that will have unexpected side effects for operations working on
> > "all" filesystems - currently these are restricted to "all" *XFS*
> > filesystems.
> > 
> > Maybe we can add a command line option which will disable the fs type check
> > so that non-XFS filesystems can be handled. We used to have an option like
> > this for xfs_io but it seems it got removed so I'm not sure we want to add
> > that into xfs_quota though. Dave?
> 
> The option is still there in xfs_io, we just ignore it because
> we do the detection automatically now via:
> 
>                 if (!platform_test_xfs_fd(c))
>                         flags |= IO_FOREIGN;
> 
> The rest of the libxcmd infrastructure handles enabling/disabling
> the commands for foreign filesystems  via the
> io/init.c::init_check_command() function, which does:
> 
>         if (file && !(ct->flags & CMD_FOREIGN_OK) &&
>                                         (file->flags & IO_FOREIGN)) {
>                 fprintf(stderr,
>         _("foreign file active, %s command is for XFS filesystems only\n"),
>                         ct->name);
>                 return 0;
>         }
> 
> 
> It is trivial to add this to xfs_quota (ok, it's 20 lines of code)
> and so allow the relevant commands the tests need to operate on
> foreign filesystems.

OK, then I agree that enabling xfs_quota to work for ext4 filesystems is
the easiest way to make xfstests project quota tests work for ext4.

For usability of project quota on ext4, we want the support in quota-tools
as soon as possible anyway but it is a separate issue...
	
								Honza
-- 
Jan Kara <jack-IBi9RG/b67k@public.gmane.org>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [v15 4/4] ext4: cleanup inode flag definitions
@ 2015-12-28 15:23     ` Theodore Ts'o
  0 siblings, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2015-12-28 15:23 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel, linux-ext4, linux-api, adilger, jack, viro, hch,
	dmonakhov

On Sun, Sep 13, 2015 at 09:20:33PM +0900, Li Xi wrote:
> The inode flags defined in uapi/linux/fs.h were migrated from
> ext4.h. This patch changes the inode flag definitions in ext4.h
> to VFS definitions to make the gaps between them clearer.
> 
> Signed-off-by: Li Xi <lixi@ddn.com>
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Instead of doing things this way, I've decided to clean things up by
updating the flags in uapi/linux/fs.h.  That's because some people who
might want to assign new flags might not be ext4 developers, and so
they wouldn't look at fs/ext4/ext4.h.

At the same time, we really don't want people adding new flags by
default, unless there is a really good reason.  So I've added a
comment making the history of the interface and suggesting that people
not assign new flags without thinking twice (or checking with
linux-fsdevel and linux-api).

						- Ted

commit 6ac40c7b5597646ec4335f77ab79cac9663f4a1e
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Mon Dec 28 10:21:43 2015 -0500

    fs: clean up the flags definition in uapi/linux/fs.h
    
    Add an explanation for the flags used by FS_IOC_[GS]ETFLAGS and remind
    people that changes should be revised by linux-fsdevel and linux-api.
    
    Add flags that are used on-disk for ext4, and remove FS_DIRECTIO_FL
    since it was used only by gfs2 and support was removed in 2008 in
    commit c9f6a6bbc28 ("The ability to mark files for direct i/o access
    when opened normally is both unused and pointless, so this patch
    removes support for that feature.")  Now we have _two_ remaining flags
    left.  But since we want to discourage people from assigning new
    flags, that's OK.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 627f58e..35d156f 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -2,8 +2,11 @@
 #define _UAPI_LINUX_FS_H
 
 /*
- * This file has definitions for some important file table
- * structures etc.
+ * This file has definitions for some important file table structures
+ * and constants and structures used by various generic file system
+ * ioctl's.  Please do not make any changes in this file before
+ * sending patches for review to linux-fsdevel@vger.kernel.org and
+ * linux-api@vger.kernel.org.
  */
 
 #include <linux/limits.h>
@@ -204,6 +207,23 @@ struct fsxattr {
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
+ *
+ * Note: for historical reasons, these flags were originally used and
+ * defined for use by ext2/ext3, and then other file systems started
+ * using these flags so they wouldn't need to write their own version
+ * of chattr/lsattr (which was shipped as part of e2fsprogs).  You
+ * should think twice before trying to use these flags in new
+ * contexts, or trying to assign these flags, since they are used both
+ * as the UAPI and the on-disk encoding for ext2/3/4.  Also, we are
+ * almost out of 32-bit flags.  :-)
+ *
+ * We have recently hoisted FS_IOC_FSGETXATTR / FS_IOC_FSSETXATTR from
+ * XFS to the generic FS level interface.  This uses a structure that
+ * has padding and hence has more room to grow, so it may be more
+ * appropriate for many new use cases.
+ *
+ * Please do not change these flags or interfaces before checking with
+ * linux-fsdevel@vger.kernel.org and linux-api@vger.kernel.org.
  */
 #define	FS_SECRM_FL			0x00000001 /* Secure deletion */
 #define	FS_UNRM_FL			0x00000002 /* Undelete */
@@ -217,8 +237,8 @@ struct fsxattr {
 #define FS_DIRTY_FL			0x00000100
 #define FS_COMPRBLK_FL			0x00000200 /* One or more compressed clusters */
 #define FS_NOCOMP_FL			0x00000400 /* Don't compress */
-#define FS_ECOMPR_FL			0x00000800 /* Compression error */
 /* End compression flags --- maybe not all used */
+#define FS_ENCRYPT_FL			0x00000800 /* Encrypted file */
 #define FS_BTREE_FL			0x00001000 /* btree format dir */
 #define FS_INDEX_FL			0x00001000 /* hash-indexed directory */
 #define FS_IMAGIC_FL			0x00002000 /* AFS directory */
@@ -226,9 +246,12 @@ struct fsxattr {
 #define FS_NOTAIL_FL			0x00008000 /* file tail should not be merged */
 #define FS_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
 #define FS_TOPDIR_FL			0x00020000 /* Top of directory hierarchies*/
+#define FS_HUGE_FILE_FL			0x00040000 /* Reserved for ext4 */
 #define FS_EXTENT_FL			0x00080000 /* Extents */
-#define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
+#define FS_EA_INODE_FL			0x00200000 /* Inode used for large EA */
+#define FS_EOFBLOCKS_FL			0x00400000 /* Reserved for ext4 */
 #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
+#define FS_INLINE_DATA_FL		0x10000000 /* Reserved for ext4 */
 #define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
 

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [v15 4/4] ext4: cleanup inode flag definitions
@ 2015-12-28 15:23     ` Theodore Ts'o
  0 siblings, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2015-12-28 15:23 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, adilger-m1MBpc4rdrD3fQ9qLvQP4Q,
	jack-AlSwsSmVLrQ, viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

On Sun, Sep 13, 2015 at 09:20:33PM +0900, Li Xi wrote:
> The inode flags defined in uapi/linux/fs.h were migrated from
> ext4.h. This patch changes the inode flag definitions in ext4.h
> to VFS definitions to make the gaps between them clearer.
> 
> Signed-off-by: Li Xi <lixi-LfVdkaOWEx8@public.gmane.org>
> Reviewed-by: Andreas Dilger <adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>

Instead of doing things this way, I've decided to clean things up by
updating the flags in uapi/linux/fs.h.  That's because some people who
might want to assign new flags might not be ext4 developers, and so
they wouldn't look at fs/ext4/ext4.h.

At the same time, we really don't want people adding new flags by
default, unless there is a really good reason.  So I've added a
comment making the history of the interface and suggesting that people
not assign new flags without thinking twice (or checking with
linux-fsdevel and linux-api).

						- Ted

commit 6ac40c7b5597646ec4335f77ab79cac9663f4a1e
Author: Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>
Date:   Mon Dec 28 10:21:43 2015 -0500

    fs: clean up the flags definition in uapi/linux/fs.h
    
    Add an explanation for the flags used by FS_IOC_[GS]ETFLAGS and remind
    people that changes should be revised by linux-fsdevel and linux-api.
    
    Add flags that are used on-disk for ext4, and remove FS_DIRECTIO_FL
    since it was used only by gfs2 and support was removed in 2008 in
    commit c9f6a6bbc28 ("The ability to mark files for direct i/o access
    when opened normally is both unused and pointless, so this patch
    removes support for that feature.")  Now we have _two_ remaining flags
    left.  But since we want to discourage people from assigning new
    flags, that's OK.
    
    Signed-off-by: Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 627f58e..35d156f 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -2,8 +2,11 @@
 #define _UAPI_LINUX_FS_H
 
 /*
- * This file has definitions for some important file table
- * structures etc.
+ * This file has definitions for some important file table structures
+ * and constants and structures used by various generic file system
+ * ioctl's.  Please do not make any changes in this file before
+ * sending patches for review to linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org and
+ * linux-api-u79uwXL29TaiAVqoAR/hOA@public.gmane.org
  */
 
 #include <linux/limits.h>
@@ -204,6 +207,23 @@ struct fsxattr {
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
+ *
+ * Note: for historical reasons, these flags were originally used and
+ * defined for use by ext2/ext3, and then other file systems started
+ * using these flags so they wouldn't need to write their own version
+ * of chattr/lsattr (which was shipped as part of e2fsprogs).  You
+ * should think twice before trying to use these flags in new
+ * contexts, or trying to assign these flags, since they are used both
+ * as the UAPI and the on-disk encoding for ext2/3/4.  Also, we are
+ * almost out of 32-bit flags.  :-)
+ *
+ * We have recently hoisted FS_IOC_FSGETXATTR / FS_IOC_FSSETXATTR from
+ * XFS to the generic FS level interface.  This uses a structure that
+ * has padding and hence has more room to grow, so it may be more
+ * appropriate for many new use cases.
+ *
+ * Please do not change these flags or interfaces before checking with
+ * linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org and linux-api-u79uwXL29TaiAVqoAR/hOA@public.gmane.org
  */
 #define	FS_SECRM_FL			0x00000001 /* Secure deletion */
 #define	FS_UNRM_FL			0x00000002 /* Undelete */
@@ -217,8 +237,8 @@ struct fsxattr {
 #define FS_DIRTY_FL			0x00000100
 #define FS_COMPRBLK_FL			0x00000200 /* One or more compressed clusters */
 #define FS_NOCOMP_FL			0x00000400 /* Don't compress */
-#define FS_ECOMPR_FL			0x00000800 /* Compression error */
 /* End compression flags --- maybe not all used */
+#define FS_ENCRYPT_FL			0x00000800 /* Encrypted file */
 #define FS_BTREE_FL			0x00001000 /* btree format dir */
 #define FS_INDEX_FL			0x00001000 /* hash-indexed directory */
 #define FS_IMAGIC_FL			0x00002000 /* AFS directory */
@@ -226,9 +246,12 @@ struct fsxattr {
 #define FS_NOTAIL_FL			0x00008000 /* file tail should not be merged */
 #define FS_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
 #define FS_TOPDIR_FL			0x00020000 /* Top of directory hierarchies*/
+#define FS_HUGE_FILE_FL			0x00040000 /* Reserved for ext4 */
 #define FS_EXTENT_FL			0x00080000 /* Extents */
-#define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
+#define FS_EA_INODE_FL			0x00200000 /* Inode used for large EA */
+#define FS_EOFBLOCKS_FL			0x00400000 /* Reserved for ext4 */
 #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
+#define FS_INLINE_DATA_FL		0x10000000 /* Reserved for ext4 */
 #define FS_PROJINHERIT_FL		0x20000000 /* Create with parents projid */
 #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
 

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
  2015-09-13 12:20 ` [v15 3/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support Li Xi
@ 2016-01-03 23:05   ` Dave Chinner
  2016-01-04  6:15       ` Theodore Ts'o
  2016-01-30  0:56       ` Pranith Kumar
  0 siblings, 2 replies; 45+ messages in thread
From: Dave Chinner @ 2016-01-03 23:05 UTC (permalink / raw)
  To: Li Xi
  Cc: linux-fsdevel, linux-ext4, linux-api, tytso, adilger, jack, viro,
	hch, dmonakhov

On Sun, Sep 13, 2015 at 09:20:32PM +0900, Li Xi wrote:
> This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
> support for ext4. The interface is kept consistent with
> XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.
> 
> Signed-off-by: Li Xi <lixi@ddn.com>
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> Reviewed-by: Jan Kara <jack@suse.cz>

We need to split this into two patches - one to move the ioctl
definition to the VFS layer, the other for all the ext4 changes to
use it.

This is the way we've done such changes in the past because
it impacts on unrelated userspace code (e.g. xfsprogs shares
libxfs/xfs_fs.h) and so these changes have to be specificallly
propagated and handled in userspace as there will be systems that
have the new xfs_fs.h but the old uapi/linux/fs.h and so xfsprogs
compilation will break. Hence the UAPI change needs to be separate
to new users of the API.

Having a separate patch also means multiple dev trees can carry the
same API change - that will solve the problem that I have
conflicting patches in XFS that add new flags to this ioctl (e.g.
for per-inode DAX and per-inode lazytime).

I've attached a patch below that is just the UAPI change. If no-one
objects, I'll commit this to the XFS tree for the upcoming merge
window....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

From: Dave Chinner <dchinner@redhat.com>

Hoist the ioctl definitions for the XFS_IOC_FS[SG]SETXATTR API from
fs/xfs/libxfs/xfs_fs.h to include/uapi/linux/fs.h so that the ioctls
can be used by all filesystems, not just XFS. This enables
(initially) ext4 to use the ioctl to set project IDs on inodes.

Based-on-patch-from: Li Xi <lixi@ddn.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_fs.h  | 51 +++++++++++++++++--------------------------------
 include/uapi/linux/fs.h | 32 +++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index b2b73a9..743d913 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -36,38 +36,23 @@ struct dioattr {
 #endif
 
 /*
- * Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR.
+ * Flags for the bs_xflags/fsx_xflags field in FS_IOC_FS[GS]ETXATTR[A]
  */
-#ifndef HAVE_FSXATTR
-struct fsxattr {
-	__u32		fsx_xflags;	/* xflags field value (get/set) */
-	__u32		fsx_extsize;	/* extsize field value (get/set)*/
-	__u32		fsx_nextents;	/* nextents field value (get)	*/
-	__u32		fsx_projid;	/* project identifier (get/set) */
-	unsigned char	fsx_pad[12];
-};
-#endif
-
-/*
- * Flags for the bs_xflags/fsx_xflags field
- * There should be a one-to-one correspondence between these flags and the
- * XFS_DIFLAG_s.
- */
-#define XFS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
-#define XFS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
-#define XFS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
-#define XFS_XFLAG_APPEND	0x00000010	/* all writes append */
-#define XFS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
-#define XFS_XFLAG_NOATIME	0x00000040	/* do not update access time */
-#define XFS_XFLAG_NODUMP	0x00000080	/* do not include in backups */
-#define XFS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
-#define XFS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
-#define XFS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
-#define XFS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
-#define XFS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
-#define XFS_XFLAG_NODEFRAG	0x00002000  	/* do not defragment */
-#define XFS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
-#define XFS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
+#define	XFS_XFLAG_REALTIME	FS_XFLAG_REALTIME
+#define	XFS_XFLAG_PREALLOC	FS_XFLAG_PREALLOC
+#define	XFS_XFLAG_IMMUTABLE	FS_XFLAG_IMMUTABLE
+#define	XFS_XFLAG_APPEND	FS_XFLAG_APPEND
+#define	XFS_XFLAG_SYNC		FS_XFLAG_SYNC
+#define	XFS_XFLAG_NOATIME	FS_XFLAG_NOATIME
+#define	XFS_XFLAG_NODUMP	FS_XFLAG_NODUMP
+#define	XFS_XFLAG_RTINHERIT	FS_XFLAG_RTINHERIT
+#define	XFS_XFLAG_PROJINHERIT	FS_XFLAG_PROJINHERIT
+#define	XFS_XFLAG_NOSYMLINKS	FS_XFLAG_NOSYMLINKS
+#define	XFS_XFLAG_EXTSIZE	FS_XFLAG_EXTSIZE
+#define	XFS_XFLAG_EXTSZINHERIT	FS_XFLAG_EXTSZINHERIT
+#define	XFS_XFLAG_NODEFRAG	FS_XFLAG_NODEFRAG
+#define	XFS_XFLAG_FILESTREAM	FS_XFLAG_FILESTREAM
+#define	XFS_XFLAG_HASATTR	FS_XFLAG_HASATTR
 
 /*
  * Structure for XFS_IOC_GETBMAP.
@@ -514,8 +499,8 @@ typedef struct xfs_swapext
 #define XFS_IOC_ALLOCSP		_IOW ('X', 10, struct xfs_flock64)
 #define XFS_IOC_FREESP		_IOW ('X', 11, struct xfs_flock64)
 #define XFS_IOC_DIOINFO		_IOR ('X', 30, struct dioattr)
-#define XFS_IOC_FSGETXATTR	_IOR ('X', 31, struct fsxattr)
-#define XFS_IOC_FSSETXATTR	_IOW ('X', 32, struct fsxattr)
+#define XFS_IOC_FSGETXATTR	FS_IOC_FSGETXATTR
+#define XFS_IOC_FSSETXATTR	FS_IOC_FSSETXATTR
 #define XFS_IOC_ALLOCSP64	_IOW ('X', 36, struct xfs_flock64)
 #define XFS_IOC_FREESP64	_IOW ('X', 37, struct xfs_flock64)
 #define XFS_IOC_GETBMAP		_IOWR('X', 38, struct getbmap)
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index f15d980..880d52e 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -110,6 +110,36 @@ struct inodes_stat_t {
 #define MS_MGC_VAL 0xC0ED0000
 #define MS_MGC_MSK 0xffff0000
 
+/*
+ * Structure for FS_IOC_FSGETXATTR[A] and FS_IOC_FSSETXATTR.
+ */
+struct fsxattr {
+	__u32		fsx_xflags;	/* xflags field value (get/set) */
+	__u32		fsx_extsize;	/* extsize field value (get/set)*/
+	__u32		fsx_nextents;	/* nextents field value (get)	*/
+	__u32		fsx_projid;	/* project identifier (get/set) */
+	unsigned char	fsx_pad[12];
+};
+
+/*
+ * Flags for the fsx_xflags field
+ */
+#define	FS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
+#define	FS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
+#define	FS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
+#define	FS_XFLAG_APPEND		0x00000010	/* all writes append */
+#define	FS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
+#define	FS_XFLAG_NOATIME	0x00000040	/* do not update access time */
+#define	FS_XFLAG_NODUMP		0x00000080	/* do not include in backups */
+#define	FS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
+#define	FS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
+#define	FS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
+#define	FS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
+#define	FS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
+#define	FS_XFLAG_NODEFRAG	0x00002000	/* do not defragment */
+#define	FS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
+#define	FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
+
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
 
@@ -169,6 +199,8 @@ struct inodes_stat_t {
 #define FS_IOC32_SETFLAGS		_IOW('f', 2, int)
 #define FS_IOC32_GETVERSION		_IOR('v', 1, int)
 #define FS_IOC32_SETVERSION		_IOW('v', 2, int)
+#define FS_IOC_FSGETXATTR		_IOR ('X', 31, struct fsxattr)
+#define FS_IOC_FSSETXATTR		_IOW ('X', 32, struct fsxattr)
 
 /*
  * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
  2016-01-03 23:05   ` [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion Dave Chinner
@ 2016-01-04  6:15       ` Theodore Ts'o
  2016-01-30  0:56       ` Pranith Kumar
  1 sibling, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2016-01-04  6:15 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Li Xi, linux-fsdevel, linux-ext4, linux-api, adilger, jack, viro,
	hch, dmonakhov

On Mon, Jan 04, 2016 at 10:05:34AM +1100, Dave Chinner wrote:
> I've attached a patch below that is just the UAPI change. If no-one
> objects, I'll commit this to the XFS tree for the upcoming merge
> window....

No objections.  Thanks!!

					- Ted

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
@ 2016-01-04  6:15       ` Theodore Ts'o
  0 siblings, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2016-01-04  6:15 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Li Xi, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, adilger-m1MBpc4rdrD3fQ9qLvQP4Q,
	jack-AlSwsSmVLrQ, viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

On Mon, Jan 04, 2016 at 10:05:34AM +1100, Dave Chinner wrote:
> I've attached a patch below that is just the UAPI change. If no-one
> objects, I'll commit this to the XFS tree for the upcoming merge
> window....

No objections.  Thanks!!

					- Ted

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
  2016-01-03 23:05   ` [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion Dave Chinner
@ 2016-01-30  0:56       ` Pranith Kumar
  2016-01-30  0:56       ` Pranith Kumar
  1 sibling, 0 replies; 45+ messages in thread
From: Pranith Kumar @ 2016-01-30  0:56 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Li Xi, open list:OVERLAYFS FILESYSTEM, linux-ext4,
	open list:KERNEL SELFTEST F...,
	Theodore Ts'o, adilger, Jan Kara, Al Viro, hch, dmonakhov

On Sun, Jan 3, 2016 at 6:05 PM, Dave Chinner <david@fromorbit.com> wrote:
> On Sun, Sep 13, 2015 at 09:20:32PM +0900, Li Xi wrote:
>> This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
>> support for ext4. The interface is kept consistent with
>> XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.
>>
>> Signed-off-by: Li Xi <lixi@ddn.com>
>> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
>> Reviewed-by: Jan Kara <jack@suse.cz>
>

Hello,

This commit breaks building latest qemu as follows:

In file included from /usr/include/xfs/xfs.h:58:0,
                 from /home/pranith/qemu/block/raw-posix.c:96:
/usr/include/xfs/xfs_fs.h:42:8: error: redefinition of ‘struct fsxattr’
 struct fsxattr {
        ^
In file included from /home/pranith/qemu/block/raw-posix.c:59:0:
/usr/include/linux/fs.h:155:8: note: originally defined here
 struct fsxattr {
        ^
/home/pranith/qemu/rules.mak:57: recipe for target 'block/raw-posix.o' failed

I think this is caused by moving the fsxattr struct around. Is the
header inclusion messed up somehow?

Thanks,

-- 
Pranith

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
@ 2016-01-30  0:56       ` Pranith Kumar
  0 siblings, 0 replies; 45+ messages in thread
From: Pranith Kumar @ 2016-01-30  0:56 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Li Xi, open list:OVERLAYFS FILESYSTEM, linux-ext4,
	open list:KERNEL SELFTEST F...,
	Theodore Ts'o, adilger, Jan Kara, Al Viro, hch, dmonakhov

On Sun, Jan 3, 2016 at 6:05 PM, Dave Chinner <david@fromorbit.com> wrote:
> On Sun, Sep 13, 2015 at 09:20:32PM +0900, Li Xi wrote:
>> This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
>> support for ext4. The interface is kept consistent with
>> XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.
>>
>> Signed-off-by: Li Xi <lixi@ddn.com>
>> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
>> Reviewed-by: Jan Kara <jack@suse.cz>
>

Hello,

This commit breaks building latest qemu as follows:

In file included from /usr/include/xfs/xfs.h:58:0,
                 from /home/pranith/qemu/block/raw-posix.c:96:
/usr/include/xfs/xfs_fs.h:42:8: error: redefinition of ‘struct fsxattr’
 struct fsxattr {
        ^
In file included from /home/pranith/qemu/block/raw-posix.c:59:0:
/usr/include/linux/fs.h:155:8: note: originally defined here
 struct fsxattr {
        ^
/home/pranith/qemu/rules.mak:57: recipe for target 'block/raw-posix.o' failed

I think this is caused by moving the fsxattr struct around. Is the
header inclusion messed up somehow?

Thanks,

-- 
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
@ 2016-01-30  4:41         ` Theodore Ts'o
  0 siblings, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2016-01-30  4:41 UTC (permalink / raw)
  To: Pranith Kumar
  Cc: Dave Chinner, Li Xi, open list:OVERLAYFS FILESYSTEM, linux-ext4,
	open list:KERNEL SELFTEST F...,
	adilger, Jan Kara, Al Viro, hch, dmonakhov

On Fri, Jan 29, 2016 at 07:56:44PM -0500, Pranith Kumar wrote:
> 
> This commit breaks building latest qemu as follows:

Well, this commit moves where the fsxattr struct is around, but the
header files that gcc is complaining about here:

> In file included from /usr/include/xfs/xfs.h:58:0,
>                  from /home/pranith/qemu/block/raw-posix.c:96:
> /usr/include/xfs/xfs_fs.h:42:8: error: redefinition of ‘struct fsxattr’
>  struct fsxattr {
>         ^
> In file included from /home/pranith/qemu/block/raw-posix.c:59:0:
> /usr/include/linux/fs.h:155:8: note: originally defined here
>  struct fsxattr {
>         ^
> /home/pranith/qemu/rules.mak:57: recipe for target 'block/raw-posix.o' failed

are userspace header files in /usr/include, and so the problem isn't
in the kernel, but how the userspace header files have been set up.

You didn't say what distribution you are using, but I suspect what's
going on is that you are getting /usr/include/xfs/xfs_fs.h from the
xfsprogs package, while the /usr/include/linux/fs.h is getting derived
from the include/uapi/linux/fs.h file from the kernel header files.

So the issue is that these two header files are out of sync.  It's
because of issues like this that I'm not a fan of updating the kernel
header files whenever I install a newer kernel version.

So on my Debain system, I don't update linux-libc-dev when I install a
new upstream kernel built using "make deb-pkg".  I'll still a new
version of the linux-image-*.deb file, and maybe a newer version of
linux-firmware-*.dev, but I don't bother installing the
linux-headers-*.deb file (since I don't compile external kernel
modules), and I don't bother installing linux-libc-dev-*.deb (because
of situations like this, where the userspace include files need ot be
updated in sync, and this should be the distribution's problem to
handle).

Cheers,

						- Ted

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
@ 2016-01-30  4:41         ` Theodore Ts'o
  0 siblings, 0 replies; 45+ messages in thread
From: Theodore Ts'o @ 2016-01-30  4:41 UTC (permalink / raw)
  To: Pranith Kumar
  Cc: Dave Chinner, Li Xi, open list:OVERLAYFS FILESYSTEM,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA, open list:KERNEL SELFTEST F...,
	adilger-m1MBpc4rdrD3fQ9qLvQP4Q, Jan Kara, Al Viro,
	hch-wEGCiKHe2LqWVfeAwA7xHQ, dmonakhov-GEFAQzZX7r8dnm+yROfE0A

On Fri, Jan 29, 2016 at 07:56:44PM -0500, Pranith Kumar wrote:
> 
> This commit breaks building latest qemu as follows:

Well, this commit moves where the fsxattr struct is around, but the
header files that gcc is complaining about here:

> In file included from /usr/include/xfs/xfs.h:58:0,
>                  from /home/pranith/qemu/block/raw-posix.c:96:
> /usr/include/xfs/xfs_fs.h:42:8: error: redefinition of ‘struct fsxattr’
>  struct fsxattr {
>         ^
> In file included from /home/pranith/qemu/block/raw-posix.c:59:0:
> /usr/include/linux/fs.h:155:8: note: originally defined here
>  struct fsxattr {
>         ^
> /home/pranith/qemu/rules.mak:57: recipe for target 'block/raw-posix.o' failed

are userspace header files in /usr/include, and so the problem isn't
in the kernel, but how the userspace header files have been set up.

You didn't say what distribution you are using, but I suspect what's
going on is that you are getting /usr/include/xfs/xfs_fs.h from the
xfsprogs package, while the /usr/include/linux/fs.h is getting derived
from the include/uapi/linux/fs.h file from the kernel header files.

So the issue is that these two header files are out of sync.  It's
because of issues like this that I'm not a fan of updating the kernel
header files whenever I install a newer kernel version.

So on my Debain system, I don't update linux-libc-dev when I install a
new upstream kernel built using "make deb-pkg".  I'll still a new
version of the linux-image-*.deb file, and maybe a newer version of
linux-firmware-*.dev, but I don't bother installing the
linux-headers-*.deb file (since I don't compile external kernel
modules), and I don't bother installing linux-libc-dev-*.deb (because
of situations like this, where the userspace include files need ot be
updated in sync, and this should be the distribution's problem to
handle).

Cheers,

						- Ted

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
  2016-01-30  4:41         ` Theodore Ts'o
  (?)
@ 2016-01-30  4:49         ` Pranith Kumar
  2016-01-31 22:36           ` Dave Chinner
  -1 siblings, 1 reply; 45+ messages in thread
From: Pranith Kumar @ 2016-01-30  4:49 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Dave Chinner, Li Xi, open list:OVERLAYFS FILESYSTEM, linux-ext4,
	open list:KERNEL SELFTEST F...,
	adilger, Jan Kara, Al Viro, hch, dmonakhov

On Fri, Jan 29, 2016 at 11:41 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> So on my Debain system, I don't update linux-libc-dev when I install a
> new upstream kernel built using "make deb-pkg".  I'll still a new
> version of the linux-image-*.deb file, and maybe a newer version of
> linux-firmware-*.dev, but I don't bother installing the
> linux-headers-*.deb file (since I don't compile external kernel
> modules), and I don't bother installing linux-libc-dev-*.deb (because
> of situations like this, where the userspace include files need ot be
> updated in sync, and this should be the distribution's problem to
> handle).

I am using a debian system and built the kernel using
"make bindeb-pkg". This generated the following debs:

linux-firmware-image-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
linux-image-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
linux-headers-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
linux-libc-dev_4.5.0-rc1+-2_powerpc.deb

which I installed as I usually do to test new system calls or run other tests.

I'll try to update the uapi header files manually and see how it goes...

Thanks!
-- 
Pranith

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion
  2016-01-30  4:49         ` Pranith Kumar
@ 2016-01-31 22:36           ` Dave Chinner
  0 siblings, 0 replies; 45+ messages in thread
From: Dave Chinner @ 2016-01-31 22:36 UTC (permalink / raw)
  To: Pranith Kumar
  Cc: Theodore Ts'o, Li Xi, open list:OVERLAYFS FILESYSTEM,
	linux-ext4, open list:KERNEL SELFTEST F...,
	adilger, Jan Kara, Al Viro, hch, dmonakhov

On Fri, Jan 29, 2016 at 11:49:29PM -0500, Pranith Kumar wrote:
> On Fri, Jan 29, 2016 at 11:41 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> > So on my Debain system, I don't update linux-libc-dev when I install a
> > new upstream kernel built using "make deb-pkg".  I'll still a new
> > version of the linux-image-*.deb file, and maybe a newer version of
> > linux-firmware-*.dev, but I don't bother installing the
> > linux-headers-*.deb file (since I don't compile external kernel
> > modules), and I don't bother installing linux-libc-dev-*.deb (because
> > of situations like this, where the userspace include files need ot be
> > updated in sync, and this should be the distribution's problem to
> > handle).
> 
> I am using a debian system and built the kernel using
> "make bindeb-pkg". This generated the following debs:
> 
> linux-firmware-image-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
> linux-image-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
> linux-headers-4.5.0-rc1+_4.5.0-rc1+-2_powerpc.deb
> linux-libc-dev_4.5.0-rc1+-2_powerpc.deb
> 
> which I installed as I usually do to test new system calls or run other tests.
> 
> I'll try to update the uapi header files manually and see how it goes...

You need to update qemu's autoconf to define HAVE_FSXATTR if it's
found in the uapi/linux/fs.h so that it then isn't defined in
xfs/xfs_fs.h.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2016-01-31 22:36 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-13 12:20 [v15 0/4] ext4: add project quota support Li Xi
     [not found] ` <1442146833-13652-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2015-09-13 12:20   ` [v15 1/4] ext4: adds project ID support Li Xi
     [not found]     ` <1442146833-13652-2-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2015-09-23 12:34       ` Dmitry Monakhov
2015-09-23 18:17         ` Jan Kara
2015-09-13 12:20   ` [v15 2/4] ext4: adds project quota support Li Xi
2015-09-24 17:12   ` [v15 0/4] ext4: add " Andreas Dilger
2015-11-05 14:45     ` Li Xi
2015-11-05 15:13       ` Shuichi Ihara
     [not found]         ` <7360A48E-8576-49DB-878B-DFC2EFC83BC4-LfVdkaOWEx8@public.gmane.org>
2015-11-08 21:28           ` Dave Chinner
2015-11-18 14:14             ` Shuichi Ihara
2015-11-19 21:47               ` Dave Chinner
2015-11-23  1:45                 ` Andreas Dilger
2015-11-23  1:45                   ` Andreas Dilger
2015-11-23  2:50                   ` Dave Chinner
2015-11-23  2:50                     ` Dave Chinner
2015-11-23  9:25                 ` Jan Kara
2015-11-23  9:25                   ` Jan Kara
2015-11-23 20:15                   ` Dave Chinner
2015-11-23 20:15                     ` Dave Chinner
2015-11-24  9:07                     ` Jan Kara
2015-11-24  9:07                       ` Jan Kara
2015-09-13 12:20 ` [v15 3/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support Li Xi
2016-01-03 23:05   ` [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion Dave Chinner
2016-01-04  6:15     ` Theodore Ts'o
2016-01-04  6:15       ` Theodore Ts'o
2016-01-30  0:56     ` Pranith Kumar
2016-01-30  0:56       ` Pranith Kumar
2016-01-30  4:41       ` Theodore Ts'o
2016-01-30  4:41         ` Theodore Ts'o
2016-01-30  4:49         ` Pranith Kumar
2016-01-31 22:36           ` Dave Chinner
2015-09-13 12:20 ` [v15 4/4] ext4: cleanup inode flag definitions Li Xi
2015-12-28 15:23   ` Theodore Ts'o
2015-12-28 15:23     ` Theodore Ts'o
2015-09-23 12:31 ` [v15 0/4] ext4: add project quota support Jan Kara
     [not found]   ` <20150923123119.GA13946-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
2015-09-23 13:17     ` Li Xi
     [not found]       ` <CAPTn0cBB7h89R7NB+zg+J+TVvKXut_Usixs==S=AWs-v7kZExg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-23 13:32         ` Dmitry Monakhov
2015-09-23 13:32           ` Dmitry Monakhov
2015-09-23 13:57           ` Li Xi
     [not found]             ` <CAPTn0cC=1xWCcUMVqhAx4pvqqX9rXC8p6B4Jt7cpm4HfuaFOMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-23 13:58               ` Li Xi
2015-09-23 14:13               ` Dmitry Monakhov
2015-09-23 14:13                 ` Dmitry Monakhov
2015-09-24 12:09             ` Jan Kara
2015-10-18  1:01 ` Theodore Ts'o
2015-10-18  2:25   ` Li Xi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.