--- e2fsck/e2fsck.h
+++ e2fsck/e2fsck.h
@@ -67,7 +67,9 @@
 #define E2FSCK_ATTR(x)
 #endif
 
+#ifdef CONFIG_QUOTA
 #include "quota/quotaio.h"
+#endif
 
 /*
  * Exit codes used by fsck-type programs
@@ -319,10 +321,12 @@
 	io_channel	journal_io;
 	char	*journal_name;
 
+#ifdef CONFIG_QUOTA
 	/*
 	 * Ext4 quota support
 	 */
 	quota_ctx_t qctx;
+#endif
 #ifdef RESOURCE_TRACK
 	/*
 	 * For timing purposes
@@ -464,8 +468,10 @@
 /* logfile.c */
 extern void set_up_logging(e2fsck_t ctx);
 
+#ifdef CONFIG_QUOTA
 /* quota.c */
 extern void e2fsck_hide_quota(e2fsck_t ctx);
+#endif
 
 /* pass1.c */
 extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
--- e2fsck/Makefile.in
+++ e2fsck/Makefile.in
@@ -11,6 +11,13 @@
 
 @MCONFIG@
 
+DEPLIBQUOTA:=
+DEPPROFILED_LIBQUOTA:=
+DEPSTATIC_LIBQUOTA:=
+LIBQUOTA:=
+PROFILED_LIBQUOTA:=
+STATIC_LIBQUOTA:=
+
 PROGS=		e2fsck
 MANPAGES=	e2fsck.8
 FMANPAGES=	e2fsck.conf.5
--- e2fsck/pass1b.c
+++ e2fsck/pass1b.c
@@ -659,9 +659,11 @@
 	if (ctx->inode_bad_map)
 		ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino);
 	ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(dp->inode.i_mode));
+#ifdef CONFIG_QUOTA
 	quota_data_sub(ctx->qctx, &dp->inode, ino,
 		       pb.dup_blocks * fs->blocksize);
 	quota_data_inodes(ctx->qctx, &dp->inode, ino, -1);
+#endif
 
 	/* Inode may have changed by block_iterate, so reread it */
 	e2fsck_read_inode(ctx, ino, &dp->inode, "delete_file");
@@ -693,7 +695,9 @@
 			delete_file_block(fs, &blk,
 					  BLOCK_COUNT_EXTATTR, 0, 0, &pb);
 			ext2fs_file_acl_block_set(fs, &dp->inode, blk);
+#ifdef CONFIG_QUOTA
 			quota_data_sub(ctx->qctx, &dp->inode, ino, fs->blocksize);
+#endif
 		}
 	}
 }
--- e2fsck/pass1.c
+++ e2fsck/pass1.c
@@ -957,6 +957,7 @@
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
 			}
+#ifdef CONFIG_QUOTA
 		} else if ((ino == EXT4_USR_QUOTA_INO) ||
 			   (ino == EXT4_GRP_QUOTA_INO)) {
 			ext2fs_mark_inode_bitmap2(ctx->inode_used_map, ino);
@@ -984,6 +985,7 @@
 				e2fsck_write_inode_full(ctx, ino, inode,
 							inode_size, "pass1");
 			}
