- __u8 h_i_frag; /* Fragment number */
-@@ -320,6 +325,7 @@ struct ext3_inode {
- #define i_gid_low i_gid
- #define i_uid_high osd2.linux2.l_i_uid_high
- #define i_gid_high osd2.linux2.l_i_gid_high
-+#define i_raw_tag osd2.linux2.l_i_tag
- #define i_reserved2 osd2.linux2.l_i_reserved2
-
- /*
-@@ -364,6 +370,7 @@ struct ext3_inode {
- #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
- #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
- * error in ordered mode */
-+#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
-
- /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
- #ifndef _LINUX_EXT2_FS_H
-@@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
- extern void ext3_set_aops(struct inode *inode);
- extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
- u64 start, u64 len);
-+extern int ext3_sync_flags(struct inode *, int, int);
-
- /* ioctl.c */
- extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
-diff -NurpP --minimal linux-3.6.6/fs/ext3/file.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/file.c
---- linux-3.6.6/fs/ext3/file.c 2012-05-21 18:07:20.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/file.c 2012-10-04 18:47:00.000000000 +0200
-@@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
- #endif
- .get_acl = ext3_get_acl,
- .fiemap = ext3_fiemap,
-+ .sync_flags = ext3_sync_flags,
- };
-
-diff -NurpP --minimal linux-3.6.6/fs/ext3/ialloc.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/ialloc.c
---- linux-3.6.6/fs/ext3/ialloc.c 2012-07-22 23:39:39.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/ialloc.c 2012-10-04 18:47:00.000000000 +0200
-@@ -14,6 +14,7 @@
-
- #include <linux/quotaops.h>
- #include <linux/random.h>
-+#include <linux/vs_tag.h>
-
- #include "ext3.h"
- #include "xattr.h"
-@@ -469,6 +470,7 @@ got:
- inode->i_mode = mode;
- inode->i_uid = current_fsuid();
- inode->i_gid = dir->i_gid;
-+ inode->i_tag = dx_current_fstag(sb);
- } else
- inode_init_owner(inode, dir, mode);
-
-diff -NurpP --minimal linux-3.6.6/fs/ext3/inode.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/inode.c
---- linux-3.6.6/fs/ext3/inode.c 2012-10-04 15:27:39.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/inode.c 2012-10-04 18:47:00.000000000 +0200
-@@ -27,6 +27,8 @@
- #include <linux/writeback.h>
- #include <linux/mpage.h>
- #include <linux/namei.h>
-+#include <linux/vs_tag.h>
-+
- #include "ext3.h"
- #include "xattr.h"
- #include "acl.h"
-@@ -2848,36 +2850,60 @@ void ext3_set_inode_flags(struct inode *
- {
- unsigned int flags = EXT3_I(inode)->i_flags;
-
-- inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
-+ inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
-+ S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
-+
-+ if (flags & EXT3_IMMUTABLE_FL)
-+ inode->i_flags |= S_IMMUTABLE;
-+ if (flags & EXT3_IXUNLINK_FL)
-+ inode->i_flags |= S_IXUNLINK;
-+
- if (flags & EXT3_SYNC_FL)
- inode->i_flags |= S_SYNC;
- if (flags & EXT3_APPEND_FL)
- inode->i_flags |= S_APPEND;
-- if (flags & EXT3_IMMUTABLE_FL)
-- inode->i_flags |= S_IMMUTABLE;
- if (flags & EXT3_NOATIME_FL)
- inode->i_flags |= S_NOATIME;
- if (flags & EXT3_DIRSYNC_FL)
- inode->i_flags |= S_DIRSYNC;
-+
-+ inode->i_vflags &= ~(V_BARRIER | V_COW);
-+
-+ if (flags & EXT3_BARRIER_FL)
-+ inode->i_vflags |= V_BARRIER;
-+ if (flags & EXT3_COW_FL)
-+ inode->i_vflags |= V_COW;
- }
-
- /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
- void ext3_get_inode_flags(struct ext3_inode_info *ei)
- {
- unsigned int flags = ei->vfs_inode.i_flags;
-+ unsigned int vflags = ei->vfs_inode.i_vflags;
-+
-+ ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
-+ EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
-+ EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
-+ EXT3_BARRIER_FL | EXT3_COW_FL);
-+
-+ if (flags & S_IMMUTABLE)
-+ ei->i_flags |= EXT3_IMMUTABLE_FL;
-+ if (flags & S_IXUNLINK)
-+ ei->i_flags |= EXT3_IXUNLINK_FL;
-
-- ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
-- EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
- if (flags & S_SYNC)
- ei->i_flags |= EXT3_SYNC_FL;
- if (flags & S_APPEND)
- ei->i_flags |= EXT3_APPEND_FL;
-- if (flags & S_IMMUTABLE)
-- ei->i_flags |= EXT3_IMMUTABLE_FL;
- if (flags & S_NOATIME)
- ei->i_flags |= EXT3_NOATIME_FL;
- if (flags & S_DIRSYNC)
- ei->i_flags |= EXT3_DIRSYNC_FL;
-+
-+ if (vflags & V_BARRIER)
-+ ei->i_flags |= EXT3_BARRIER_FL;
-+ if (vflags & V_COW)
-+ ei->i_flags |= EXT3_COW_FL;
- }
-
- struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
-@@ -2915,8 +2941,10 @@ struct inode *ext3_iget(struct super_blo
- i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
- i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
- }
-- i_uid_write(inode, i_uid);
-- i_gid_write(inode, i_gid);
-+ i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
-+ i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
-+ inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
-+ le16_to_cpu(raw_inode->i_raw_tag));
- set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
- inode->i_size = le32_to_cpu(raw_inode->i_size);
- inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
-@@ -3088,8 +3116,8 @@ again:
-
- ext3_get_inode_flags(ei);
- raw_inode->i_mode = cpu_to_le16(inode->i_mode);
-- i_uid = i_uid_read(inode);
-- i_gid = i_gid_read(inode);
-+ i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
-+ i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
- if(!(test_opt(inode->i_sb, NO_UID32))) {
- raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
- raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
-@@ -3114,6 +3142,9 @@ again:
- raw_inode->i_uid_high = 0;
- raw_inode->i_gid_high = 0;
- }
-+#ifdef CONFIG_TAGGING_INTERN
-+ raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
-+#endif
- raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
- disksize = cpu_to_le32(ei->i_disksize);
- if (disksize != raw_inode->i_size) {
-@@ -3282,7 +3313,8 @@ int ext3_setattr(struct dentry *dentry,
- if (is_quota_modification(inode, attr))
- dquot_initialize(inode);
- if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
-- (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
-+ (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
-+ (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
- handle_t *handle;
-
- /* (user+group)*(old+new) structure, inode write (sb,
-@@ -3304,6 +3336,8 @@ int ext3_setattr(struct dentry *dentry,
- inode->i_uid = attr->ia_uid;
- if (attr->ia_valid & ATTR_GID)
- inode->i_gid = attr->ia_gid;
-+ if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
-+ inode->i_tag = attr->ia_tag;
- error = ext3_mark_inode_dirty(handle, inode);
- ext3_journal_stop(handle);
- }
-diff -NurpP --minimal linux-3.6.6/fs/ext3/ioctl.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/ioctl.c
---- linux-3.6.6/fs/ext3/ioctl.c 2012-05-21 18:07:20.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/ioctl.c 2012-10-04 18:47:00.000000000 +0200
-@@ -12,6 +12,34 @@
- #include <asm/uaccess.h>
- #include "ext3.h"
-
-+
-+int ext3_sync_flags(struct inode *inode, int flags, int vflags)
-+{
-+ handle_t *handle = NULL;
-+ struct ext3_iloc iloc;
-+ int err;
-+
-+ handle = ext3_journal_start(inode, 1);
-+ if (IS_ERR(handle))
-+ return PTR_ERR(handle);
-+
-+ if (IS_SYNC(inode))
-+ handle->h_sync = 1;
-+ err = ext3_reserve_inode_write(handle, inode, &iloc);
-+ if (err)
-+ goto flags_err;
-+
-+ inode->i_flags = flags;
-+ inode->i_vflags = vflags;
-+ ext3_get_inode_flags(EXT3_I(inode));
-+ inode->i_ctime = CURRENT_TIME_SEC;
-+
-+ err = ext3_mark_iloc_dirty(handle, inode, &iloc);
-+flags_err:
-+ ext3_journal_stop(handle);
-+ return err;
-+}
-+
- long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
- {
- struct inode *inode = filp->f_dentry->d_inode;
-@@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
-
- flags = ext3_mask_flags(inode->i_mode, flags);
-
-+ if (IS_BARRIER(inode)) {
-+ vxwprintk_task(1, "messing with the barrier.");
-+ return -EACCES;
-+ }
-+
- mutex_lock(&inode->i_mutex);
-
- /* Is it quota file? Do not allow user to mess with it */
-@@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
- *
- * This test looks nicer. Thanks to Pauline Middelink
- */
-- if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
-+ if ((oldflags & EXT3_IMMUTABLE_FL) ||
-+ ((flags ^ oldflags) & (EXT3_APPEND_FL |
-+ EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
- if (!capable(CAP_LINUX_IMMUTABLE))
- goto flags_out;
- }
-@@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
- if (err)
- goto flags_err;
-
-- flags = flags & EXT3_FL_USER_MODIFIABLE;
-+ flags &= EXT3_FL_USER_MODIFIABLE;
- flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
- ei->i_flags = flags;
-
-diff -NurpP --minimal linux-3.6.6/fs/ext3/namei.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/namei.c
---- linux-3.6.6/fs/ext3/namei.c 2012-10-04 15:27:39.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/namei.c 2012-10-04 18:47:00.000000000 +0200
-@@ -25,6 +25,8 @@
- */
-
- #include <linux/quotaops.h>
-+#include <linux/vs_tag.h>
-+
- #include "ext3.h"
- #include "namei.h"
- #include "xattr.h"
-@@ -915,6 +917,7 @@ restart:
- submit_bh(READ | REQ_META | REQ_PRIO,
- bh);
- }
-+ dx_propagate_tag(nd, inode);
- }
- }
- if ((bh = bh_use[ra_ptr++]) == NULL)
-@@ -2526,6 +2529,7 @@ const struct inode_operations ext3_dir_i
- .listxattr = ext3_listxattr,
- .removexattr = generic_removexattr,
- #endif
-+ .sync_flags = ext3_sync_flags,
- .get_acl = ext3_get_acl,
- };
-
-diff -NurpP --minimal linux-3.6.6/fs/ext3/super.c linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/super.c
---- linux-3.6.6/fs/ext3/super.c 2012-10-04 15:27:39.000000000 +0200
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext3/super.c 2012-10-04 18:47:00.000000000 +0200
-@@ -811,7 +811,8 @@ enum {
- Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
- Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
- Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
-- Opt_resize, Opt_usrquota, Opt_grpquota
-+ Opt_resize, Opt_usrquota, Opt_grpquota,
-+ Opt_tag, Opt_notag, Opt_tagid
- };
-
- static const match_table_t tokens = {
-@@ -868,6 +869,9 @@ static const match_table_t tokens = {
- {Opt_barrier, "barrier"},
- {Opt_nobarrier, "nobarrier"},
- {Opt_resize, "resize"},
-+ {Opt_tag, "tag"},
-+ {Opt_notag, "notag"},
-+ {Opt_tagid, "tagid=%u"},
- {Opt_err, NULL},
- };
-
-@@ -1033,6 +1037,20 @@ static int parse_options (char *options,
- case Opt_nouid32:
- set_opt (sbi->s_mount_opt, NO_UID32);
- break;
-+#ifndef CONFIG_TAGGING_NONE
-+ case Opt_tag:
-+ set_opt (sbi->s_mount_opt, TAGGED);
-+ break;
-+ case Opt_notag:
-+ clear_opt (sbi->s_mount_opt, TAGGED);
-+ break;
-+#endif
-+#ifdef CONFIG_PROPAGATE
-+ case Opt_tagid:
-+ /* use args[0] */
-+ set_opt (sbi->s_mount_opt, TAGGED);
-+ break;
-+#endif
- case Opt_nocheck:
- clear_opt (sbi->s_mount_opt, CHECK);
- break;
-@@ -1731,6 +1749,9 @@ static int ext3_fill_super (struct super
- NULL, 0))
- goto failed_mount;
-
-+ if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
-+ sb->s_flags |= MS_TAGGED;
-+
- sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
- (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
-
-@@ -2618,6 +2639,14 @@ static int ext3_remount (struct super_bl
- if (test_opt(sb, ABORT))
- ext3_abort(sb, __func__, "Abort forced by user");
-
-+ if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
-+ !(sb->s_flags & MS_TAGGED)) {
-+ printk("EXT3-fs: %s: tagging not permitted on remount.\n",
-+ sb->s_id);
-+ err = -EINVAL;
-+ goto restore_opts;
-+ }
-+
- sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
- (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
-
-diff -NurpP --minimal linux-3.6.6/fs/ext4/ext4.h linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext4/ext4.h
---- linux-3.6.6/fs/ext4/ext4.h 2012-11-06 18:42:12.000000000 +0100
-+++ linux-3.6.6-vs2.3.4.3.1-noxfs-nocow/fs/ext4/ext4.h 2012-11-06 18:43:41.000000000 +0100
-@@ -393,8 +393,12 @@ struct flex_groups {
- #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_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
- #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
-
-+#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
-+#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
-+
- #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
- #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
-
-@@ -666,7 +670,7 @@ struct ext4_inode {
- __le16 l_i_uid_high; /* these 2 fields */
- __le16 l_i_gid_high; /* were reserved2[0] */
- __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
-- __le16 l_i_reserved;
-+ __le16 l_i_tag; /* Context Tag */
- } linux2;
- struct {
- __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
-@@ -784,6 +788,7 @@ do { \