diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index dc3c031fd761c5ba07980ae133bfe0c4fb90c755..ed39aa672dbd00b4a350da2c2d259aff42a7a5fd 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1287,10 +1287,10 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_CONFIG_PINGER
           LC_CONFIG_CHECKSUM
           LC_CONFIG_LIBLUSTRE_RECOVERY
-          LC_CONFIG_QUOTA
           LC_CONFIG_HEALTH_CHECK_WRITE
           LC_CONFIG_LRU_RESIZE
           LC_CONFIG_ADAPTIVE_TIMEOUTS
+          LC_QUOTA_MODULE
 
           LC_TASK_PPTR
           # RHEL4 patches
@@ -1509,35 +1509,54 @@ fi
 #
 # LC_CONFIG_QUOTA
 #
-# whether to enable quota support
+# whether to enable quota support global control
 #
 AC_DEFUN([LC_CONFIG_QUOTA],
-[AC_ARG_ENABLE([quota], 
+[AC_ARG_ENABLE([quota],
 	AC_HELP_STRING([--enable-quota],
 			[enable quota support]),
-	[],[enable_quota='default'])
-if test x$linux25 != xyes; then
-	enable_quota='no'
+	[],[enable_quota='yes'])
+])
+
+# whether to enable quota support(kernel modules)
+AC_DEFUN([LC_QUOTA_MODULE],
+[if test x$enable_quota != xno; then
+    LB_LINUX_CONFIG([QUOTA],[
+	enable_quota_module='yes'
+	AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
+    ],[
+	enable_quota_module='no'
+	AC_MSG_WARN([quota is not enabled because the kernel - lacks quota support])
+    ])
 fi
-LB_LINUX_CONFIG([QUOTA],[
-	if test x$enable_quota = xdefault; then
-		enable_quota='yes'
-	fi
-],[
-	if test x$enable_quota = xdefault; then
-		enable_quota='no'
-		AC_MSG_WARN([quota is not enabled because the kernel lacks quota support])
-	else
-		if test x$enable_quota = xyes; then
-			AC_MSG_ERROR([cannot enable quota because the kernel lacks quota support])
-		fi
-	fi
 ])
+
+#
+# LC_CONFIG_QUOTA_LIBLUSTRE
+#
+# whether to enable quota support(liblustre)
+#
+AC_DEFUN([LC_CONFIG_QUOTA_LIBLUSTRE],
+[enable_quota_liblustre='no'
 if test x$enable_quota != xno; then
+	AC_MSG_CHECKING([if compile liblustre with quota])
+	enable_quota_liblustre='yes'
 	AC_DEFINE(HAVE_QUOTA_SUPPORT, 1, [Enable quota support])
+	AC_DEFINE(HAVE_QUOTA_LIBLUSTRE_SUPPORT, 1, [Enable liblustre quota support])
+	AC_MSG_RESULT([yes])
 fi
 ])
 
+AC_DEFUN([LC_QUOTA],
+[#check global
+LC_CONFIG_QUOTA
+LC_CONFIG_QUOTA_LIBLUSTRE
+#check for utils
+AC_CHECK_HEADER(sys/quota.h,
+                [AC_DEFINE(HAVE_SYS_QUOTA_H, 1, [Define to 1 if you have <sys/quota.h>.])],
+                [AC_MSG_ERROR([don't find <sys/quota.h> in your system])])
+])
+
 AC_DEFUN([LC_QUOTA_READ],
 [AC_MSG_CHECKING([if kernel supports quota_read])
 LB_LINUX_TRY_COMPILE([
@@ -1734,7 +1753,7 @@ AM_CONDITIONAL(LIBLUSTRE_TESTS, test x$enable_liblustre_tests = xyes)
 AM_CONDITIONAL(MPITESTS, test x$enable_mpitests = xyes, Build MPI Tests)
 AM_CONDITIONAL(CLIENT, test x$enable_client = xyes)
 AM_CONDITIONAL(SERVER, test x$enable_server = xyes)
-AM_CONDITIONAL(QUOTA, test x$enable_quota = xyes)
+AM_CONDITIONAL(QUOTA, test x$enable_quota_module = xyes -o x$enable_quota_liblustre = xyes)
 AM_CONDITIONAL(BLKID, test x$ac_cv_header_blkid_blkid_h = xyes)
 AM_CONDITIONAL(EXT2FS_DEVEL, test x$ac_cv_header_ext2fs_ext2fs_h = xyes)
 AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
diff --git a/lustre/liblustre/lutil.c b/lustre/liblustre/lutil.c
index 930c4ead794511a34af9d59f01b6d3f3ba6f011b..2b0e6042d6e3e10861c351c758f1892b281a4acb 100644
--- a/lustre/liblustre/lutil.c
+++ b/lustre/liblustre/lutil.c
@@ -77,7 +77,7 @@ void *inter_module_get(char *arg)
                 return ldlm_namespace_cleanup;
         else if (!strcmp(arg, "ldlm_replay_locks"))
                 return ldlm_replay_locks;
-#ifdef HAVE_QUOTA_SUPPORT
+#ifdef HAVE_QUOTA_LIBLUSTRE_SUPPORT
         else if (!strcmp(arg, "osc_quota_interface"))
                 return &osc_quota_interface;
         else if (!strcmp(arg, "mdc_quota_interface"))
diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c
index 1490e734faa67687a2b62d103f54007418f3f0bb..7e968353f9b846fd534c27db171960ecb8d87b5e 100644
--- a/lustre/lvfs/fsfilt_ext3.c
+++ b/lustre/lvfs/fsfilt_ext3.c
@@ -1470,6 +1470,7 @@ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs)
         return 0;
 }
 
+#ifdef HAVE_QUOTA_SUPPORT
 #define DQINFO_COPY(out, in)                    \
 do {                                            \
         Q_COPY(out, in, dqi_bgrace);            \
@@ -2159,7 +2160,6 @@ out:
         RETURN(rc);
 }
 
-#ifdef HAVE_QUOTA_SUPPORT
 static int fsfilt_ext3_quotainfo(struct lustre_quota_info *lqi, int type, 
                                  int cmd)
 {
@@ -2274,13 +2274,13 @@ static struct fsfilt_operations fsfilt_ext3_ops = {
         .fs_setup               = fsfilt_ext3_setup,
         .fs_send_bio            = fsfilt_ext3_send_bio,
         .fs_get_op_len          = fsfilt_ext3_get_op_len,
-        .fs_quotactl            = fsfilt_ext3_quotactl,
-        .fs_quotacheck          = fsfilt_ext3_quotacheck,
 #ifdef HAVE_DISK_INODE_VERSION
         .fs_get_version         = fsfilt_ext3_get_version,
         .fs_set_version         = fsfilt_ext3_set_version,
 #endif
 #ifdef HAVE_QUOTA_SUPPORT
+        .fs_quotactl            = fsfilt_ext3_quotactl,
+        .fs_quotacheck          = fsfilt_ext3_quotacheck,
         .fs_quotainfo           = fsfilt_ext3_quotainfo,
         .fs_qids                = fsfilt_ext3_qids,
         .fs_dquot               = fsfilt_ext3_dquot,
diff --git a/lustre/lvfs/lustre_quota_fmt.h b/lustre/lvfs/lustre_quota_fmt.h
index 93a8945cacf4093e163b174aea4500d126264fdf..a9fbcfca3136012fdfb2a921cfe845b349cfc0f0 100644
--- a/lustre/lvfs/lustre_quota_fmt.h
+++ b/lustre/lvfs/lustre_quota_fmt.h
@@ -41,6 +41,8 @@
 #ifndef _LUSTRE_QUOTA_FMT_H
 #define _LUSTRE_QUOTA_FMT_H
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 #include <linux/types.h>
 #include <linux/quota.h>
 
@@ -222,3 +224,4 @@ int lustre_quota_convert(struct lustre_quota_info *lqi, int type);
 #define LUSTRE_OPQFILES_NAMES { { "lquota.user", "lquota.group" }, \
                                 { "lquota_v2.user", "lquota_v2.group" } }
 #endif                          /* lustre_quota_fmt.h */
+#endif
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index d9f9a0daf761a2f52a8145df7d104cdfc48c3363..f8ee54599112f4e5a89d80ec8c0caa2954a78725 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -1405,6 +1405,7 @@ static int mds_set_info_rpc(struct obd_export *exp, struct ptlrpc_request *req)
         RETURN(0);
 }
 
+#ifdef HAVE_QUOTA_SUPPORT
 static int mds_handle_quotacheck(struct ptlrpc_request *req)
 {
         struct obd_quotactl *oqctl;
@@ -1445,6 +1446,7 @@ static int mds_handle_quotactl(struct ptlrpc_request *req)
         *repoqc = *oqctl;
         RETURN(0);
 }
+#endif
 
 static int mds_msg_check_version(struct lustre_msg *msg)
 {
@@ -1765,7 +1767,7 @@ int mds_handle(struct ptlrpc_request *req)
                 DEBUG_REQ(D_INODE, req, "set_info");
                 rc = mds_set_info_rpc(req->rq_export, req);
                 break;
-
+#ifdef HAVE_QUOTA_SUPPORT
         case MDS_QUOTACHECK:
                 DEBUG_REQ(D_INODE, req, "quotacheck");
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_QUOTACHECK_NET, 0);
@@ -1777,7 +1779,7 @@ int mds_handle(struct ptlrpc_request *req)
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_QUOTACTL_NET, 0);
                 rc = mds_handle_quotactl(req);
                 break;
-
+#endif
         case OBD_PING:
                 DEBUG_REQ(D_INODE, req, "ping");
                 rc = target_handle_ping(req);
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index f07a0c131310fef1f88d4aab978aadbd07814589..47e791fca07a157ab8d511ee86fd957f8cbb4b24 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -1354,6 +1354,7 @@ static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req)
         RETURN(rc);
 }
 
+#ifdef HAVE_QUOTA_SUPPORT
 static int ost_handle_quotactl(struct ptlrpc_request *req)
 {
         struct obd_quotactl *oqctl, *repoqc;
@@ -1420,6 +1421,7 @@ static int ost_handle_quota_adjust_qunit(struct ptlrpc_request *req)
  out:
         RETURN(rc);
 }
+#endif
 
 static int ost_filter_recovery_request(struct ptlrpc_request *req,
                                        struct obd_device *obd, int *process)
@@ -1477,6 +1479,7 @@ int ost_msg_check_version(struct lustre_msg *msg)
         case OST_SYNC:
         case OST_SET_INFO:
         case OST_GET_INFO:
+#ifdef HAVE_QUOTA_SUPPORT
         case OST_QUOTACHECK:
         case OST_QUOTACTL:
         case OST_QUOTA_ADJUST_QUNIT:
@@ -1487,6 +1490,7 @@ int ost_msg_check_version(struct lustre_msg *msg)
                                lustre_msg_get_version(msg),
                                LUSTRE_OST_VERSION);
                 break;
+#endif
         case LDLM_ENQUEUE:
         case LDLM_CONVERT:
         case LDLM_CANCEL:
@@ -1663,6 +1667,7 @@ static int ost_handle(struct ptlrpc_request *req)
                 DEBUG_REQ(D_INODE, req, "get_info");
                 rc = ost_get_info(req->rq_export, req);
                 break;
+#ifdef HAVE_QUOTA_SUPPORT
         case OST_QUOTACHECK:
                 CDEBUG(D_INODE, "quotacheck\n");
                 OBD_FAIL_RETURN(OBD_FAIL_OST_QUOTACHECK_NET, 0);
@@ -1677,6 +1682,7 @@ static int ost_handle(struct ptlrpc_request *req)
                 CDEBUG(D_INODE, "quota_adjust_qunit\n");
                 rc = ost_handle_quota_adjust_qunit(req);
                 break;
+#endif
         case OBD_PING:
                 DEBUG_REQ(D_INODE, req, "ping");
                 rc = target_handle_ping(req);
diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c
index b485984c422f419689039c274f578f53e965526a..5594382cadef508d6a1d39a2bcf5ef6bc30ffb80 100644
--- a/lustre/utils/lfs.c
+++ b/lustre/utils/lfs.c
@@ -54,7 +54,9 @@
 #include <dirent.h>
 #include <time.h>
 #include <ctype.h>
+#ifdef HAVE_SYS_QUOTA_H
 #include <sys/quota.h>
+#endif
 
 #include <lnet/api-support.h>
 #include <lnet/lnetctl.h>
@@ -77,7 +79,7 @@ static int lfs_osts(int argc, char **argv);
 static int lfs_df(int argc, char **argv);
 static int lfs_check(int argc, char **argv);
 static int lfs_catinfo(int argc, char **argv);
-#ifdef HAVE_QUOTA_SUPPORT
+#ifdef HAVE_SYS_QUOTA_H
 static int lfs_quotachown(int argc, char **argv);
 static int lfs_quotacheck(int argc, char **argv);
 static int lfs_quotaon(int argc, char **argv);
@@ -138,7 +140,7 @@ command_t cmdlist[] = {
          "report filesystem disk space usage or inodes usage"
          "of each MDS/OSD.\n"
          "Usage: df [-i] [-h] [path]"},
-#ifdef HAVE_QUOTA_SUPPORT
+#ifdef HAVE_SYS_QUOTA_H
         {"quotachown",lfs_quotachown, 0,
          "Change files' owner or group on the specified filesystem.\n"
          "usage: quotachown [-i] <filesystem>\n"
@@ -333,9 +335,12 @@ static int set_time(time_t *time, time_t *set, char *str)
         return res;
 }
 
+#define USER 0
+#define GROUP 1
+
 static int name2id(unsigned int *id, char *name, int type)
 {
-        if (type == USRQUOTA) {
+        if (type == USER) {
                 struct passwd *entry;
 
                 if (!(entry = getpwnam(name))) {
@@ -362,7 +367,7 @@ static int name2id(unsigned int *id, char *name, int type)
 
 static int id2name(char **name, unsigned int id, int type)
 {
-        if (type == USRQUOTA) {
+        if (type == USER) {
                 struct passwd *entry;
 
                 if (!(entry = getpwuid(id))) {
@@ -510,7 +515,7 @@ static int lfs_find(int argc, char **argv)
                         new_fashion = 1;
                         param.gid = strtol(optarg, &endptr, 10);
                         if (optarg == endptr) {
-	                        ret = name2id(&param.gid, optarg, GRPQUOTA);
+	                        ret = name2id(&param.gid, optarg, GROUP);
         	                if (ret != 0) {
                                         fprintf(stderr, "Group/GID: %s cannot "
                                                 "be found.\n", optarg);
@@ -534,7 +539,7 @@ static int lfs_find(int argc, char **argv)
                         new_fashion = 1;
                         param.uid = strtol(optarg, &endptr, 10);
                         if (optarg == endptr) {
-	                        ret = name2id(&param.uid, optarg, USRQUOTA);
+	                        ret = name2id(&param.uid, optarg, USER);
         	                if (ret != 0) {
                                         fprintf(stderr, "User/UID: %s cannot "
                                                 "be found.\n", optarg);
@@ -1202,7 +1207,7 @@ out:
         return rc;
 }
 
-#ifdef HAVE_QUOTA_SUPPORT
+#ifdef HAVE_SYS_QUOTA_H
 static int lfs_quotachown(int argc, char **argv)
 {
 
@@ -1701,7 +1706,8 @@ int lfs_setquota(int argc, char **argv)
                                 " be available in future releases!\n");
 
                 qctl.qc_type = !strcmp(argv[1], "-u") ? USRQUOTA : GRPQUOTA;
-                rc = name2id(&qctl.qc_id, argv[2], qctl.qc_type);
+                rc = name2id(&qctl.qc_id, argv[2],
+                             (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                 if (rc) {
                         fprintf(stderr, "error: unknown id %s\n", optarg);
                         return CMD_HELP;
@@ -1731,7 +1737,8 @@ int lfs_setquota(int argc, char **argv)
                                 return CMD_HELP;
                         }
                         qctl.qc_type = (c == 'u') ? USRQUOTA : GRPQUOTA;
-                        rc = name2id(&qctl.qc_id, optarg, qctl.qc_type);
+                        rc = name2id(&qctl.qc_id, optarg,
+                                     (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                         if (rc) {
                                 fprintf(stderr, "error: unknown id %s\n",
                                         optarg);
@@ -2105,7 +2112,8 @@ ug_output:
                         qctl.qc_type = GRPQUOTA;
                         qctl.qc_id = getegid();
                 }
-                rc = id2name(&name, qctl.qc_id, qctl.qc_type);
+                rc = id2name(&name, qctl.qc_id,
+                             (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                 if (rc)
                         name = "<unknown>";
         } else if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
@@ -2115,7 +2123,8 @@ ug_output:
                 }
 
                 name = argv[optind++];
-                rc = name2id(&qctl.qc_id, name, qctl.qc_type);
+                rc = name2id(&qctl.qc_id, name,
+                             (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                 if (rc) {
                         fprintf(stderr,"error: can't find id for name %s: %s\n",
                                 name, strerror(errno));
@@ -2161,7 +2170,7 @@ out:
 
         return 0;
 }
-#endif /* HAVE_QUOTA_SUPPORT */
+#endif /* HAVE_SYS_QUOTA_H! */
 
 int main(int argc, char **argv)
 {