+#endif
 		} else if (ino < EXT2_FIRST_INODE(fs->super)) {
 			problem_t problem = 0;
 
@@ -2293,9 +2295,11 @@
 	}
 
 	if (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super)) {
+#ifdef CONFIG_QUOTA
 		quota_data_add(ctx->qctx, inode, ino,
 			       pb.num_blocks * fs->blocksize);
 		quota_data_inodes(ctx->qctx, inode, ino, +1);
+#endif
 	}
 
 	if (!(fs->super->s_feature_ro_compat &
--- e2fsck/pass3.c
+++ e2fsck/pass3.c
@@ -514,8 +514,10 @@
 	ext2fs_icount_store(ctx->inode_count, ino, 2);
 	ext2fs_icount_store(ctx->inode_link_info, ino, 2);
 	ctx->lost_and_found = ino;
+#ifdef CONFIG_QUOTA
 	quota_data_add(ctx->qctx, &inode, ino, fs->blocksize);
 	quota_data_inodes(ctx->qctx, &inode, ino, +1);
+#endif
 #if 0
 	printf("/lost+found created; inode #%lu\n", ino);
 #endif
@@ -831,7 +833,9 @@
 	if (retval)
 		return retval;
 	ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
+#ifdef CONFIG_QUOTA
 	quota_data_add(ctx->qctx, &inode, dir, es.newblocks * fs->blocksize);
+#endif
 
 	e2fsck_write_inode(ctx, dir, &inode, "expand_directory");
 
--- e2fsck/pass4.c
+++ e2fsck/pass4.c
@@ -64,7 +64,9 @@
 			e2fsck_read_bitmaps(ctx);
 			ext2fs_inode_alloc_stats2(fs, i, -1,
 						  LINUX_S_ISDIR(inode->i_mode));
+#ifdef CONFIG_QUOTA
 			quota_data_inodes(ctx->qctx, inode, i, -1);
+#endif
 			return 0;
 		}
 	}
--- e2fsck/problem.c
+++ e2fsck/problem.c
@@ -410,10 +410,12 @@
 	  N_("Setting free @bs count to %c (was %b)\n"),
 	  PROMPT_NONE, PR_PREEN_NOMSG },
 
+#ifdef CONFIG_QUOTA
 	/* Making quota file hidden */
 	{ PR_0_HIDE_QUOTA,
 	  N_("Making @q @i %i (%Q) hidden.\n"),
 	  PROMPT_NONE, PR_PREEN_OK },
