diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_iops.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_iops.c	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_iops.c	2005-07-07 03:51:24 +0200
@@ -510,6 +510,10 @@ linvfs_setattr(
 		vattr.va_mask |= XFS_AT_GID;
 		vattr.va_gid = attr->ia_gid;
 	}
+	if (ia_valid & ATTR_XID) {
+		vattr.va_mask |= XFS_AT_XID;
+		vattr.va_xid = attr->ia_xid;
+	}
 	if (ia_valid & ATTR_SIZE) {
 		vattr.va_mask |= XFS_AT_SIZE;
 		vattr.va_size = attr->ia_size;
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_linux.h
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_linux.h	2005-06-22 02:38:40 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_linux.h	2005-07-07 02:43:05 +0200
@@ -152,6 +152,7 @@ static inline void set_buffer_unwritten_
 #define current_pid()		(current->pid)
 #define current_fsuid(cred)	(current->fsuid)
 #define current_fsgid(cred)	(current->fsgid)
+#define current_fsxid(cred)	(current->xid)
 
 #define NBPP		PAGE_SIZE
 #define DPPSHFT		(PAGE_SHIFT - 9)
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_super.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_super.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_super.c	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_super.c	2005-07-07 02:34:14 +0200
@@ -171,6 +171,7 @@ xfs_revalidate_inode(
 	inode->i_nlink	= ip->i_d.di_nlink;
 	inode->i_uid	= ip->i_d.di_uid;
 	inode->i_gid	= ip->i_d.di_gid;
+	inode->i_xid	= ip->i_d.di_xid;
 	if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
 		inode->i_rdev = 0;
 	} else {
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_vnode.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_vnode.c	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_vnode.c	2005-07-07 04:36:56 +0200
@@ -202,6 +202,7 @@ vn_revalidate_core(
 	inode->i_nlink	    = vap->va_nlink;
 	inode->i_uid	    = vap->va_uid;
 	inode->i_gid	    = vap->va_gid;
+	inode->i_xid	    = vap->va_xid;
 	inode->i_blocks	    = vap->va_nblocks;
 	inode->i_mtime	    = vap->va_mtime;
 	inode->i_ctime	    = vap->va_ctime;
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_vnode.h linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_vnode.h
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/linux-2.6/xfs_vnode.h	2005-06-22 02:38:40 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/linux-2.6/xfs_vnode.h	2005-07-07 03:41:33 +0200
@@ -413,6 +413,7 @@ typedef struct vattr {
 	xfs_nlink_t	va_nlink;	/* number of references to file */
 	uid_t		va_uid;		/* owner user id */
 	gid_t		va_gid;		/* owner group id */
+	xid_t		va_xid;		/* owner group id */
 	xfs_ino_t	va_nodeid;	/* file id */
 	xfs_off_t	va_size;	/* file size in bytes */
 	u_long		va_blocksize;	/* blocksize preferred for i/o */
@@ -461,13 +462,15 @@ typedef struct vattr {
 #define XFS_AT_PROJID		0x04000000
 #define XFS_AT_SIZE_NOPERM	0x08000000
 #define XFS_AT_GENCOUNT		0x10000000
+#define XFS_AT_XID		0x20000000
 
 #define XFS_AT_ALL	(XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
 		XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
 		XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
 		XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
 		XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
-		XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
+		XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT\
+		XFS_AT_XID)
 
 #define XFS_AT_STAT	(XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
 		XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_dinode.h linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_dinode.h
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_dinode.h	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_dinode.h	2005-07-07 03:06:07 +0200
@@ -72,7 +72,8 @@ typedef struct xfs_dinode_core
 	__uint32_t	di_gid;		/* owner's group id */
 	__uint32_t	di_nlink;	/* number of links to file */
 	__uint16_t	di_projid;	/* owner's project id */
-	__uint8_t	di_pad[8];	/* unused, zeroed space */
+	__uint16_t	di_xid;		/* vserver context id */
+	__uint8_t	di_pad[6];	/* unused, zeroed space */
 	__uint16_t	di_flushiter;	/* incremented on flush */
 	xfs_timestamp_t	di_atime;	/* time last accessed */
 	xfs_timestamp_t	di_mtime;	/* time last modified */
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_fs.h linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_fs.h
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_fs.h	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_fs.h	2005-07-07 03:09:27 +0200
@@ -308,7 +308,8 @@ typedef struct xfs_bstat {
 	__s32		bs_extents;	/* number of extents		*/
 	__u32		bs_gen;		/* generation count		*/
 	__u16		bs_projid;	/* project id			*/
-	unsigned char	bs_pad[14];	/* pad space, unused		*/
+	__u16		bs_xid;		/* context id			*/
+	unsigned char	bs_pad[12];	/* pad space, unused		*/
 	__u32		bs_dmevmask;	/* DMIG event mask		*/
 	__u16		bs_dmstate;	/* DMIG state info		*/
 	__u16		bs_aextents;	/* attribute number of extents	*/
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_inode.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_inode.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_inode.c	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_inode.c	2005-07-07 03:26:30 +0200
@@ -67,6 +67,7 @@
 #include "xfs_mac.h"
 #include "xfs_acl.h"
 
+#include <linux/vserver/xid.h>
 
 kmem_zone_t *xfs_ifork_zone;
 kmem_zone_t *xfs_inode_zone;
@@ -792,20 +793,34 @@ xfs_xlate_dinode_core(
 	xfs_dinode_core_t	*buf_core = (xfs_dinode_core_t *)buf;
 	xfs_dinode_core_t	*mem_core = (xfs_dinode_core_t *)dip;
 	xfs_arch_t		arch = ARCH_CONVERT;
+	uint32_t		uid = 0, gid = 0;
+	uint16_t		xid = 0;
 
 	ASSERT(dir);
 
+	if (dir < 0) {
+		/* FIXME make that conditional on some flag */
+		xid = mem_core->di_xid;
+		uid = XIDINO_UID(1, mem_core->di_uid, xid);
+		gid = XIDINO_GID(1, mem_core->di_gid, xid);
+	}
+
 	INT_XLATE(buf_core->di_magic, mem_core->di_magic, dir, arch);
 	INT_XLATE(buf_core->di_mode, mem_core->di_mode, dir, arch);
 	INT_XLATE(buf_core->di_version,	mem_core->di_version, dir, arch);
 	INT_XLATE(buf_core->di_format, mem_core->di_format, dir, arch);
 	INT_XLATE(buf_core->di_onlink, mem_core->di_onlink, dir, arch);
-	INT_XLATE(buf_core->di_uid, mem_core->di_uid, dir, arch);
-	INT_XLATE(buf_core->di_gid, mem_core->di_gid, dir, arch);
+	INT_XLATE(buf_core->di_uid, uid, dir, arch);
+	INT_XLATE(buf_core->di_gid, gid, dir, arch);
+	INT_XLATE(buf_core->di_xid, xid, dir, arch);
 	INT_XLATE(buf_core->di_nlink, mem_core->di_nlink, dir, arch);
 	INT_XLATE(buf_core->di_projid, mem_core->di_projid, dir, arch);
 
 	if (dir > 0) {
+		/* FIXME make that conditional on some flag */
+		mem_core->di_uid = INOXID_UID(1, uid, gid);
+		mem_core->di_gid = INOXID_GID(1, uid, gid);
+		mem_core->di_xid = INOXID_XID(1, uid, gid, xid);
 		memcpy(mem_core->di_pad, buf_core->di_pad,
 			sizeof(buf_core->di_pad));
 	} else {
@@ -1184,6 +1199,7 @@ xfs_ialloc(
 	ASSERT(ip->i_d.di_nlink == nlink);
 	ip->i_d.di_uid = current_fsuid(cr);
 	ip->i_d.di_gid = current_fsgid(cr);
+	ip->i_d.di_xid = current_fsxid(cr);
 	ip->i_d.di_projid = prid;
 	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
 
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_itable.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_itable.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_itable.c	2005-06-22 02:38:40 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_itable.c	2005-07-07 03:56:25 +0200
@@ -97,6 +97,7 @@ xfs_bulkstat_one_iget(
 	buf->bs_mode = dic->di_mode;
 	buf->bs_uid = dic->di_uid;
 	buf->bs_gid = dic->di_gid;
+	buf->bs_xid = dic->di_xid;
 	buf->bs_size = dic->di_size;
 	buf->bs_atime.tv_sec = dic->di_atime.t_sec;
 	buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
@@ -172,6 +173,7 @@ xfs_bulkstat_one_dinode(
 	buf->bs_mode = INT_GET(dic->di_mode, ARCH_CONVERT);
 	buf->bs_uid = INT_GET(dic->di_uid, ARCH_CONVERT);
 	buf->bs_gid = INT_GET(dic->di_gid, ARCH_CONVERT);
+	buf->bs_xid = INT_GET(dic->di_xid, ARCH_CONVERT);
 	buf->bs_size = INT_GET(dic->di_size, ARCH_CONVERT);
 	buf->bs_atime.tv_sec = INT_GET(dic->di_atime.t_sec, ARCH_CONVERT);
 	buf->bs_atime.tv_nsec = INT_GET(dic->di_atime.t_nsec, ARCH_CONVERT);
diff -NurpP --minimal linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_vnodeops.c linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_vnodeops.c
--- linux-2.6.12.2-vs2.0-rc5.5/fs/xfs/xfs_vnodeops.c	2005-07-02 22:38:30 +0200
+++ linux-2.6.12.2-vs2.0-rc5.6/fs/xfs/xfs_vnodeops.c	2005-07-07 04:04:53 +0200
@@ -167,6 +167,7 @@ xfs_getattr(
 	vap->va_mode = ip->i_d.di_mode & MODEMASK;
 	vap->va_uid = ip->i_d.di_uid;
 	vap->va_gid = ip->i_d.di_gid;
+	vap->va_xid = ip->i_d.di_xid;
 	vap->va_projid = ip->i_d.di_projid;
 
 	/*
@@ -299,6 +300,7 @@ xfs_setattr(
 	uint			commit_flags=0;
 	uid_t			uid=0, iuid=0;
 	gid_t			gid=0, igid=0;
+	xid_t			xid=0, ixid=0;
 	int			timeflags = 0;
 	vnode_t			*vp;
 	xfs_prid_t		projid=0, iprojid=0;
@@ -354,6 +356,7 @@ xfs_setattr(
 	if (XFS_IS_QUOTA_ON(mp) && (mask & (XFS_AT_UID|XFS_AT_GID))) {
 		uint	qflags = 0;
 
+		/* FIXME: handle xid? */
 		if (mask & XFS_AT_UID) {
 			uid = vap->va_uid;
 			qflags |= XFS_QMOPT_UQUOTA;
@@ -427,6 +430,8 @@ xfs_setattr(
 	if (mask &
 	    (XFS_AT_MODE|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_UID|
 	     XFS_AT_GID|XFS_AT_PROJID)) {
+		/* FIXME: handle xid? */
+
 		/*
 		 * CAP_FOWNER overrides the following restrictions:
 		 *
@@ -475,7 +480,7 @@ xfs_setattr(
 	 * and can change the group id only to a group of which he
 	 * or she is a member.
 	 */
-	if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
+	if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_XID|XFS_AT_PROJID)) {
 		/*
 		 * These IDs could have changed since we last looked at them.
 		 * But, we're assured that if the ownership did change
@@ -483,10 +488,12 @@ xfs_setattr(
 		 * would have changed also.
 		 */
 		iuid = ip->i_d.di_uid;
-		iprojid = ip->i_d.di_projid;
 		igid = ip->i_d.di_gid;
-		gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
+		ixid = ip->i_d.di_xid;
+		iprojid = ip->i_d.di_projid;
 		uid = (mask & XFS_AT_UID) ? vap->va_uid : iuid;
+		gid = (mask & XFS_AT_GID) ? vap->va_gid : igid;
+		xid = (mask & XFS_AT_XID) ? vap->va_xid : ixid;
 		projid = (mask & XFS_AT_PROJID) ? (xfs_prid_t)vap->va_projid :
 			 iprojid;
 
@@ -515,6 +522,7 @@ xfs_setattr(
 		 */
 		if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
 		    (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
+			/* FIXME: handle xid? */
 			ASSERT(tp);
 			code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
 						capable(CAP_FOWNER) ?
@@ -747,7 +755,7 @@ xfs_setattr(
 	 * and can change the group id only to a group of which he
 	 * or she is a member.
 	 */
-	if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID)) {
+	if (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_XID|XFS_AT_PROJID)) {
 		/*
 		 * CAP_FSETID overrides the following restrictions:
 		 *
@@ -763,6 +771,12 @@ xfs_setattr(
 		 * Change the ownerships and register quota modifications
 		 * in the transaction.
 		 */
+		if (ixid != xid) {
+			if (XFS_IS_GQUOTA_ON(mp)) {
+				/* FIXME: handle xid quota? */
+			}
+			ip->i_d.di_xid = xid;
+		}
 		if (iuid != uid) {
 			if (XFS_IS_UQUOTA_ON(mp)) {
 				ASSERT(mask & XFS_AT_UID);
