EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
#ifdef CONFIG_QUOTA
EXT4_FEATURE_RO_COMPAT_QUOTA |
+ EXT4_FEATURE_RO_COMPAT_PROJECT |
#endif
EXT4_FEATURE_RO_COMPAT_GDT_CSUM
};
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_PROJECT)) {
- if (!Q_flag && !(sb->s_feature_ro_compat &
- EXT4_FEATURE_RO_COMPAT_QUOTA))
- fputs(_("\nWarning: enabled project without quota together\n"),
- stderr);
Q_flag = 1;
quota_enable[PRJQUOTA] = QOPT_ENABLE;
}
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ Q_flag = 1;
+ quota_enable[PRJQUOTA] = QOPT_DISABLE;
+ }
+
+ if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_QUOTA)) {
/*
* Set the Q_flag here and handle the quota options in the code
ext2_ino_t qf_ino;
enum quota_type qtype;
int enable = 0;
+ int need_dirty = 0;
for (qtype = 0 ; qtype < MAXQUOTAS; qtype++)
if (quota_enable[qtype] != 0)
QFMT_VFS_V1)) > 0)
quota_update_limits(qctx, qf_ino, qtype);
quota_write_inode(qctx, 1 << qtype);
+ /* Enable Quota feature if one of quota enabled */
+ if (!(fs->super->s_feature_ro_compat &
+ EXT4_FEATURE_RO_COMPAT_QUOTA)) {
+ fs->super->s_feature_ro_compat |=
+ EXT4_FEATURE_RO_COMPAT_QUOTA;
+ need_dirty = 1;
+ }
+ if (qtype == PRJQUOTA &&
+ !(fs->super->s_feature_ro_compat &
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ fs->super->s_feature_ro_compat |=
+ EXT4_FEATURE_RO_COMPAT_PROJECT;
+ need_dirty = 1;
+ }
} else if (quota_enable[qtype] == QOPT_DISABLE) {
quota_remove_inode(fs, qtype);
+ if (qtype == PRJQUOTA) {
+ fs->super->s_feature_ro_compat &=
+ ~EXT4_FEATURE_RO_COMPAT_PROJECT;
+ need_dirty = 1;
+ }
}
}
quota_release_context(&qctx);
-
- if (enable) {
- fs->super->s_feature_ro_compat |= EXT4_FEATURE_RO_COMPAT_QUOTA;
- ext2fs_mark_super_dirty(fs);
- } else {
+ /* Clear Quota feature if all quota types disabled. */
+ if (!enable) {
for (qtype = 0 ; qtype < MAXQUOTAS; qtype++)
- if (*quota_sb_inump(fs->super, qtype) != 0)
+ if (*quota_sb_inump(fs->super, qtype))
break;
if (qtype == MAXQUOTAS) {
fs->super->s_feature_ro_compat &=
~EXT4_FEATURE_RO_COMPAT_QUOTA;
- ext2fs_mark_super_dirty(fs);
+ need_dirty = 1;
}
}
+ if (need_dirty)
+ ext2fs_mark_super_dirty(fs);
return;
}
--- /dev/null
+enable project using tune2fs -O option
--- /dev/null
+FSCK_OPT=-yf
+
+if [ "$QUOTA" != "y" ]; then
+ echo "$test_name: $test_description: skipped"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -I 256 -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 projid 500
+EOF
+rm -f $TMPFILE.2
+
+$TUNE2FS -O project $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -O project 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 project enabled failed with $status" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+rm -f $TMPFILE
--- /dev/null
+disable project using tune2fs
--- /dev/null
+FSCK_OPT=-yf
+
+if [ "$QUOTA" != "y" ]; then
+ echo "$test_name: $test_description: skipped"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -I 256 -b 4096 -O quota,project $TMPFILE 100 > $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O quota,project failed" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+$TUNE2FS -O ^project $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -O ^project 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 project enabled failed with $status" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+rm -f $TMPFILE
--- /dev/null
+enable project using tune2fs -Q option
--- /dev/null
+FSCK_OPT=-yf
+
+if [ "$QUOTA" != "y" ]; then
+ echo "$test_name: $test_description: skipped"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -I 256 -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 projid 500
+EOF
+rm -f $TMPFILE.2
+
+$TUNE2FS -Q prj $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -Q project 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 project enabled failed with $status" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+rm -f $TMPFILE
--- /dev/null
+disable project using tune2fs -Q option
--- /dev/null
+FSCK_OPT=-yf
+
+if [ "$QUOTA" != "y" ]; then
+ echo "$test_name: $test_description: skipped"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -I 256 -b 4096 -O quota,project $TMPFILE 100 > $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O quota,project failed" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+$TUNE2FS -Q ^prj $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -O ^project 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 project enabled failed with $status" > $test_name.failed
+ echo "$test_name: $test_description: failed"
+ return $status
+fi
+
+rm -f $TMPFILE