+#endif
 
 	/* Superblock has invalid MMP block. */
 	{ PR_0_MMP_INVALID_BLK,
@@ -933,20 +935,26 @@
 	  N_("Error converting subcluster @b @B: %m\n"),
 	  PROMPT_NONE, PR_FATAL },
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode has bad mode */
 	{ PR_1_QUOTA_BAD_MODE,
 	  N_("@q @i is not regular file.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode is not in use, but contains data */
 	{ PR_1_QUOTA_INODE_NOT_CLEAR,
 	  N_("@q @i is not in use, but contains data.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
+#ifdef CONFIG_QUOTA
 	/* Quota inode is user visible */
 	{ PR_1_QUOTA_INODE_NOT_HIDDEN,
 	  N_("@q @i is visible to the user.  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
+#endif
 
 	/* Invalid bad inode */
 	{ PR_1_INVALID_BAD_INODE,
@@ -1732,10 +1740,12 @@
 	  N_("Recreate @j"),
 	  PROMPT_NULL, PR_PREEN_OK | PR_NO_OK },
 
+#ifdef CONFIG_QUOTA
 	/* Update quota information if it is inconsistent */
 	{ PR_6_UPDATE_QUOTAS,
 	  N_("Update quota info for quota type %N"),
 	  PROMPT_NULL, PR_PREEN_OK },
+#endif
 
 	/* Error setting block group checksum info */
 	{ PR_6_SET_BG_CHECKSUM,
--- e2fsck/problem.h
+++ e2fsck/problem.h
@@ -234,8 +234,10 @@
 /* Free blocks count wrong */
 #define PR_0_FREE_BLOCK_COUNT			0x000040
 
+#ifdef CONFIG_QUOTA
 /* Make quota file hidden */
 #define	PR_0_HIDE_QUOTA				0x000041
+#endif
 
 /* Superblock has invalid MMP block. */
 #define PR_0_MMP_INVALID_BLK			0x000042
@@ -549,14 +551,20 @@
 /* Failed to convert subcluster bitmap */
 #define PR_1_CONVERT_SUBCLUSTER		0x010061
 
+#ifdef CONFIG_QUOTA
 /* Quota inode has wrong mode */
 #define PR_1_QUOTA_BAD_MODE		0x010062
+#endif
 
+#ifdef CONFIG_QUOTA
 /* Quota inode is not in use, but contains data */
 #define PR_1_QUOTA_INODE_NOT_CLEAR	0x010063
+#endif
 
+#ifdef CONFIG_QUOTA
 /* Quota inode is user visible */
 #define PR_1_QUOTA_INODE_NOT_HIDDEN	0x010064
+#endif
 
 /* Invalid bad inode */
 #define PR_1_INVALID_BAD_INODE		0x010065
@@ -1056,8 +1064,10 @@
 /* Recreate the journal if E2F_FLAG_JOURNAL_INODE flag is set */
 #define PR_6_RECREATE_JOURNAL		0x060001
 
+#ifdef CONFIG_QUOTA
 /* Update quota information if it is inconsistent */
 #define PR_6_UPDATE_QUOTAS		0x060002
+#endif
 
 /* Error setting block group checksum info */
 #define PR_6_SET_BG_CHECKSUM		0x060003
--- e2fsck/quota.c
+++ e2fsck/quota.c
@@ -4,6 +4,7 @@
  */
 
 #include "config.h"
+#ifdef CONFIG_QUOTA
 #ifdef HAVE_SYS_MOUNT_H
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -90,3 +91,4 @@
 
 	return;
 }
+#endif
--- e2fsck/super.c
+++ e2fsck/super.c
@@ -879,10 +879,12 @@
 	 */
 	e2fsck_fix_dirhash_hint(ctx);
 
+#ifdef CONFIG_QUOTA
 	/*
 	 * Hide quota inodes if necessary.
 	 */
 	e2fsck_hide_quota(ctx);
+#endif
 
 	return;
 }
--- e2fsck/unix.c
+++ e2fsck/unix.c
@@ -1622,6 +1622,7 @@
 	else
 		journal_size = -1;
 
+#ifdef CONFIG_QUOTA
 	if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA) {
 		/* Quotas were enabled. Do quota accounting during fsck. */
 		if ((sb->s_usr_quota_inum && sb->s_grp_quota_inum) ||
@@ -1632,6 +1633,7 @@
 
 		quota_init_context(&ctx->qctx, ctx->fs, qtype);
 	}
+#endif
 
 	run_result = e2fsck_run(ctx);
 	e2fsck_clear_progbar(ctx);
@@ -1667,6 +1669,7 @@
 	}
 no_journal:
 
+#ifdef CONFIG_QUOTA
 	if (ctx->qctx) {
 		int i, needs_writeout;
 		for (i = 0; i < MAXQUOTAS; i++) {
@@ -1682,6 +1685,7 @@
 		}
 		quota_release_context(&ctx->qctx);
 	}
+#endif
 
 	if (run_result == E2F_FLAG_RESTART) {
 		log_out(ctx, "%s",
--- misc/Makefile.in
+++ misc/Makefile.in
@@ -11,6 +11,13 @@
 
 @MCONFIG@
 
+DEPLIBQUOTA:=
+DEPPROFILED_LIBQUOTA:=
+DEPSTATIC_LIBQUOTA:=
+LIBQUOTA:=
+PROFILED_LIBQUOTA:=
+STATIC_LIBQUOTA:=
+
 @DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_PROG= e4defrag
 @DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_MAN= e4defrag.8
 
--- misc/mke2fs.c
+++ misc/mke2fs.c
@@ -62,7 +62,9 @@
 #include "prof_err.h"
 #include "../version.h"
 #include "nls-enable.h"
+#ifdef CONFIG_QUOTA
 #include "quota/quotaio.h"
+#endif
 #include "mke2fs.h"
 
 #define STRIDE_LENGTH 8
@@ -99,7 +101,9 @@
 static int	packed_meta_blocks;
 static char	*bad_blocks_filename = NULL;
 static __u32	fs_stride;
+#ifdef CONFIG_QUOTA
 static int	quotatype = -1;  /* Initialize both user and group quotas by default */
+#endif
 static __u64	offset;
 static blk64_t journal_location = ~0LL;
 static int	proceed_delay = -1;
@@ -963,6 +967,7 @@
 			discard = 1;
 		} else if (!strcmp(token, "nodiscard")) {
 			discard = 0;
+#ifdef CONFIG_QUOTA
 		} else if (!strcmp(token, "quotatype")) {
 			if (!arg) {
 				r_usage++;
@@ -980,6 +985,7 @@
 				r_usage++;
 				continue;
 			}
+#endif
 		} else {
 			r_usage++;
 			badopt = token;
@@ -1005,7 +1011,11 @@
 			"\ttest_fs\n"
 			"\tdiscard\n"
 			"\tnodiscard\n"
-			"\tquotatype=<usr OR grp>\n\n"),
+#ifdef CONFIG_QUOTA
+			"\tquotatype=<usr OR grp>\n"
+#endif
+			"\n"
+			),
 			badopt ? badopt : "");
 		free(buf);
 		exit(1);
@@ -2522,6 +2532,7 @@
 	ext2fs_free_blocks_count_set(fs->super, tot_free);
 }
 
+#ifdef CONFIG_QUOTA
 static int create_quota_inodes(ext2_filsys fs)
 {
 	quota_ctx_t qctx;
@@ -2533,6 +2544,7 @@
 
 	return 0;
 }
+#endif
 
 int main (int argc, char *argv[])
 {
@@ -2911,9 +2923,11 @@
 	if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
 				       EXT4_FEATURE_RO_COMPAT_BIGALLOC))
 		fix_cluster_bg_counts(fs);
+#ifdef CONFIG_QUOTA
 	if (EXT2_HAS_RO_COMPAT_FEATURE(&fs_param,
 				       EXT4_FEATURE_RO_COMPAT_QUOTA))
 		create_quota_inodes(fs);
+#endif
 
 	retval = mk_hugefiles(fs, device_name);
 	if (retval)
--- misc/tune2fs.c
+++ misc/tune2fs.c
@@ -60,7 +60,9 @@
 #include "jfs_user.h"
 #include "util.h"
 #include "blkid/blkid.h"
+#ifdef CONFIG_QUOTA
 #include "quota/quotaio.h"
+#endif
 
 #include "../version.h"
 #include "nls-enable.h"
@@ -75,7 +77,11 @@
 char *new_label, *new_last_mounted, *new_UUID;
 char *io_options;
 static int c_flag, C_flag, e_flag, f_flag, g_flag, i_flag, l_flag, L_flag;
-static int m_flag, M_flag, Q_flag, r_flag, s_flag = -1, u_flag, U_flag, T_flag;
+static int m_flag, M_flag,
+#ifdef CONFIG_QUOTA
+Q_flag,
+#endif
+r_flag, s_flag = -1, u_flag, U_flag, T_flag;
 static int I_flag;
 static int clear_mmp;
 static time_t last_check_time;
@@ -94,7 +100,9 @@
 static char *extended_cmd;
 static unsigned long new_inode_size;
 static char *ext_mount_opts;
+#ifdef CONFIG_QUOTA
 static int usrquota, grpquota;
+#endif
 
 int journal_size, journal_flags;
 char *journal_device;
@@ -635,6 +643,7 @@
 		fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
 	}
 
+#ifdef CONFIG_QUOTA
 	if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
 				EXT4_FEATURE_RO_COMPAT_QUOTA)) {
 		/*
@@ -664,6 +673,7 @@
 		usrquota = QOPT_DISABLE;
 		grpquota = QOPT_DISABLE;
 	}
+#endif
 
 	if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
 	    (sb->s_feature_compat || sb->s_feature_ro_compat ||
@@ -774,6 +784,7 @@
 	return 1;
 }
 
+#ifdef CONFIG_QUOTA
 static void handle_quota_options(ext2_filsys fs)
 {
 	quota_ctx_t qctx;
@@ -819,6 +830,7 @@
 
 	return;
 }
+#endif
 
 #ifdef CONFIG_QUOTA
 static void parse_quota_opts(const char *opts)
@@ -2266,6 +2278,7 @@
 			goto closefs;
 	}
 
+#ifdef CONFIG_QUOTA
 	if (Q_flag) {
 		if (mount_flags & EXT2_MF_MOUNTED) {
 			fputs(_("The quota feature may only be changed when "
@@ -2275,6 +2288,7 @@
 		}
 		handle_quota_options(fs);
 	}
+#endif
 
 	if (U_flag) {
 		int set_csum = 0;
