2015-09-13 12:20:29

by Li Xi

[permalink] [raw]
Subject: [v15 0/4] ext4: add project quota support

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(-)


2015-09-13 12:20:32

by Li Xi

[permalink] [raw]
Subject: [v15 3/4] ext4: adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support

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 <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
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


2015-09-13 12:20:33

by Li Xi

[permalink] [raw]
Subject: [v15 4/4] ext4: cleanup inode flag definitions

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 <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
---
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


2015-09-23 12:31:19

by Jan Kara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]>
SUSE Labs, CR

2015-09-23 13:17:55

by Li Xi

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]> 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/[email protected]>
> SUSE Labs, CR

2015-09-23 13:32:22

by Dmitry Monakhov

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

Li Xi <[email protected]> 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 <[email protected]> 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/[email protected]>
>> SUSE Labs, CR


Attachments:
signature.asc (472.00 B)

2015-09-23 13:57:06

by Li Xi

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]> wrote:
> Li Xi <[email protected]> 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 <[email protected]> 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 <[email protected]>
>>> SUSE Labs, CR

2015-09-23 13:58:27

by Li Xi

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]> 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 <[email protected]> wrote:
>> Li Xi <[email protected]> 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 <[email protected]> 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/[email protected]>
>>>> SUSE Labs, CR

2015-09-23 14:13:39

by Dmitry Monakhov

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

Li Xi <[email protected]> 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 <[email protected]> wrote:
>> Li Xi <[email protected]> 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 <[email protected]> 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/[email protected]>
>>>> SUSE Labs, CR


Attachments:
signature.asc (472.00 B)

2015-09-24 12:09:16

by Jan Kara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]> wrote:
> > Li Xi <[email protected]> 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 <[email protected]> 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 <[email protected]>
> >>> SUSE Labs, CR
--
Jan Kara <[email protected]>
SUSE Labs, CR

2015-09-24 17:12:11

by Andreas Dilger

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

On Sep 13, 2015, at 2:20 PM, Li Xi <[email protected]> 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

2015-10-18 01:01:43

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]>
Date: Sat Oct 17 16:15:18 2015 -0400

ext4: reserve code points for the project quota feature

Signed-off-by: Theodore Ts'o <[email protected]>

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 */

2015-10-18 02:25:34

by Li Xi

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 <[email protected]> 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 <[email protected]>
> Date: Sat Oct 17 16:15:18 2015 -0400
>
> ext4: reserve code points for the project quota feature
>
> Signed-off-by: Theodore Ts'o <[email protected]>
>
> 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 */

2015-11-05 14:45:12

by Li Xi

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

On Fri, Sep 25, 2015 at 1:12 AM, Andreas Dilger <[email protected]> wrote:
> On Sep 13, 2015, at 2:20 PM, Li Xi <[email protected]> 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

2015-11-05 15:13:10

by Shuichi Ihara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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 , "[email protected] (Li Xi の代理)" <[email protected] ([email protected] の代理)> wrote:

>On Fri, Sep 25, 2015 at 1:12 AM, Andreas Dilger <[email protected]> wrote:
>> On Sep 13, 2015, at 2:20 PM, Li Xi <[email protected]> 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 [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html

2015-11-08 21:28:30

by Dave Chinner

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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
[email protected]

2015-11-18 14:14:32

by Shuichi Ihara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support


11/9/15, 6:28 AM , "Dave Chinner" <[email protected]> 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

2015-11-19 21:47:27

by Dave Chinner

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
>
> 11/9/15, 6:28 AM , "Dave Chinner" <[email protected]> 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
[email protected]

2015-11-23 01:45:24

by Andreas Dilger

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

On Nov 19, 2015, at 2:47 PM, Dave Chinner <[email protected]> wrote:
>
> On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
>>
>> 11/9/15, 6:28 AM , "Dave Chinner" <[email protected]> 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






Attachments:
signature.asc (833.00 B)
Message signed with OpenPGP using GPGMail

2015-11-23 02:50:14

by Dave Chinner

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

On Sun, Nov 22, 2015 at 06:45:24PM -0700, Andreas Dilger wrote:
> On Nov 19, 2015, at 2:47 PM, Dave Chinner <[email protected]> wrote:
> >
> > On Wed, Nov 18, 2015 at 02:14:32PM +0000, Shuichi Ihara wrote:
> >>
> >> 11/9/15, 6:28 AM , "Dave Chinner" <[email protected]> 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
[email protected]

2015-11-23 09:25:23

by Jan Kara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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" <[email protected]> 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/[email protected]>
SUSE Labs, CR

2015-11-23 20:15:23

by Dave Chinner

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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" <[email protected]> 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
[email protected]

2015-11-24 09:07:43

by Jan Kara

[permalink] [raw]
Subject: Re: [v15 0/4] ext4: add project quota support

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" <[email protected]> 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/[email protected]>
SUSE Labs, CR

2015-12-28 15:23:34

by Theodore Y. Ts'o

[permalink] [raw]
Subject: Re: [v15 4/4] ext4: cleanup inode flag definitions

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 <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>

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 <[email protected]>
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 <[email protected]>

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 [email protected] and
+ * linux-api-u79uwXL29TaiAVqoAR/[email protected]
*/

#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
+ * [email protected] and linux-api-u79uwXL29TaiAVqoAR/[email protected]
*/
#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 */


2016-01-03 23:06:35

by Dave Chinner

[permalink] [raw]
Subject: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

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 <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>
> Reviewed-by: Jan Kara <[email protected]>

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
[email protected]

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

From: Dave Chinner <[email protected]>

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 <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
---
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)

2016-01-04 06:15:23

by Theodore Y. Ts'o

[permalink] [raw]
Subject: Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

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

2016-01-30 00:56:44

by Pranith Kumar

[permalink] [raw]
Subject: Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

On Sun, Jan 3, 2016 at 6:05 PM, Dave Chinner <[email protected]> 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 <[email protected]>
>> Reviewed-by: Andreas Dilger <[email protected]>
>> Reviewed-by: Jan Kara <[email protected]>
>

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

2016-01-30 04:41:51

by Theodore Y. Ts'o

[permalink] [raw]
Subject: Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

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

2016-01-30 04:49:59

by Pranith Kumar

[permalink] [raw]
Subject: Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

On Fri, Jan 29, 2016 at 11:41 PM, Theodore Ts'o <[email protected]> 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

2016-01-31 22:36:23

by Dave Chinner

[permalink] [raw]
Subject: Re: [PATCH] fs: XFS_IOC_FS[SG]SETXATTR to FS_IOC_FS[SG]ETXATTR promotion

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 <[email protected]> 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
[email protected]