From e31db0edce11d4b5319d66c27e9eab1c352a01d1 Mon Sep 17 00:00:00 2001
From: Niu Yawei <yawei.niu@intel.com>
Date: Wed, 22 Jan 2014 02:44:00 -0500
Subject: [PATCH] LU-4345 quota: debug patch

Added some debug message to figure out where the fake uid comes from.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: Ib9243723f6b70caf313f0a0de5bd10567e2987a3
---
 lustre/ofd/ofd_io.c         |    8 ++++++++
 lustre/ofd/ofd_obd.c        |    6 ++++++
 lustre/ofd/ofd_objects.c    |    8 ++++++++
 lustre/osd-zfs/osd_object.c |   18 ++++++++++--------
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c
index b90bc8a..cee8af2 100644
--- a/lustre/ofd/ofd_io.c
+++ b/lustre/ofd/ofd_io.c
@@ -375,6 +375,10 @@ ofd_write_attr_set(const struct lu_env *env, struct ofd_device *ofd,
 
 	/* set uid/gid */
 	if (la->la_valid) {
+		/* XXX debug for LU-4345 */
+		if ((la->la_valid & LA_UID) && (la->la_uid > 7000))
+			CERROR("set uid: %u\n", la->la_uid);
+
 		rc = dt_attr_set(env, dt_obj, la, th,
 				 ofd_object_capa(env, ofd_obj));
 		if (rc)
@@ -467,6 +471,10 @@ retry:
 		GOTO(out_stop, rc);
 
 	if (la->la_valid) {
+		/* XXX debug for LU-4345 */
+		if ((la->la_valid & LA_UID) && (la->la_uid > 7000))
+			CERROR("set uid: %u\n", la->la_uid);
+
 		rc = dt_attr_set(env, o, la, th, ofd_object_capa(env, fo));
 		if (rc)
 			GOTO(out_stop, rc);
diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c
index 0116067..677848c 100644
--- a/lustre/ofd/ofd_obd.c
+++ b/lustre/ofd/ofd_obd.c
@@ -882,6 +882,12 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp,
 		ofd_prepare_fidea(ff, oa);
 	}
 
+	/* XXX debug for LU-4345 */
+	if ((info->fti_attr.la_valid & LA_UID) &&
+	    (info->fti_attr.la_uid > 7000)) {
+		CERROR("set uid: %u\n", info->fti_attr.la_uid);
+	}
+
 	/* setting objects attributes (including owner/group) */
 	rc = ofd_attr_set(env, fo, &info->fti_attr, ff);
 	if (rc)
diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c
index 00226cb..7aa5c54 100644
--- a/lustre/ofd/ofd_objects.c
+++ b/lustre/ofd/ofd_objects.c
@@ -413,6 +413,10 @@ int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo,
 	if (rc)
 		GOTO(stop, rc);
 
+	/* XXX debug for LU-4345 */
+	if ((la->la_valid & LA_UID) && (la->la_uid > 7000))
+		CERROR("set uid: %u\n", la->la_uid);
+
 	rc = dt_attr_set(env, ofd_object_child(fo), la, th,
 			 ofd_object_capa(env, fo));
 	if (rc)
@@ -503,6 +507,10 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo,
 	if (rc)
 		GOTO(stop, rc);
 
+	/* XXX debug for LU-4345 */
+	if ((la->la_valid & LA_UID) && (la->la_uid > 7000))
+		CERROR("set uid: %u\n", la->la_uid);
+
 	rc = dt_attr_set(env, dob, la, th, ofd_object_capa(env, fo));
 	if (rc)
 		GOTO(stop, rc);
diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c
index 85732f1..0812341 100644
--- a/lustre/osd-zfs/osd_object.c
+++ b/lustre/osd-zfs/osd_object.c
@@ -962,13 +962,14 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt,
 		rc = -zap_increment_int(osd->od_objset.os, osd->od_iusr_oid,
 					la->la_uid, 1, oh->ot_tx);
 		if (rc)
-			CERROR("%s: failed to update accounting ZAP for user "
-				"%d (%d)\n", osd->od_svname, la->la_uid, rc);
+			CERROR("%s: failed to update accounting ZAP for new "
+			       "user %d (%d)\n", osd->od_svname, la->la_uid,
+			       rc);
 		rc = -zap_increment_int(osd->od_objset.os, osd->od_iusr_oid,
 					obj->oo_attr.la_uid, -1, oh->ot_tx);
 		if (rc)
-			CERROR("%s: failed to update accounting ZAP for user "
-				"%d (%d)\n", osd->od_svname,
+			CERROR("%s: failed to update accounting ZAP for "
+			       "original user %d (%d)\n", osd->od_svname,
 				obj->oo_attr.la_uid, rc);
 	}
 	if ((la->la_valid & LA_GID) && (la->la_gid != obj->oo_attr.la_gid)) {
@@ -977,13 +978,14 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt,
 		rc = -zap_increment_int(osd->od_objset.os, osd->od_igrp_oid,
 					la->la_gid, 1, oh->ot_tx);
 		if (rc)
-			CERROR("%s: failed to update accounting ZAP for user "
-				"%d (%d)\n", osd->od_svname, la->la_gid, rc);
+			CERROR("%s: failed to update accounting ZAP for new "
+			       "group %d (%d)\n", osd->od_svname, la->la_gid,
+			       rc);
 		rc = -zap_increment_int(osd->od_objset.os, osd->od_igrp_oid,
 					obj->oo_attr.la_gid, -1, oh->ot_tx);
 		if (rc)
-			CERROR("%s: failed to update accounting ZAP for user "
-				"%d (%d)\n", osd->od_svname,
+			CERROR("%s: failed to update accounting ZAP for "
+			       "original group %d (%d)\n", osd->od_svname,
 				obj->oo_attr.la_gid, rc);
 	}
 
-- 
1.7.1