From 355ffb2ff566229b8bc3f5f7557e91edff5a767a Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Sun, 13 Oct 2013 22:07:57 -0400 Subject: [PATCH 1/6] debugfs.c: the max length of debugfs argument is too short The max length of debugfs argument is 256 which is too short, the arguments are two paths, the PATH_MAX is 4096 according to /usr/include/linux/limits.h, so use BUFSIZ (which is 8192 on Linux systems), that's also what the ss library uses. Signed-off-by: Robert Yang Acked-by: Darren Hart Signed-off-by: Theodore Ts'o --- debugfs/debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index cf559df1..4f190259 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -37,6 +37,10 @@ extern char *optarg; #include "../version.h" #include "jfs_user.h" +#ifndef BUFSIZ +#define BUFSIZ 8192 +#endif + ss_request_table *extra_cmds; const char *debug_prog_name; int sci_idx; @@ -2293,7 +2297,7 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[]) static int source_file(const char *cmd_file, int ss_idx) { FILE *f; - char buf[256]; + char buf[BUFSIZ]; char *cp; int exit_status = 0; int retval; From c756ec4217dcc045f70f49f2a758ba301b057e55 Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Sun, 13 Oct 2013 22:08:40 -0400 Subject: [PATCH 2/6] debugfs.c: do sparse copy when src is a sparse file Let debugfs do sparse copy when src is a sparse file, just like "cp --sparse=auto" * For the: #define IO_BUFSIZE 64*1024 this is a suggested value from gnu coreutils: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/ioblksize.h;h=1ae93255e7d0ccf0855208c7ae5888209997bf16;hb=HEAD * Use malloc() to allocate memory for the buffer since put 64K (or more) on the stack seems not a good idea. Signed-off-by: Robert Yang Acked-by: Darren Hart Signed-off-by: Theodore Ts'o --- debugfs/debugfs.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 4f190259..55902951 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -41,6 +41,16 @@ extern char *optarg; #define BUFSIZ 8192 #endif +/* 64KiB is the minimium blksize to best minimize system call overhead. */ +#ifndef IO_BUFSIZE +#define IO_BUFSIZE 64*1024 +#endif + +/* Block size for `st_blocks' */ +#ifndef S_BLKSIZE +#define S_BLKSIZE 512 +#endif + ss_request_table *extra_cmds; const char *debug_prog_name; int sci_idx; @@ -1563,22 +1573,37 @@ void do_find_free_inode(int argc, char *argv[]) } #ifndef READ_ONLY -static errcode_t copy_file(int fd, ext2_ino_t newfile) +static errcode_t copy_file(int fd, ext2_ino_t newfile, int bufsize, int make_holes) { ext2_file_t e2_file; errcode_t retval; int got; unsigned int written; - char buf[8192]; + char *buf; char *ptr; + char *zero_buf; + int cmp; retval = ext2fs_file_open(current_fs, newfile, EXT2_FILE_WRITE, &e2_file); if (retval) return retval; + if (!(buf = (char *) malloc(bufsize))){ + com_err("copy_file", errno, "can't allocate buffer\n"); + return; + } + + /* This is used for checking whether the whole block is zero */ + retval = ext2fs_get_memzero(bufsize, &zero_buf); + if (retval) { + com_err("copy_file", retval, "can't allocate buffer\n"); + free(buf); + return retval; + } + while (1) { - got = read(fd, buf, sizeof(buf)); + got = read(fd, buf, bufsize); if (got == 0) break; if (got < 0) { @@ -1586,6 +1611,21 @@ static errcode_t copy_file(int fd, ext2_ino_t newfile) goto fail; } ptr = buf; + + /* Sparse copy */ + if (make_holes) { + /* Check whether all is zero */ + cmp = memcmp(ptr, zero_buf, got); + if (cmp == 0) { + /* The whole block is zero, make a hole */ + retval = ext2fs_file_lseek(e2_file, got, EXT2_SEEK_CUR, NULL); + if (retval) + goto fail; + got = 0; + } + } + + /* Normal copy */ while (got > 0) { retval = ext2fs_file_write(e2_file, ptr, got, &written); @@ -1596,10 +1636,14 @@ static errcode_t copy_file(int fd, ext2_ino_t newfile) ptr += written; } } + free(buf); + ext2fs_free_mem(&zero_buf); retval = ext2fs_file_close(e2_file); return retval; fail: + free(buf); + ext2fs_free_mem(&zero_buf); (void) ext2fs_file_close(e2_file); return retval; } @@ -1612,6 +1656,8 @@ void do_write(int argc, char *argv[]) ext2_ino_t newfile; errcode_t retval; struct ext2_inode inode; + int bufsize = IO_BUFSIZE; + int make_holes = 0; if (common_args_process(argc, argv, 3, 3, "write", " ", CHECK_FS_RW)) @@ -1687,7 +1733,15 @@ void do_write(int argc, char *argv[]) return; } if (LINUX_S_ISREG(inode.i_mode)) { - retval = copy_file(fd, newfile); + if (statbuf.st_blocks < statbuf.st_size / S_BLKSIZE) { + make_holes = 1; + /* + * Use I/O blocksize as buffer size when + * copying sparse files. + */ + bufsize = statbuf.st_blksize; + } + retval = copy_file(fd, newfile, bufsize, make_holes); if (retval) com_err("copy_file", retval, 0); } From 76d84ffceb24fa4f9323b18d350e31357f3b981c Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Sun, 13 Oct 2013 22:09:12 -0400 Subject: [PATCH 3/6] contrib/populate-extfs.sh: use debugfs to populate extX fs This script uses debugfs command to populate the ext2/3/4 filesystem from a given directory, it is a little similar to genext2fs, but this one fully supports ext3 and ext4. Signed-off-by: Robert Yang Acked-by: Darren Hart Signed-off-by: Theodore Ts'o --- contrib/populate-extfs.sh | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 contrib/populate-extfs.sh diff --git a/contrib/populate-extfs.sh b/contrib/populate-extfs.sh new file mode 100755 index 00000000..b1d3d1f8 --- /dev/null +++ b/contrib/populate-extfs.sh @@ -0,0 +1,105 @@ +#!/bin/sh +# +# This script uses debugfs command to populate the ext2/3/4 filesystem +# from a given directory. +# + +do_usage () { + cat << _EOF +Usage: populate-extfs.sh +Create an ext2/ext3/ext4 filesystem from a directory or file + + source: The source directory or file + device: The target device + +_EOF + exit 1 +} + +[ $# -ne 2 ] && do_usage + +SRCDIR=${1%%/} +DEVICE=$2 + +# Find where is the debugfs command if not found in the env. +if [ -z "$DEBUGFS" ]; then + CONTRIB_DIR=$(dirname $(readlink -f $0)) + DEBUGFS="$CONTRIB_DIR/../debugfs/debugfs" +fi + +{ + CWD="/" + find $SRCDIR | while read FILE; do + TGT="${FILE##*/}" + DIR="${FILE#$SRCDIR}" + DIR="${DIR%$TGT}" + + # Skip the root dir + [ ! -z "$DIR" ] || continue + [ ! -z "$TGT" ] || continue + + if [ "$DIR" != "$CWD" ]; then + echo "cd $DIR" + CWD="$DIR" + fi + + # Only stat once since stat is a time consuming command + STAT=$(stat -c "TYPE=\"%F\";DEVNO=\"0x%t 0x%T\";MODE=\"%f\";U=\"%u\";G=\"%g\"" $FILE) + eval $STAT + + case $TYPE in + "directory") + echo "mkdir $TGT" + ;; + "regular file" | "regular empty file") + echo "write $FILE $TGT" + ;; + "symbolic link") + LINK_TGT=$(readlink $FILE) + echo "symlink $TGT $LINK_TGT" + ;; + "block special file") + echo "mknod $TGT b $DEVNO" + ;; + "character special file") + echo "mknod $TGT c $DEVNO" + ;; + "fifo") + echo "mknod $TGT p" + ;; + *) + echo "Unknown/unhandled file type '$TYPE' file: $FILE" 1>&2 + ;; + esac + + # Set the file mode + echo "sif $TGT mode 0x$MODE" + + # Set uid and gid + echo "sif $TGT uid $U" + echo "sif $TGT gid $G" + done + + # Handle the hard links. + # Save the hard links to a file, use the inode number as the filename, for example: + # If a and b's inode number is 6775928, save a and b to /tmp/tmp.VrCwHh5gdt/6775928. + INODE_DIR=`mktemp -d` || exit 1 + for i in `find $SRCDIR -type f -links +1 -printf 'INODE=%i###FN=%p\n'`; do + eval `echo $i | sed 's$###$ $'` + echo ${FN#$SRCDIR} >>$INODE_DIR/$INODE + done + # Use the debugfs' ln and "sif links_count" to handle them. + for i in `ls $INODE_DIR`; do + # The link source + SRC=`head -1 $INODE_DIR/$i` + # Remove the files and link them again except the first one + for TGT in `sed -n -e '1!p' $INODE_DIR/$i`; do + echo "rm $TGT" + echo "ln $SRC $TGT" + done + LN_CNT=`cat $INODE_DIR/$i | wc -l` + # Set the links count + echo "sif $SRC links_count $LN_CNT" + done + rm -fr $INODE_DIR +} | $DEBUGFS -w -f - $DEVICE From f5589f4c189a2d6b34fcd10570c496ca568e0aee Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 14 Oct 2013 08:54:15 -0400 Subject: [PATCH 4/6] mke2fs: remove quota docs if not configured in If quota isn't turned on with --enable-quota, then comment quota documentation out of the mke2fs manpage. Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- configure | 5 +++++ configure.in | 4 ++++ misc/mke2fs.8.in | 24 ++++++++++++------------ util/subst.conf.in | 2 ++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 4c47f7a8..afe381fc 100755 --- a/configure +++ b/configure @@ -715,6 +715,7 @@ DEPSTATIC_LIBQUOTA STATIC_LIBQUOTA DEPLIBQUOTA LIBQUOTA +QUOTA_MAN_COMMENT BLKID_CMT DEPPROFILED_LIBBLKID PROFILED_LIBBLKID @@ -5185,6 +5186,8 @@ fi +QUOTA_MAN_COMMENT='.\"' + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then @@ -5313,6 +5316,8 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling quota support" >&5 $as_echo "Enabling quota support" >&6; } + QUOTA_MAN_COMMENT="" + fi else diff --git a/configure.in b/configure.in index fc65b03a..f9cfd534 100644 --- a/configure.in +++ b/configure.in @@ -565,6 +565,8 @@ AC_SUBST(BLKID_CMT) dnl dnl handle --enable-quota dnl +QUOTA_MAN_COMMENT='.\"' +AC_SUBST(QUOTA_MAN_COMMENT) PKG_PROG_PKG_CONFIG AH_TEMPLATE([CONFIG_QUOTA], [Define to 1 to enable quota support]) AC_ARG_ENABLE([quota], @@ -575,6 +577,8 @@ then else AC_DEFINE(CONFIG_QUOTA, 1) AC_MSG_RESULT([Enabling quota support]) + QUOTA_MAN_COMMENT="" + AC_SUBST(QUOTA_MAN_COMMENT) fi , AC_MSG_RESULT([Disabling quota support by default]) diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index fe2dcdbd..7d2f0f70 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -291,13 +291,13 @@ as default. .TP .BI nodiscard Do not attempt to discard blocks at mkfs time. -.TP -.BI quotatype -Specify which quota type ('usr' or 'grp') is to be initialized. This -option has any effect only if -.B quota -feature is set. Without this extended option, the default behavior is to -initialize both user and group quotas. +@QUOTA_MAN_COMMENT@.TP +@QUOTA_MAN_COMMENT@.BI quotatype +@QUOTA_MAN_COMMENT@Specify which quota type ('usr' or 'grp') is to be initialized. This +@QUOTA_MAN_COMMENT@option has any effect only if +@QUOTA_MAN_COMMENT@.B quota +@QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default behavior is to +@QUOTA_MAN_COMMENT@initialize both user and group quotas. .RE .TP .BI \-f " fragment-size" @@ -590,11 +590,11 @@ option). .B large_file Filesystem can contain files that are greater than 2GB. (Modern kernels set this feature automatically when a file > 2GB is created.) -.TP -.B quota -Create quota inodes (inode# 3 for userquota and inode# 4 for group quota) and -set them in the superblock. With this feature, the quotas will be enabled -automatically when the filesystem is mounted. +@QUOTA_MAN_COMMENT@.TP +@QUOTA_MAN_COMMENT@.B quota +@QUOTA_MAN_COMMENT@Create quota inodes (inode# 3 for userquota and inode# 4 for group quota) and +@QUOTA_MAN_COMMENT@set them in the superblock. With this feature, the quotas will be enabled +@QUOTA_MAN_COMMENT@automatically when the filesystem is mounted. .TP .B resize_inode Reserve space so the block group descriptor table may grow in the future. diff --git a/util/subst.conf.in b/util/subst.conf.in index 0e074d85..64fde7ad 100644 --- a/util/subst.conf.in +++ b/util/subst.conf.in @@ -18,3 +18,5 @@ $prefix @prefix@ # Enable the documentation for the journal device mke2fs, tune2fs, and # e2fsck's man page JDEV +# Enable documentation for quota feature in mke2fs +QUOTA_MAN_COMMENT @QUOTA_MAN_COMMENT@ From d82445e903be682e09c41607ed5f7b338cb8c1b0 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Mon, 14 Oct 2013 09:03:06 -0400 Subject: [PATCH 5/6] tune2fs: more respect for quota config option Commit 44a2cca3 disabled tune2fs -O quota when the build didn't have --enable-quota at configure time, but that wasn't quite enough. We need to exclude the "-Q" option as well from tune2fs when --enable-quota isn't specified at configure time. Otherwise, tune2fs -Q can set the quota feature, but no other utility will touch the filesystem due to the unknown flag, if buitl w/o --enable-quota. So put everything related to "-Q" under #ifdef CONFIG_QUOTA; usage output (was missing before) and option parsing. Addresses-Red-Hat-Bugzilla: #1010709 Reported-by: Bert DeKnuydt Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- misc/tune2fs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 5feb25b2..822df74a 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -121,6 +121,9 @@ static void usage(void) "\t[-r reserved_blocks_count] [-u user] [-C mount_count] " "[-L volume_label]\n" "\t[-M last_mounted_dir] [-O [^]feature[,...]]\n" +#ifdef CONFIG_QUOTA + "\t[-Q quota_options]\n" +#endif "\t[-E extended-option[,...]] [-T last_check_time] " "[-U UUID]\n\t[ -I new_inode_size ] device\n"), program_name); exit(1); @@ -857,11 +860,15 @@ static void parse_tune2fs_options(int argc, char **argv) char *tmp; struct group *gr; struct passwd *pw; + char optstring[100] = "c:e:fg:i:jlm:o:r:s:u:C:E:I:J:L:M:O:T:U:"; +#ifdef CONFIG_QUOTA + strcat(optstring, "Q:"); +#endif open_flag = 0; printf("tune2fs %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE); - while ((c = getopt(argc, argv, "c:e:fg:i:jlm:o:r:s:u:C:E:I:J:L:M:O:Q:T:U:")) != EOF) + while ((c = getopt(argc, argv, optstring)) != EOF) switch (c) { case 'c': max_mount_count = strtol(optarg, &tmp, 0); @@ -1015,11 +1022,13 @@ static void parse_tune2fs_options(int argc, char **argv) features_cmd = optarg; open_flag = EXT2_FLAG_RW; break; +#ifdef CONFIG_QUOTA case 'Q': Q_flag = 1; parse_quota_opts(optarg); open_flag = EXT2_FLAG_RW; break; +#endif case 'r': reserved_blocks = strtoul(optarg, &tmp, 0); if (*tmp) { From 43075b42bdff509cc567bd870a32072edf05d04c Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Mon, 14 Oct 2013 09:49:27 -0400 Subject: [PATCH 6/6] quota: fix disabling quota, add quota tests Update all superblock copies when disabling the quota feature. Added basic tests for the quota feature. Signed-off-by: Niu Yawei Signed-off-by: Andreas Dilger Signed-off-by: "Theodore Ts'o" --- configure | 6 +- configure.in | 4 + lib/quota/mkquota.c | 1 + tests/Makefile.in | 1 + tests/m_quota/expect.1 | 172 ++++++++++++++++++++++++++++++++++++++ tests/m_quota/script | 8 ++ tests/t_quota_1on/name | 1 + tests/t_quota_1on/script | 42 ++++++++++ tests/t_quota_2off/name | 1 + tests/t_quota_2off/script | 35 ++++++++ 10 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 tests/m_quota/expect.1 create mode 100644 tests/m_quota/script create mode 100644 tests/t_quota_1on/name create mode 100644 tests/t_quota_1on/script create mode 100644 tests/t_quota_2off/name create mode 100644 tests/t_quota_2off/script diff --git a/configure b/configure index afe381fc..738bd89e 100755 --- a/configure +++ b/configure @@ -5187,6 +5187,7 @@ fi QUOTA_MAN_COMMENT='.\"' +QUOTA_CMT= @@ -5309,9 +5310,11 @@ fi if test "${enable_quota+set}" = set; then : enableval=$enable_quota; if test "$enableval" = "no" then + QUOTA_CMT=# { $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling quota support" >&5 $as_echo "Disabling quota support" >&6; } else + QUOTA_CMT= $as_echo "#define CONFIG_QUOTA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling quota support" >&5 @@ -5321,7 +5324,8 @@ $as_echo "Enabling quota support" >&6; } fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling quota support by default" >&5 + QUOTA_CMT=# +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling quota support by default" >&5 $as_echo "Disabling quota support by default" >&6; } fi diff --git a/configure.in b/configure.in index f9cfd534..87d73e4e 100644 --- a/configure.in +++ b/configure.in @@ -566,6 +566,7 @@ dnl dnl handle --enable-quota dnl QUOTA_MAN_COMMENT='.\"' +QUOTA_CMT= AC_SUBST(QUOTA_MAN_COMMENT) PKG_PROG_PKG_CONFIG AH_TEMPLATE([CONFIG_QUOTA], [Define to 1 to enable quota support]) @@ -573,14 +574,17 @@ AC_ARG_ENABLE([quota], [ --enable-quota enable quota support], if test "$enableval" = "no" then + QUOTA_CMT=# AC_MSG_RESULT([Disabling quota support]) else + QUOTA_CMT= AC_DEFINE(CONFIG_QUOTA, 1) AC_MSG_RESULT([Enabling quota support]) QUOTA_MAN_COMMENT="" AC_SUBST(QUOTA_MAN_COMMENT) fi , +QUOTA_CMT=# AC_MSG_RESULT([Disabling quota support by default]) ) dnl diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c index 8d087da0..a0d3a2a9 100644 --- a/lib/quota/mkquota.c +++ b/lib/quota/mkquota.c @@ -99,6 +99,7 @@ errcode_t quota_remove_inode(ext2_filsys fs, int qtype) quota_inode_truncate(fs, qf_ino); ext2fs_mark_super_dirty(fs); + fs->flags &= ~EXT2_FLAG_SUPER_ONLY; ext2fs_write_bitmaps(fs); return 0; } diff --git a/tests/Makefile.in b/tests/Makefile.in index b9df3b02..37a043ea 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -17,6 +17,7 @@ test_one: $(srcdir)/test_one.in Makefile mke2fs.conf @echo "Creating test_one script..." @echo "#!/bin/sh" > test_one @HTREE_CMT@ @echo "HTREE=y" >> test_one +@QUOTA_CMT@ @echo "QUOTA=y" >> test_one @echo "SRCDIR=@srcdir@" >> test_one @echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one @cat $(srcdir)/test_one.in >> test_one diff --git a/tests/m_quota/expect.1 b/tests/m_quota/expect.1 new file mode 100644 index 00000000..830046e7 --- /dev/null +++ b/tests/m_quota/expect.1 @@ -0,0 +1,172 @@ + +Warning: the quota feature is still under development +See https://ext4.wiki.kernel.org/index.php/Quota for more information + +Filesystem label= +OS type: Linux +Block size=1024 (log=0) +Fragment size=1024 (log=0) +Stride=0 blocks, Stripe width=0 blocks +32768 inodes, 131072 blocks +6553 blocks (5.00%) reserved for the super user +First data block=1 +Maximum filesystem blocks=67371008 +16 block groups +8192 blocks per group, 8192 fragments per group +2048 inodes per group +Superblock backups stored on blocks: + 8193, 24577, 40961, 57345, 73729 + +Allocating group tables: done +Writing inode tables: done +Writing superblocks and filesystem accounting information: done + +Filesystem features: ext_attr resize_inode dir_index filetype sparse_super quota +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 11/32768 files (18.2% non-contiguous), 5703/131072 blocks +Exit status is 0 +Filesystem volume name: +Last mounted on: +Filesystem magic number: 0xEF53 +Filesystem revision #: 1 (dynamic) +Filesystem features: ext_attr resize_inode dir_index filetype sparse_super quota +Default mount options: (none) +Filesystem state: clean +Errors behavior: Continue +Filesystem OS type: Linux +Inode count: 32768 +Block count: 131072 +Reserved block count: 6553 +Free blocks: 125369 +Free inodes: 32757 +First block: 1 +Block size: 1024 +Fragment size: 1024 +Reserved GDT blocks: 256 +Blocks per group: 8192 +Fragments per group: 8192 +Inodes per group: 2048 +Inode blocks per group: 256 +Mount count: 0 +Check interval: 15552000 (6 months) +Reserved blocks uid: 0 +Reserved blocks gid: 0 +First inode: 11 +Inode size: 128 +Default directory hash: half_md4 +User quota inode: 3 +Group quota inode: 4 + + +Group 0: (Blocks 1-8192) + Primary superblock at 1, Group descriptors at 2-2 + Reserved GDT blocks at 3-258 + Block bitmap at 259 (+258), Inode bitmap at 260 (+259) + Inode table at 261-516 (+260) + 7650 free blocks, 2037 free inodes, 2 directories + Free blocks: 543-8192 + Free inodes: 12-2048 +Group 1: (Blocks 8193-16384) + Backup superblock at 8193, Group descriptors at 8194-8194 + Reserved GDT blocks at 8195-8450 + Block bitmap at 8451 (+258), Inode bitmap at 8452 (+259) + Inode table at 8453-8708 (+260) + 7676 free blocks, 2048 free inodes, 0 directories + Free blocks: 8709-16384 + Free inodes: 2049-4096 +Group 2: (Blocks 16385-24576) + Block bitmap at 16385 (+0), Inode bitmap at 16386 (+1) + Inode table at 16387-16642 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 16643-24576 + Free inodes: 4097-6144 +Group 3: (Blocks 24577-32768) + Backup superblock at 24577, Group descriptors at 24578-24578 + Reserved GDT blocks at 24579-24834 + Block bitmap at 24835 (+258), Inode bitmap at 24836 (+259) + Inode table at 24837-25092 (+260) + 7676 free blocks, 2048 free inodes, 0 directories + Free blocks: 25093-32768 + Free inodes: 6145-8192 +Group 4: (Blocks 32769-40960) + Block bitmap at 32769 (+0), Inode bitmap at 32770 (+1) + Inode table at 32771-33026 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 33027-40960 + Free inodes: 8193-10240 +Group 5: (Blocks 40961-49152) + Backup superblock at 40961, Group descriptors at 40962-40962 + Reserved GDT blocks at 40963-41218 + Block bitmap at 41219 (+258), Inode bitmap at 41220 (+259) + Inode table at 41221-41476 (+260) + 7676 free blocks, 2048 free inodes, 0 directories + Free blocks: 41477-49152 + Free inodes: 10241-12288 +Group 6: (Blocks 49153-57344) + Block bitmap at 49153 (+0), Inode bitmap at 49154 (+1) + Inode table at 49155-49410 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 49411-57344 + Free inodes: 12289-14336 +Group 7: (Blocks 57345-65536) + Backup superblock at 57345, Group descriptors at 57346-57346 + Reserved GDT blocks at 57347-57602 + Block bitmap at 57603 (+258), Inode bitmap at 57604 (+259) + Inode table at 57605-57860 (+260) + 7676 free blocks, 2048 free inodes, 0 directories + Free blocks: 57861-65536 + Free inodes: 14337-16384 +Group 8: (Blocks 65537-73728) + Block bitmap at 65537 (+0), Inode bitmap at 65538 (+1) + Inode table at 65539-65794 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 65795-73728 + Free inodes: 16385-18432 +Group 9: (Blocks 73729-81920) + Backup superblock at 73729, Group descriptors at 73730-73730 + Reserved GDT blocks at 73731-73986 + Block bitmap at 73987 (+258), Inode bitmap at 73988 (+259) + Inode table at 73989-74244 (+260) + 7676 free blocks, 2048 free inodes, 0 directories + Free blocks: 74245-81920 + Free inodes: 18433-20480 +Group 10: (Blocks 81921-90112) + Block bitmap at 81921 (+0), Inode bitmap at 81922 (+1) + Inode table at 81923-82178 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 82179-90112 + Free inodes: 20481-22528 +Group 11: (Blocks 90113-98304) + Block bitmap at 90113 (+0), Inode bitmap at 90114 (+1) + Inode table at 90115-90370 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 90371-98304 + Free inodes: 22529-24576 +Group 12: (Blocks 98305-106496) + Block bitmap at 98305 (+0), Inode bitmap at 98306 (+1) + Inode table at 98307-98562 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 98563-106496 + Free inodes: 24577-26624 +Group 13: (Blocks 106497-114688) + Block bitmap at 106497 (+0), Inode bitmap at 106498 (+1) + Inode table at 106499-106754 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 106755-114688 + Free inodes: 26625-28672 +Group 14: (Blocks 114689-122880) + Block bitmap at 114689 (+0), Inode bitmap at 114690 (+1) + Inode table at 114691-114946 (+2) + 7934 free blocks, 2048 free inodes, 0 directories + Free blocks: 114947-122880 + Free inodes: 28673-30720 +Group 15: (Blocks 122881-131071) + Block bitmap at 122881 (+0), Inode bitmap at 122882 (+1) + Inode table at 122883-123138 (+2) + 7933 free blocks, 2048 free inodes, 0 directories + Free blocks: 123139-131071 + Free inodes: 30721-32768 diff --git a/tests/m_quota/script b/tests/m_quota/script new file mode 100644 index 00000000..36ab6306 --- /dev/null +++ b/tests/m_quota/script @@ -0,0 +1,8 @@ +DESCRIPTION="enable quota feature on mkfs" +FS_SIZE=131072 +MKE2FS_OPTS="-O quota" +if [ "$QUOTA" != "y" ]; then + echo "$test_name: $DESCRIPTION: skipped" + return 0 +fi +. $cmd_dir/run_mke2fs diff --git a/tests/t_quota_1on/name b/tests/t_quota_1on/name new file mode 100644 index 00000000..f92e2d58 --- /dev/null +++ b/tests/t_quota_1on/name @@ -0,0 +1 @@ +enable quota using tune2fs diff --git a/tests/t_quota_1on/script b/tests/t_quota_1on/script new file mode 100644 index 00000000..ed17f337 --- /dev/null +++ b/tests/t_quota_1on/script @@ -0,0 +1,42 @@ +FSCK_OPT=-yf + +if [ "$QUOTA" != "y" ]; then + echo "$test_name: $test_description: skipped" + return 0 +fi + +$MKE2FS -q -F -o Linux -b 4096 $TMPFILE 10000 > $test_name.log 2>&1 +status=$? +if [ "$status" != 0 ] ; then + echo "mke2fs failed" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi + +dd if=/dev/zero of=$TMPFILE.2 bs=1048576 count=1 >> $test_name.log 2>&1 +cat <<- EOF | $DEBUGFS -w -f /dev/stdin $TMPFILE >> $test_name.log 2>&1 + write $TMPFILE.2 file1 + set_inode_field file1 uid 500 + set_inode_field file1 gid 500 +EOF +rm -f $TMPFILE.2 + +$TUNE2FS -O quota $TMPFILE >> $test_name.log 2>&1 +status=$? +if [ "$status" != 0 ] ; then + echo "tune2fs -O quota failed with $status" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi + +$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1 +status=$? +if [ "$status" = 0 ] ; then + echo "$test_name: $test_description: ok" + touch $test_name.ok +else + echo "e2fsck with quota enabled failed with $status" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi +rm -f $TMPFILE diff --git a/tests/t_quota_2off/name b/tests/t_quota_2off/name new file mode 100644 index 00000000..bb0ec98f --- /dev/null +++ b/tests/t_quota_2off/name @@ -0,0 +1 @@ +disable quota using tune2fs diff --git a/tests/t_quota_2off/script b/tests/t_quota_2off/script new file mode 100644 index 00000000..b170c59c --- /dev/null +++ b/tests/t_quota_2off/script @@ -0,0 +1,35 @@ +FSCK_OPT=-yf + +if [ "$QUOTA" != "y" ]; then + echo "$test_name: $test_description: skipped" + return 0 +fi + +$MKE2FS -q -F -o Linux -b 4096 -O quota $TMPFILE 100 > $test_name.log 2>&1 +status=$? +if [ "$status" != 0 ] ; then + echo "mke2fs -O quota failed" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi + +$TUNE2FS -O ^quota $TMPFILE >> $test_name.log 2>&1 +status=$? +if [ "$status" != 0 ] ; then + echo "tune2fs -O ^quota failed" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi + +$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1 +status=$? +if [ "$status" = 0 ] ; then + echo "$test_name: $test_description: ok" + touch $test_name.ok +else + echo "e2fsck with quota enabled failed with $status" > $test_name.failed + echo "$test_name: $test_description: failed" + return $status +fi + +rm -f $TMPFILE