diff --git a/lustre/Makefile.in b/lustre/Makefile.in
index c06794a37654c8e88967e4cc0e35f4cbb22546fc..ca60f36f176697d6dc49f4ac4de5543164fd0a42 100644
--- a/lustre/Makefile.in
+++ b/lustre/Makefile.in
@@ -5,9 +5,9 @@ subdir-m += ptlrpc
 subdir-m += osc
 subdir-m += obdecho
 subdir-m += mgc
+subdir-m += quota
 
 @SERVER_TRUE@subdir-m += mds obdfilter ost mgs
 @CLIENT_TRUE@subdir-m += mdc llite 
-@QUOTA_TRUE@subdir-m += quota
 
 @INCLUDE_RULES@
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 031d94ed6e199d1abe3b8c5130e2931dc5b6508a..1559db3dd550f5366e4e9e24d062623c44e3d17f 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1545,7 +1545,6 @@ AC_DEFUN([LC_CONFIG_QUOTA_LIBLUSTRE],
 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
diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h
index aaff3e67f5507c34100109fe7103da49b688e4a1..14da2b3721323fe964743bf2c3df451ade462d1c 100644
--- a/lustre/include/lustre_lib.h
+++ b/lustre/include/lustre_lib.h
@@ -80,13 +80,12 @@ int target_handle_ping(struct ptlrpc_request *req);
 int target_pack_pool_reply(struct ptlrpc_request *req);
 void target_committed_to_req(struct ptlrpc_request *req);
 
-#ifdef HAVE_QUOTA_SUPPORT
 /* quotacheck callback, dqacq/dqrel callback handler */
 int target_handle_qc_callback(struct ptlrpc_request *req);
+#ifdef HAVE_QUOTA_SUPPORT
 int target_handle_dqacq_callback(struct ptlrpc_request *req);
 #else
 #define target_handle_dqacq_callback(req) ldlm_callback_reply(req, -ENOTSUPP)
-#define target_handle_qc_callback(req) (0)
 #endif
 
 void target_cancel_recovery_timer(struct obd_device *obd);
diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h
index 77fdb73473f4460b40966dc8a53c937b522b10c5..ee1d0a13ec6eb4e72d78d316660b1727454a6972 100644
--- a/lustre/include/lustre_quota.h
+++ b/lustre/include/lustre_quota.h
@@ -653,6 +653,19 @@ static inline int lquota_pending_commit(quota_interface_t *interface,
 extern quota_interface_t osc_quota_interface;
 extern quota_interface_t mdc_quota_interface;
 extern quota_interface_t lov_quota_interface;
+
+#ifndef MAXQUOTAS
+#define MAXQUOTAS 2
+#endif
+
+#ifndef USRQUOTA
+#define USRQUOTA 0
+#endif
+
+#ifndef GRPQUOTA
+#define GRPQUOTA 1
+#endif
+
 #endif
 
 #define LUSTRE_ADMIN_QUOTAFILES_V1 {\
diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h
index a708895c7abcb4932e6100154ce041f8624d60e3..babf7eb02a5126a6f932f30afe07fa3cd9231e9d 100644
--- a/lustre/include/obd_class.h
+++ b/lustre/include/obd_class.h
@@ -1385,7 +1385,6 @@ static inline int obd_notify_observer(struct obd_device *observer,
         return rc1 ?: rc2;
  }
 
-#ifdef HAVE_QUOTA_SUPPORT
 static inline int obd_quotacheck(struct obd_export *exp,
                                  struct obd_quotactl *oqctl)
 {
@@ -1416,7 +1415,7 @@ static inline int obd_quota_adjust_qunit(struct obd_export *exp,
                                          struct quota_adjust_qunit *oqaq,
                                          struct lustre_quota_ctxt *qctxt)
 {
-#ifdef LPROCFS
+#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
         struct timeval work_start;
         struct timeval work_end;
         long timediff;
@@ -1424,7 +1423,7 @@ static inline int obd_quota_adjust_qunit(struct obd_export *exp,
         int rc;
         ENTRY;
 
-#ifdef LPROCFS
+#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
         if (qctxt)
                 do_gettimeofday(&work_start);
 #endif
@@ -1433,7 +1432,7 @@ static inline int obd_quota_adjust_qunit(struct obd_export *exp,
 
         rc = OBP(exp->exp_obd, quota_adjust_qunit)(exp, oqaq, qctxt);
 
-#ifdef LPROCFS
+#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
         if (qctxt) {
                 do_gettimeofday(&work_end);
                 timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
@@ -1443,7 +1442,6 @@ static inline int obd_quota_adjust_qunit(struct obd_export *exp,
 #endif
         RETURN(rc);
 }
-#endif
 
 static inline int obd_health_check(struct obd_device *obd)
 {
diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c
index 5dc6af325860c3e729481101f9d6ccaa39fae814..c91c71d76e440a0cf1b8c2e5256bede432296913 100644
--- a/lustre/ldlm/ldlm_lib.c
+++ b/lustre/ldlm/ldlm_lib.c
@@ -1736,7 +1736,6 @@ void target_committed_to_req(struct ptlrpc_request *req)
 
 EXPORT_SYMBOL(target_committed_to_req);
 
-#ifdef HAVE_QUOTA_SUPPORT
 int target_handle_qc_callback(struct ptlrpc_request *req)
 {
         struct obd_quotactl *oqctl;
@@ -1754,6 +1753,7 @@ int target_handle_qc_callback(struct ptlrpc_request *req)
         return 0;
 }
 
+#ifdef HAVE_QUOTA_SUPPORT
 int target_handle_dqacq_callback(struct ptlrpc_request *req)
 {
 #ifdef __KERNEL__
diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c
index 2c40b41cca98ac8089d3c4227c4bf85d11c8cff7..668f26b5692afe79111411cf55434c2f96d68128 100644
--- a/lustre/llite/dir.c
+++ b/lustre/llite/dir.c
@@ -871,7 +871,6 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 obd_ioctl_freedata(buf, len);
                 RETURN(rc);
         }
-#ifdef HAVE_QUOTA_SUPPORT
         case OBD_IOC_QUOTACHECK: {
                 struct obd_quotactl *oqctl;
                 int rc, error = 0;
@@ -1043,7 +1042,6 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 OBD_FREE_PTR(oqctl);
                 RETURN(rc);
         }
-#endif /* HAVE_QUOTA_SUPPORT */
         case OBD_IOC_GETNAME_OLD:
         case OBD_IOC_GETNAME: {
                 struct obd_device *obd = class_exp2obd(sbi->ll_osc_exp);
diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c
index 7e968353f9b846fd534c27db171960ecb8d87b5e..69d5f4db4853394a964022640db93f0635346131 100644
--- a/lustre/lvfs/fsfilt_ext3.c
+++ b/lustre/lvfs/fsfilt_ext3.c
@@ -1407,7 +1407,9 @@ out:
 
 static int fsfilt_ext3_setup(struct super_block *sb)
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) && defined(HAVE_QUOTA_SUPPORT)
         struct ext3_sb_info *sbi = EXT3_SB(sb);
+#endif
 #if 0
         sbi->dx_lock = fsfilt_ext3_dx_lock;
         sbi->dx_unlock = fsfilt_ext3_dx_unlock;
diff --git a/lustre/lvfs/lustre_quota_fmt.c b/lustre/lvfs/lustre_quota_fmt.c
index 880ee5d415055e9e8c77a8a4b8b25bcc9a02f3c3..e168c99f47039c9e43f964d8c9a01daeee217a2f 100644
--- a/lustre/lvfs/lustre_quota_fmt.c
+++ b/lustre/lvfs/lustre_quota_fmt.c
@@ -39,7 +39,6 @@
  * from linux/fs/quota_v2.c
  */
 
-
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -60,6 +59,8 @@
 #include <obd_support.h>
 #include "lustre_quota_fmt.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 static const uint lustre_initqversions[][MAXQUOTAS] = {
         [LUSTRE_QUOTA_V1] = LUSTRE_INITQVERSIONS,
         [LUSTRE_QUOTA_V2] = LUSTRE_INITQVERSIONS_V2
@@ -1108,3 +1109,4 @@ EXPORT_SYMBOL(lustre_read_dquot);
 EXPORT_SYMBOL(lustre_commit_dquot);
 EXPORT_SYMBOL(lustre_init_quota_info);
 EXPORT_SYMBOL(lustre_get_qids);
+#endif
diff --git a/lustre/lvfs/lustre_quota_fmt_convert.c b/lustre/lvfs/lustre_quota_fmt_convert.c
index 5df31382b3f1a4acc42d446cd92cbd6776b457da..de85f8ba8382f26c7a86a3053098453464282a41 100644
--- a/lustre/lvfs/lustre_quota_fmt_convert.c
+++ b/lustre/lvfs/lustre_quota_fmt_convert.c
@@ -59,6 +59,8 @@
 #include <obd_support.h>
 #include "lustre_quota_fmt.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 static int admin_convert_dqinfo(struct file *fp_v1, struct file *fp_v2,
                                 struct lustre_quota_info *lqi, int type)
 {
@@ -300,4 +302,5 @@ out:
         return rc;
 }
 EXPORT_SYMBOL(lustre_slave_quota_convert);
-#endif
+#endif /* HAVE_QUOTA64 */
+#endif /* HAVE_QUOTA_SUPPORT */
diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c
index 5d0fe9b91390e9ed78478f45406ac29bff055a29..a371193379c5afae46bb05a8535897854dcbe30e 100644
--- a/lustre/lvfs/quotafmt_test.c
+++ b/lustre/lvfs/quotafmt_test.c
@@ -57,6 +57,8 @@
 
 #include "lustre_quota_fmt.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 char *test_quotafile[2] = { "usrquota_test", "grpquota_test" };
 
 static int quotfmt_initialize(struct lustre_quota_info *lqi,
@@ -543,3 +545,5 @@ MODULE_LICENSE("GPL");
 
 module_init(quotfmt_test_init);
 module_exit(quotfmt_test_exit);
+
+#endif /* HAVE_QUOTA_SUPPORT */
diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c
index 8d6877554904c1a0996be8630fa330ed0c300e27..815da94877fb39fc99bae2429382645d275fc9cb 100644
--- a/lustre/mds/mds_lov.c
+++ b/lustre/mds/mds_lov.c
@@ -1055,9 +1055,11 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
         case OBD_NOTIFY_CONFIG:
                 mds_allow_cli(obd, (unsigned long)data);
 
+#ifdef HAVE_QUOTA_SUPPORT
                 /* quota_type has been processed, we can now handle
                  * incoming quota requests */
                 obd->u.obt.obt_qctxt.lqc_setup = 1;
+#endif
         default:
                 RETURN(0);
         }
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index 861e36d0cf3ac0063ad1dedf0a19bba825ffcb58..f15c5da3fdff1204beaf82c4ee89c700aac241ac 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -2578,7 +2578,6 @@ static int osc_queue_async_io(struct obd_export *exp, struct lov_stripe_md *lsm,
                 RETURN(-EBUSY);
 
         /* check if the file's owner/group is over quota */
-#ifdef HAVE_QUOTA_SUPPORT
         if ((cmd & OBD_BRW_WRITE) && !(cmd & OBD_BRW_NOQUOTA)){
                 struct obd_async_page_ops *ops;
                 struct obdo *oa;
@@ -2597,7 +2596,6 @@ static int osc_queue_async_io(struct obd_export *exp, struct lov_stripe_md *lsm,
                 if (rc)
                         RETURN(rc);
         }
-#endif
 
         if (loi == NULL)
                 loi = lsm->lsm_oinfo[0];
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index b5fa0cd3583d39cf51f77ce34ef832d27bd0e8d8..839180f5c22cb0971ca67a255b7701ee1e6b9058 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -1489,6 +1489,7 @@ int ost_msg_check_version(struct lustre_msg *msg)
         case OST_QUOTACHECK:
         case OST_QUOTACTL:
         case OST_QUOTA_ADJUST_QUNIT:
+#endif
                 rc = lustre_msg_check_version(msg, LUSTRE_OST_VERSION);
                 if (rc)
                         CERROR("bad opc %u version %08x, expecting %08x\n",
@@ -1496,7 +1497,6 @@ 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:
diff --git a/lustre/quota/lproc_quota.c b/lustre/quota/lproc_quota.c
index b1d82de8928efa8bf1b51608cafd1fdf6b2f789b..922f2d48cdef887b924beaadc62f4ac3d6515f7f 100644
--- a/lustre/quota/lproc_quota.c
+++ b/lustre/quota/lproc_quota.c
@@ -44,6 +44,8 @@
 
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 #ifdef LPROCFS
 int lprocfs_quota_rd_bunit(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
@@ -733,3 +735,4 @@ int lquota_proc_cleanup(struct lustre_quota_ctxt *qctxt)
 }
 
 #endif  /* LPROCFS */
+#endif
diff --git a/lustre/quota/quota_adjust_qunit.c b/lustre/quota/quota_adjust_qunit.c
index 206cb4508bc4ee9e65068e1be30a7d26957be1ae..2cf06390e062254d24ce6835d3eac90b40b1feea 100644
--- a/lustre/quota/quota_adjust_qunit.c
+++ b/lustre/quota/quota_adjust_qunit.c
@@ -67,6 +67,8 @@
 #include <class_hash.h>
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 #ifdef __KERNEL__
 /* this function is charge of recording lqs_ino_rec and
  * lqs_blk_rec. when a lquota slave checks a quota
@@ -346,6 +348,7 @@ int filter_quota_adjust_qunit(struct obd_export *exp,
         RETURN(rc);
 }
 #endif /* __KERNEL__ */
+#endif
 
 int client_quota_adjust_qunit(struct obd_export *exp,
                               struct quota_adjust_qunit *oqaq,
diff --git a/lustre/quota/quota_check.c b/lustre/quota/quota_check.c
index 468391aa6d6c01dbb25b59fd4efbd5aa05753c04..edc70f331e28b5a0a9db89e755bb1efbf87c60a5 100644
--- a/lustre/quota/quota_check.c
+++ b/lustre/quota/quota_check.c
@@ -33,6 +33,8 @@
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
+
+
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -63,6 +65,7 @@
 #include <lustre_quota.h>
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
 #ifdef __KERNEL__
 static int target_quotacheck_callback(struct obd_export *exp,
                                       struct obd_quotactl *oqctl)
@@ -168,6 +171,7 @@ out:
 }
 
 #endif /* __KERNEL__ */
+#endif /* HAVE_QUOTA_SUPPORT */
 
 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl)
 {
diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c
index 7e05d4324b86d2c8046f172628357bf92c5cb351..0e9eb8082b96b6e1516f454a95ce05126413693e 100644
--- a/lustre/quota/quota_context.c
+++ b/lustre/quota/quota_context.c
@@ -61,6 +61,8 @@
 #include <lprocfs_status.h>
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 static lustre_hash_ops_t lqs_hash_ops;
 
 unsigned long default_bunit_sz = 128 * 1024 * 1024; /* 128M bytes */
@@ -1321,6 +1323,7 @@ exit:
         EXIT;
 }
 
+
 /*
  * lqs<->qctxt hash operations
  */
@@ -1415,3 +1418,4 @@ static lustre_hash_ops_t lqs_hash_ops = {
         .lh_put     = lqs_put,
         .lh_exit    = lqs_exit
 };
+#endif /* HAVE_QUOTA_SUPPORT */
diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c
index fb060786c2e25af3233024e23fcf14cd6be8bc3f..900f1ce3dd3175cfc57f812c9500eefadaccd1ef 100644
--- a/lustre/quota/quota_ctl.c
+++ b/lustre/quota/quota_ctl.c
@@ -66,6 +66,7 @@
 #include <lustre_quota.h>
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
 #ifdef __KERNEL__
 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
 {
@@ -253,6 +254,7 @@ adjust:
         RETURN(rc);
 }
 #endif /* __KERNEL__ */
+#endif
 
 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
 {
@@ -310,9 +312,12 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
         int i, rc = 0;
         ENTRY;
 
-        if (oqctl->qc_cmd != Q_QUOTAON && oqctl->qc_cmd != Q_QUOTAOFF &&
-            oqctl->qc_cmd != Q_GETOQUOTA && oqctl->qc_cmd != Q_INITQUOTA &&
-            oqctl->qc_cmd != Q_SETQUOTA && oqctl->qc_cmd != Q_FINVALIDATE) {
+        if (oqctl->qc_cmd != LUSTRE_Q_QUOTAON &&
+            oqctl->qc_cmd != LUSTRE_Q_QUOTAOFF &&
+            oqctl->qc_cmd != Q_GETOQUOTA &&
+            oqctl->qc_cmd != Q_INITQUOTA &&
+            oqctl->qc_cmd != LUSTRE_Q_SETQUOTA &&
+            oqctl->qc_cmd != Q_FINVALIDATE) {
                 CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd);
                 RETURN(-EFAULT);
         }
diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c
index 1ec25e38f1002d1c8bfd34ce72b36f234008cac8..6bbb8bc21a500581865e9006af6a5038c3cb6718 100644
--- a/lustre/quota/quota_interface.c
+++ b/lustre/quota/quota_interface.c
@@ -69,6 +69,8 @@
 
 #ifdef __KERNEL__
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 static cfs_time_t last_print = 0;
 static spinlock_t last_print_lock = SPIN_LOCK_UNLOCKED;
 
@@ -579,6 +581,7 @@ static int mds_quota_pending_commit(struct obd_device *obd, unsigned int uid,
 {
         return quota_pending_commit(obd, uid, gid, inodes, 0);
 }
+#endif /* HAVE_QUOTA_SUPPORT */
 #endif /* __KERNEL__ */
 
 struct osc_quota_info {
@@ -790,6 +793,7 @@ int osc_quota_exit(void)
 }
 
 #ifdef __KERNEL__
+#ifdef HAVE_QUOTA_SUPPORT
 quota_interface_t mds_quota_interface = {
         .quota_init     = mds_quota_init,
         .quota_exit     = mds_quota_exit,
@@ -820,6 +824,7 @@ quota_interface_t filter_quota_interface = {
         .quota_adjust_qunit   = filter_quota_adjust_qunit,
         .quota_pending_commit = filter_quota_pending_commit,
 };
+#endif
 #endif /* __KERNEL__ */
 
 quota_interface_t mdc_quota_interface = {
@@ -852,6 +857,7 @@ cfs_proc_dir_entry_t *lquota_type_proc_dir = NULL;
 
 static int __init init_lustre_quota(void)
 {
+#ifdef HAVE_QUOTA_SUPPORT
         int rc = 0;
 
         lquota_type_proc_dir = lprocfs_register(OBD_LQUOTA_DEVICENAME,
@@ -866,8 +872,10 @@ static int __init init_lustre_quota(void)
         rc = qunit_cache_init();
         if (rc)
                 return rc;
+
         PORTAL_SYMBOL_REGISTER(filter_quota_interface);
         PORTAL_SYMBOL_REGISTER(mds_quota_interface);
+#endif
         PORTAL_SYMBOL_REGISTER(mdc_quota_interface);
         PORTAL_SYMBOL_REGISTER(osc_quota_interface);
         PORTAL_SYMBOL_REGISTER(lov_quota_interface);
@@ -876,16 +884,18 @@ static int __init init_lustre_quota(void)
 
 static void /*__exit*/ exit_lustre_quota(void)
 {
-        PORTAL_SYMBOL_UNREGISTER(filter_quota_interface);
-        PORTAL_SYMBOL_UNREGISTER(mds_quota_interface);
         PORTAL_SYMBOL_UNREGISTER(mdc_quota_interface);
         PORTAL_SYMBOL_UNREGISTER(osc_quota_interface);
         PORTAL_SYMBOL_UNREGISTER(lov_quota_interface);
+#ifdef HAVE_QUOTA_SUPPORT
+        PORTAL_SYMBOL_UNREGISTER(filter_quota_interface);
+        PORTAL_SYMBOL_UNREGISTER(mds_quota_interface);
 
         qunit_cache_cleanup();
 
         if (lquota_type_proc_dir)
                 lprocfs_remove(&lquota_type_proc_dir);
+#endif
 }
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
@@ -894,8 +904,10 @@ MODULE_LICENSE("GPL");
 
 cfs_module(lquota, "1.0.0", init_lustre_quota, exit_lustre_quota);
 
+#ifdef HAVE_QUOTA_SUPPORT
 EXPORT_SYMBOL(mds_quota_interface);
 EXPORT_SYMBOL(filter_quota_interface);
+#endif
 EXPORT_SYMBOL(mdc_quota_interface);
 EXPORT_SYMBOL(osc_quota_interface);
 EXPORT_SYMBOL(lov_quota_interface);
diff --git a/lustre/quota/quota_internal.h b/lustre/quota/quota_internal.h
index a357cbf167fcce8226bd363a832e19c8f3fa78a0..fe99c9a598805c9b9414d71f899e263ef6ee77ff 100644
--- a/lustre/quota/quota_internal.h
+++ b/lustre/quota/quota_internal.h
@@ -39,6 +39,8 @@
 
 #include <lustre_quota.h>
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 /* QUSG covnert bytes to blocks when counting block quota */
 #define QUSG(count, isblk)      (isblk ? toqb(count) : count)
 
@@ -143,14 +145,9 @@ int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt, struct lustre_dquot
 /* quota_ctl.c */
 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
-int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
-int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
 
 /* quota_chk.c */
 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
-int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
-int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
-int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
 
 #ifdef LPROCFS
 void lprocfs_quotactl_test_init_vars(struct lprocfs_static_vars *lvars);
@@ -168,13 +165,6 @@ static inline void lprocfs_quotacheck_test_init_vars
 }
 #endif
 
-/* quota_adjust_qunit.c */
-int client_quota_adjust_qunit(struct obd_export *exp,
-                              struct quota_adjust_qunit *oqaq,
-                              struct lustre_quota_ctxt *qctxt);
-int lov_quota_adjust_qunit(struct obd_export *exp,
-                           struct quota_adjust_qunit *oqaq,
-                           struct lustre_quota_ctxt *qctxt);
 int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq, struct
                           lustre_quota_ctxt *qctxt);
 void qdata_to_oqaq(struct qunit_data *qdata,
@@ -212,3 +202,15 @@ extern cfs_proc_dir_entry_t *lquota_type_proc_dir;
 
 
 #endif
+int client_quota_adjust_qunit(struct obd_export *exp,
+                              struct quota_adjust_qunit *oqaq,
+                              struct lustre_quota_ctxt *qctxt);
+int lov_quota_adjust_qunit(struct obd_export *exp,
+                           struct quota_adjust_qunit *oqaq,
+                           struct lustre_quota_ctxt *qctxt);
+int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
+int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
+int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
+int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
+int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
+#endif
diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c
index 10c994b0903fc5360354f81d04228be52ee879b8..ea71dcbecc2be3bb056254ff5d3af1c4e502e7a8 100644
--- a/lustre/quota/quota_master.c
+++ b/lustre/quota/quota_master.c
@@ -62,6 +62,8 @@
 
 #include "quota_internal.h"
 
+#ifdef HAVE_QUOTA_SUPPORT
+
 /* lock ordering: mds->mds_qonoff_sem > dquot->dq_sem */
 static struct list_head lustre_dquot_hash[NR_DQHASH];
 static spinlock_t dquot_hash_lock = SPIN_LOCK_UNLOCKED;
@@ -1653,3 +1655,5 @@ int mds_quota_recovery(struct obd_device *obd)
         wait_for_completion(&data.comp);
         RETURN(rc);
 }
+
+#endif /* HAVE_QUOTA_SUPPORT */