summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@fedoraproject.org>2009-05-20 20:41:35 +0000
committerEric Sandeen <sandeen@fedoraproject.org>2009-05-20 20:41:35 +0000
commit0d0952fb08125d36a68a7d62b414d34cef73e75f (patch)
tree93a864784e4250b6eac8431be6ffd2131165a7d2
parentbdcaa2518787233ec9a3a924a64689307b0489a1 (diff)
downloade2fsprogs-0d0952fb08125d36a68a7d62b414d34cef73e75f.tar.gz
e2fsprogs-0d0952fb08125d36a68a7d62b414d34cef73e75f.tar.xz
e2fsprogs-0d0952fb08125d36a68a7d62b414d34cef73e75f.zip
* Wed May 20 2009 Eric Sandeen <sandeen@redhat.com> 1.41.4-10e2fsprogs-1_41_4-10_fc11
- Fix minimum resize calculation and enforce it (#499452)
-rw-r--r--e2fsprogs-1.41.4-minimum-resize.patch93
-rw-r--r--e2fsprogs.spec8
2 files changed, 100 insertions, 1 deletions
diff --git a/e2fsprogs-1.41.4-minimum-resize.patch b/e2fsprogs-1.41.4-minimum-resize.patch
new file mode 100644
index 0000000..233d8bc
--- /dev/null
+++ b/e2fsprogs-1.41.4-minimum-resize.patch
@@ -0,0 +1,93 @@
+Sent to the list:
+
+[PATCH] fix minimum size calculations
+
+The extra padding added to the minimum size calculations:
+
+ /*
+ * We need to reserve a few extra blocks if extents are
+ * enabled, in case we need to grow the extent tree. The more
+ * we shrink the file system, the more space we need.
+ */
+ if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)
+ blks_needed += (fs->super->s_blocks_count - blks_needed)/500;
+
+can go quite wrong if we've already added up more "blks_needed"
+than our current size, and the above subtraction wraps. This can
+easily happen for a filesystem which is almost completely full.
+
+In this case, just return the current fs size as the minimum and
+be done with it.
+
+With this fix we could probably call calculate_minimum_resize_size()
+for each resize2fs invocation and refuse to resize smaller than that?
+
+Signed-off-by: Eric Sandeen <sandeen@redhat.com>
+
+[PATCH] resize2fs: don't try to resize below calculated minimum
+
+Without a force flag, don't allow resize2fs to even start resizing
+below what it thinks the minimum safe value is.
+
+This may stop resizes which could otherwise proceed with a bit
+of space still left, but seems like a reasonably safe thing to do.
+
+Signed-off-by: Eric Sandeen <sandeen@redhat.com>
+---
+
+Index: e2fsprogs/resize/resize2fs.c
+===================================================================
+--- e2fsprogs.orig/resize/resize2fs.c
++++ e2fsprogs/resize/resize2fs.c
+@@ -2003,6 +2003,12 @@ blk_t calculate_minimum_resize_size(ext2
+ blks_needed += overhead;
+
+ /*
++ * If at this point we've already added up more "needed" than
++ * the current size, just return current size as minimum.
++ */
++ if (blks_needed >= fs->super->s_blocks_count)
++ return fs->super->s_blocks_count;
++ /*
+ * We need to reserve a few extra blocks if extents are
+ * enabled, in case we need to grow the extent tree. The more
+ * we shrink the file system, the more space we need.
+
+Index: e2fsprogs/resize/main.c
+===================================================================
+--- e2fsprogs.orig/resize/main.c
++++ e2fsprogs/resize/main.c
+@@ -160,6 +160,7 @@ int main (int argc, char ** argv)
+ int fd, ret;
+ blk_t new_size = 0;
+ blk_t max_size = 0;
++ blk_t min_size = 0;
+ io_manager io_ptr;
+ char *new_size_str = 0;
+ int use_stride = -1;
+@@ -341,9 +342,11 @@ int main (int argc, char ** argv)
+ exit(1);
+ }
+
++ min_size = calculate_minimum_resize_size(fs);
++
+ if (print_min_size) {
+ printf(_("Estimated minimum size of the filesystem: %u\n"),
+- calculate_minimum_resize_size(fs));
++ min_size);
+ exit(0);
+ }
+
+@@ -388,6 +391,11 @@ int main (int argc, char ** argv)
+ new_size &= ~((sys_page_size / fs->blocksize)-1);
+ }
+
++ if (!force && new_size < min_size) {
++ com_err(program_name, 0,
++ _("New size smaller than minimum (%u)\n"), min_size);
++ exit(1);
++ }
+ if (use_stride >= 0) {
+ if (use_stride >= (int) fs->super->s_blocks_per_group) {
+ com_err(program_name, 0,
+
diff --git a/e2fsprogs.spec b/e2fsprogs.spec
index 525f06c..1e92fea 100644
--- a/e2fsprogs.spec
+++ b/e2fsprogs.spec
@@ -4,7 +4,7 @@
Summary: Utilities for managing ext2, ext3, and ext4 filesystems
Name: e2fsprogs
Version: 1.41.4
-Release: 9%{?dist}
+Release: 10%{?dist}
# License based on upstream-modified COPYING file,
# which clearly states "V2" intent.
License: GPLv2
@@ -22,6 +22,7 @@ Patch6: e2fsprogs-1.41.4-ignore-NEEDS_RECOVERY-mismatch.patch
Patch7: e2fsprogs-1.41.4-ext4-resize-fixes.patch
Patch8: e2fsprogs-1.41.4-fix-external-journals.patch
Patch9: e2fsprogs-1.41.4-i_file_acl_high-fix.patch
+Patch10: e2fsprogs-1.41.4-minimum-resize.patch
Url: http://e2fsprogs.sourceforge.net/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -113,6 +114,8 @@ SMP systems.
%patch8 -p1 -b .ext-journal
# e2fsck: On a 32-bit filesystem, make sure i_file_acl_high is zero
%patch9 -p1 -b .acl_hi
+# Fix minimum resize calculation and enforce it
+%patch10 -p1 -b .resize_min
%build
%configure --enable-elf-shlibs --enable-nls --disable-e2initrd-helper --enable-blkid-devmapper --enable-blkid-selinux
@@ -311,6 +314,9 @@ fi
%dir %attr(2775, uuidd, uuidd) /var/lib/libuuid
%changelog
+* Wed May 20 2009 Eric Sandeen <sandeen@redhat.com> 1.41.4-10
+- Fix minimum resize calculation and enforce it (#499452)
+
* Thu May 14 2009 Eric Sandeen <sandeen@redhat.com> 1.41.4-9
- Fix corrupted filesystems with mis-set i_file_acl_hi (#500935)