rpms/kernel/devel linux-2.6.27-delay-ext4-free-block-cap-check.patch, NONE, 1.1 TODO, 1.33, 1.34 kernel.spec, 1.1090, 1.1091
Eric Sandeen
sandeen at fedoraproject.org
Mon Oct 27 16:46:55 UTC 2008
- Previous message: rpms/gssdp/F-9 gssdp.spec,1.3,1.4 sources,1.3,1.4
- Next message: rpms/kvm/devel .cvsignore, 1.38, 1.39 kvm-62-block-rw-range-check.patch, 1.3, 1.4 kvm.spec, 1.72, 1.73 sources, 1.37, 1.38 kvm-74-page-find.patch, 1.1, NONE kvm-74-pxe-boot.patch, 1.1, NONE kvm-bootmenu.patch, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: sandeen
Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15617
Modified Files:
TODO kernel.spec
Added Files:
linux-2.6.27-delay-ext4-free-block-cap-check.patch
Log Message:
* Mon Oct 27 2008 Eric Sandeen <sandeen at redhat.com>
- Delay capable() checks in ext4 until necessary. (#467216)
linux-2.6.27-delay-ext4-free-block-cap-check.patch:
--- NEW FILE linux-2.6.27-delay-ext4-free-block-cap-check.patch ---
diff -u linux-2.6/fs/ext4/balloc.c linux-2.6/fs/ext4/balloc.c
--- linux-2.6/fs/ext4/balloc.c 2008-10-24 15:54:54.225063944 -0500
+++ linux-2.6/fs/ext4/balloc.c 2008-10-24 15:38:52.897001441 -0500
@@ -589,21 +589,23 @@
return;
}
-int ext4_claim_free_blocks(struct ext4_sb_info *sbi,
- s64 nblocks)
+/**
+ * ext4_has_free_blocks()
+ * @sbi: in-core super block structure.
+ * @nblocks: number of needed blocks
+ *
+ * Check if filesystem has nblocks free & available for allocation.
+ * On success return 1, return 0 on failure.
+ */
+int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks)
{
- s64 free_blocks, dirty_blocks;
- s64 root_blocks = 0;
+ s64 free_blocks, dirty_blocks, root_blocks;
struct percpu_counter *fbc = &sbi->s_freeblocks_counter;
struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter;
free_blocks = percpu_counter_read_positive(fbc);
dirty_blocks = percpu_counter_read_positive(dbc);
-
- if (!capable(CAP_SYS_RESOURCE) &&
- sbi->s_resuid != current->fsuid &&
- (sbi->s_resgid == 0 || !in_group_p(sbi->s_resgid)))
- root_blocks = ext4_r_blocks_count(sbi->s_es);
+ root_blocks = ext4_r_blocks_count(sbi->s_es);
if (free_blocks - (nblocks + root_blocks + dirty_blocks) <
EXT4_FREEBLOCKS_WATERMARK) {
@@ -616,57 +618,32 @@
}
}
/* Check whether we have space after
- * accounting for current dirty blocks
+ * accounting for current dirty blocks & root reserved blocks.
*/
- if (free_blocks < ((root_blocks + nblocks) + dirty_blocks))
- /* we don't have free space */
- return -ENOSPC;
+ if (free_blocks >= ((root_blocks + nblocks) + dirty_blocks))
+ return 1;
+
+ /* Hm, nope. Are (enough) root reserved blocks available? */
+ if (sbi->s_resuid == current->fsuid ||
+ ((sbi->s_resgid != 0) && in_group_p(sbi->s_resgid)) ||
+ capable(CAP_SYS_RESOURCE)) {
+ if (free_blocks >= (nblocks + dirty_blocks))
+ return 1;
+ }
- /* Add the blocks to nblocks */
- percpu_counter_add(dbc, nblocks);
return 0;
}
-/**
- * ext4_has_free_blocks()
- * @sbi: in-core super block structure.
- * @nblocks: number of neeed blocks
- *
- * Check if filesystem has free blocks available for allocation.
- * Return the number of blocks avaible for allocation for this request
- * On success, return nblocks
- */
-ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
+int ext4_claim_free_blocks(struct ext4_sb_info *sbi,
s64 nblocks)
{
- s64 free_blocks, dirty_blocks;
- s64 root_blocks = 0;
- struct percpu_counter *fbc = &sbi->s_freeblocks_counter;
- struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter;
-
- free_blocks = percpu_counter_read_positive(fbc);
- dirty_blocks = percpu_counter_read_positive(dbc);
-
- if (!capable(CAP_SYS_RESOURCE) &&
- sbi->s_resuid != current->fsuid &&
- (sbi->s_resgid == 0 || !in_group_p(sbi->s_resgid)))
- root_blocks = ext4_r_blocks_count(sbi->s_es);
-
- if (free_blocks - (nblocks + root_blocks + dirty_blocks) <
- EXT4_FREEBLOCKS_WATERMARK) {
- free_blocks = percpu_counter_sum(fbc);
- dirty_blocks = percpu_counter_sum(dbc);
- }
- if (free_blocks <= (root_blocks + dirty_blocks))
- /* we don't have free space */
+ if (ext4_has_free_blocks(sbi, nblocks)) {
+ percpu_counter_add(&sbi->s_dirtyblocks_counter, nblocks);
return 0;
-
- if (free_blocks - (root_blocks + dirty_blocks) < nblocks)
- return free_blocks - (root_blocks + dirty_blocks);
- return nblocks;
+ } else
+ return -ENOSPC;
}
-
/**
* ext4_should_retry_alloc()
* @sb: super block
unchanged:
--- linux-2.6.orig/fs/ext4/ext4.h 2008-10-24 15:32:33.302001208 -0500
+++ linux-2.6/fs/ext4/ext4.h 2008-10-24 15:32:36.077063920 -0500
@@ -1003,8 +1003,7 @@ extern ext4_fsblk_t ext4_new_blocks(hand
ext4_lblk_t iblock, ext4_fsblk_t goal,
unsigned long *count, int *errp);
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
-extern ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
- s64 nblocks);
+extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
ext4_fsblk_t block, unsigned long count, int metadata);
extern void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
Index: TODO
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/TODO,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- TODO 26 Oct 2008 22:58:44 -0000 1.33
+++ TODO 27 Oct 2008 16:46:25 -0000 1.34
@@ -160,6 +160,9 @@
in -stable, but reverted in upstream-reverts
(the ext4 patch queue won't apply if we get this patch from -stable)
+linux-2.6.27-delay-ext4-free-block-cap-check.patch
+ In the ext4 queue, will be upstream (for bug #467216)
+
linux-2.6-x86-avoid-dereferencing-beyond-stack-THREAD_SIZE.patch
In mainline and 2.6.26-stable, submitted for 2.6.27-stable.
Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1090
retrieving revision 1.1091
diff -u -r1.1090 -r1.1091
--- kernel.spec 27 Oct 2008 16:41:18 -0000 1.1090
+++ kernel.spec 27 Oct 2008 16:46:25 -0000 1.1091
@@ -708,6 +708,7 @@
Patch2900: linux-2.6.27-ext4-stable-patch-queue.patch
Patch2901: linux-2.6.27-fs-disable-fiemap.patch
Patch2902: linux-2.6.27-ext-dir-corruption-fix.patch
+Patch2903: linux-2.6.27-delay-ext4-free-block-cap-check.patch
# cciss sysfs links are broken
Patch3000: linux-2.6-blk-cciss-fix-regression-sysfs-symlink-missing.patch
@@ -1134,6 +1135,8 @@
ApplyPatch linux-2.6.27-fs-disable-fiemap.patch
# CVE-2008-3528, ext-fs dir corruption
ApplyPatch linux-2.6.27-ext-dir-corruption-fix.patch
+# Delay capability() checks 'til last in ext4
+ApplyPatch linux-2.6.27-delay-ext4-free-block-cap-check.patch
# xfs
@@ -1872,6 +1875,9 @@
%kernel_variant_files -k vmlinux %{with_kdump} kdump
%changelog
+* Mon Oct 27 2008 Eric Sandeen <sandeen at redhat.com>
+- Delay capable() checks in ext4 until necessary. (#467216)
+
* Mon Oct 27 2008 Dave Jones <davej at redhat.com>
- ACPI: Ignore the RESET_REG_SUP bit when using ACPI reset mechanism. (461228)
- Previous message: rpms/gssdp/F-9 gssdp.spec,1.3,1.4 sources,1.3,1.4
- Next message: rpms/kvm/devel .cvsignore, 1.38, 1.39 kvm-62-block-rw-range-check.patch, 1.3, 1.4 kvm.spec, 1.72, 1.73 sources, 1.37, 1.38 kvm-74-page-find.patch, 1.1, NONE kvm-74-pxe-boot.patch, 1.1, NONE kvm-bootmenu.patch, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the scm-commits
mailing list