distributed counters for ext2 to avoid group scaning
PATCH 1/1 distributed counters for ext2 to avoid group scaning
hi!
ext2 with concurrent balloc/ialloc doesn't maintain global free inodes/blocks counters. this is due to badness of spinlocks and atomic_t from big iron's viewpoint. therefore, to know these values we should scan all group descriptors. there are 81 groups for 10G fs. I believe there is method to avoid scaning and decrease memory footprint.
problem:
1) we have to maintain something like global counter
2) we do not want to use spinlock/atomic because of cache ping-pong badness
3) it's possible to fluctuate for some counters
for example, free blocks counter in ext2
solution:
lets have some base value of counter and diff value for each cpu. every time, someone wants to change (increase/decrease) counter, he increases/decreases diff value for current cpu. value of global counter may be calculated as sum of base value and all diffs. in order to prevent diff overflow, we need sometime to 'resyn' diff with base value. this resync needs to be serialized by seqlock. I called it 'distributed counter'.
this schema have been tested with ext2 on dual P3-1GHz.
here is the patch against _2.5.64-mm8_. would be happy to see any comments/suggestions!
fs/ext2/balloc.c +8 -1
@@ -138,6 +138,7 @@ desc->bg_free_blocks_count =cpu_to_le16 (free_blocks - count);spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, -count); sb->s_dirt =1 ;mark_buffer_dirty (bh);return count;
@@ -156,6 +157,7 @@ desc->bg_free_blocks_count =cpu_to_le16 (free_blocks + count);spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, count); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -491,7 +493,12 @@ goto out_release; } -unsigned long ext2_count_free_blocks (struct super_block * sb) +unsigned long ext2_count_free_blocks (struct super_block *sb) +{ +return dcounter_value (&EXT2_SB (sb)->free_blocks_dc); +} + +unsigned long ext2_count_free_blocks_old (struct super_block *sb) {struct ext2_group_desc * desc;unsigned long desc_count =0 ;
fs/ext2/ialloc.c +8 -1
@@ -92,6 +92,7 @@ desc->bg_used_dirs_count =cpu_to_le16 (le16_to_cpu (desc->bg_used_dirs_count) +1 );spin_unlock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); +dcounter_add (&EXT2_SB (sb)->free_inodes_dc,-1 ); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -115,6 +116,7 @@ desc->bg_used_dirs_count =cpu_to_le16 (le16_to_cpu (desc->bg_used_dirs_count) -1 );spin_unlock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); +dcounter_add (&EXT2_SB (sb)->free_inodes_dc,1 ); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -624,7 +626,12 @@ goto repeat; } -unsigned long ext2_count_free_inodes (struct super_block * sb) +unsigned long ext2_count_free_inodes (struct super_block *sb) +{ +return dcounter_value (&EXT2_SB (sb)->free_inodes_dc); +} + +unsigned long ext2_count_free_inodes_old (struct super_block *sb) {struct ext2_group_desc *desc;unsigned long desc_count =0 ;
fs/ext2/super.c +30 -5
@@ -35,6 +35,8 @@ struct ext2_super_block *es);static int ext2_remount (struct super_block * sb,int * flags,char * data);static int ext2_statfs (struct super_block * sb,struct statfs * buf); +unsigned long ext2_count_free_inodes_old (struct super_block *sb); +unsigned long ext2_count_free_blocks_old (struct super_block * sb);static char error_buf[1024 ];
@@ -508,9 +510,10 @@ gdp++; } -/* restore free blocks counter in SB -bzzz */ - es->s_free_blocks_count = total_free =ext2_count_free_blocks (sb); - es->s_free_inodes_count =cpu_to_le32 (ext2_count_free_inodes (sb)); + total_free =le32_to_cpu (es->s_free_blocks_count); +dcounter_init (&EXT2_SB (sb)->free_blocks_dc, total_free,1 ); +dcounter_init (&EXT2_SB (sb)->free_inodes_dc, +le32_to_cpu (es->s_free_inodes_count),1 );/* distribute reserved blocks over groups -bzzz */ for (i = sbi->s_groups_count-1 ; reserved && total_free && i >=0 ; i--) {
@@ -870,8 +873,18 @@static void ext2_sync_super (struct super_block *sb,struct ext2_super_block *es) { +if (ext2_count_free_blocks (sb) !=ext2_count_free_blocks_old (sb)) +printk ("EXT2-fs: invalid free blocks dcounter %d (real %d)\n" , + (int )ext2_count_free_blocks (sb), + (int )ext2_count_free_blocks_old (sb)); es->s_free_blocks_count =cpu_to_le32 (ext2_count_free_blocks (sb)); + +if (ext2_count_free_inodes (sb) !=ext2_count_free_inodes_old (sb)) +printk ("EXT2-fs: invalid free inodes dcounter %d (real %d)\n" , + (int )ext2_count_free_inodes (sb), + (int )ext2_count_free_inodes_old (sb)); es->s_free_inodes_count =cpu_to_le32 (ext2_count_free_inodes (sb)); + es->s_wtime =cpu_to_le32 (get_seconds ());mark_buffer_dirty (EXT2_SB (sb)->s_sbh);sync_dirty_buffer (EXT2_SB (sb)->s_sbh);
@@ -900,8 +913,20 @@ext2_debug ("setting valid to 0\n" ); es->s_state =cpu_to_le16 (le16_to_cpu (es->s_state) & ~EXT2_VALID_FS ); - es->s_free_blocks_count =cpu_to_le32 (ext2_count_free_blocks (sb)); - es->s_free_inodes_count =cpu_to_le32 (ext2_count_free_inodes (sb)); + es->s_free_blocks_count = +cpu_to_le32 (ext2_count_free_blocks (sb)); +if (ext2_count_free_blocks (sb) !=ext2_count_free_blocks_old (sb)) +printk ("EXT2-fs: invalid free blocks dcounter %d (real %d)\n" , + (int )ext2_count_free_blocks (sb), + (int )ext2_count_free_blocks_old (sb)); + + es->s_free_inodes_count = +cpu_to_le32 (ext2_count_free_inodes (sb)); +if (ext2_count_free_inodes (sb) !=ext2_count_free_inodes_old (sb)) +printk ("EXT2-fs: invalid free inodes dcounter %d (real %d)\n" , + (int )ext2_count_free_inodes (sb), + (int )ext2_count_free_inodes_old (sb)); + es->s_mtime =cpu_to_le32 (get_seconds ());ext2_sync_super (sb, es); }else
include/linux/dcounter.h +80 -0
80 lines not on this page · raw message
include/linux/ext2_fs_sb.h +4 -0
@@ -16,6 +16,8 @@ #ifndef _LINUX_EXT2_FS_SB #define _LINUX_EXT2_FS_SB +#include <linux/dcounter.h> + struct ext2_bg_info { u8 debts; spinlock_t balloc_lock;
@@ -52,6 +54,8 @@u32 s_next_generation;unsigned long s_dir_count;struct ext2_bg_info *s_bgi; +struct dcounter free_blocks_dc; + struct dcounter free_inodes_dc; };#endif /* _LINUX_EXT2_FS_SB */
Quoted 14 lines · Alex Tomas
hi!
ext2 with concurrent balloc/ialloc doesn't maintain global free inodes/blocks
counters. This is due to badness of spinlocks andatomic_tfrom big iron's
viewpoint. therefore, to know these values we should scan all group descriptors. there are 81 groups for 10G fs. I believe there is method to avoid scaning and decrease memory footprint.problem:
1) we have to maintain something like global counter
2) we do not want to use spinlock/atomic because of cache ping-pong badness
3) it's possible to fluctuate for some counters
for example, free blocks counter in ext2
Quoted 7 lines
solution:
lets have some base value of counter and diff value for each cpu. every time, someone wants to change (increase/decrease) counter, he increases/decreases diff value for current cpu. value of global counter may be calculated as sum of base value and all diffs. In order to prevent diff overflow, we need sometime to 'resyn' diff with base value. this resync needs to be serialized by seqlock. I called it 'distributed counter'.
This sounds like a good idea. I've thought about ways of fixing this in the past, but hadn't had any good solutions. Unfortunately, we are still stuck with updating the per-group free blocks/inodes counts, and since they are modified directly in the buffer heads we can't go changing the alignments of those fields to match the locks.
include/linux/dcounter.h line 43
Quoted 11 lines
include/linux/dcounter.h +10
-0+dcounter_init (&EXT2_SB (sb)->free_blocks_dc, total_free,1 ); +dcounter_init (&EXT2_SB (sb)->free_inodes_dc, +le32_to_cpu (es->s_free_inodes_count),1 ); +static inline void dcounter_init (struct dcounter *dc,int value,int min) +{ +seqlock_init (&dc->lock); + dc->base = value; + dc->min = min; +memset (dc->diff,0 ,sizeof (int ) *NR_CPUS ); +}
So, why is it that the minimum free blocks/inodes is 1?
include/linux/dcounter.h line 35
Quoted 6 lines
include/linux/dcounter.h +6
-0+struct dcounter { +int base; +int min; +int diff[NR_CPUS ]; +seqlock_t lock; +};
For a generic struct, it probably makes more sense to make these fields "long" instead of "int".
Also, while your goal is to reduce cache ping-pong between CPUs, we will now have cache ping-pong for the "diff" array. We need to do per-cpu values or make each value cacheline aligned to avoid ping-pong.
Just for sanity's sake, it would be good to call these fields something other than "min" and "lock", since that makes life just hell with tags (it always bugs me when structs have fields called list_head, list_entry, page, inode, etc).
Maybe something like "dc_min", "dc_lock", etc. would be much nicer? The same goes for the fields in the block group info - it would be nice if they had a "bgi_" prefix.
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
hi!
Quoted 6 lines
Review
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andreas Dilger (AD) writes:
(quoted diff) +3
-0+ dcounter_init(&EXT2_SB(sb)->free_blocks_dc, total_free, 1); + dcounter_init(&EXT2_SB(sb)->free_inodes_dc, + le32_to_cpu (es->s_free_inodes_count), 1);So, why is it that the minimum free blocks/inodes is 1?
damn! it's my mistake. thank you.
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+struct dcounter { + int base; + int min; + int diff[NR_CPUS]; + seqlock_t lock; +};For a generic struct, it probably makes more sense to make these fields "long" instead of "int".
fixed
Quoted 3 lines
Also, while your goal is to reduce cache ping-pong between CPUs, we will now have cache ping-pong for the "diff" array. We need to do per-cpu values or make each value cacheline aligned to avoid ping-pong.
yes, you're right. fixed
Quoted 8 lines
Just for sanity's sake, it would be good to call these fields something other than "min" and "lock", since that makes life just hell with tags (it always bugs me when structs have fields called
list_head,list_entry, page, inode, etc).Maybe something like "
dc_min", "dc_lock", etc. would be much nicer? The same goes for the fields in the block group info - it would be nice if they had a "bgi_" prefix.
it makes sense. I've corrected this for dcounters and hope to correct for block group info in future cleanups.
again, corrected patch is against 2.5.64-mm8.
with best regards, Alex
fs/ext2/balloc.c +8 -1
@@ -138,6 +138,7 @@ desc->bg_free_blocks_count =cpu_to_le16 (free_blocks - count);spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, -count); sb->s_dirt =1 ;mark_buffer_dirty (bh);return count;
@@ -156,6 +157,7 @@ desc->bg_free_blocks_count =cpu_to_le16 (free_blocks + count);spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, count); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -491,7 +493,12 @@ goto out_release; } -unsigned long ext2_count_free_blocks (struct super_block * sb) +unsigned long ext2_count_free_blocks (struct super_block *sb) +{ +return dcounter_value (&EXT2_SB (sb)->free_blocks_dc); +} + +unsigned long ext2_count_free_blocks_old (struct super_block *sb) {struct ext2_group_desc * desc;unsigned long desc_count =0 ;
fs/ext2/ialloc.c +15 -4
@@ -88,10 +88,13 @@spin_lock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); desc->bg_free_inodes_count =cpu_to_le16 (le16_to_cpu (desc->bg_free_inodes_count) -1 ); -if (dir) +if (dir) { desc->bg_used_dirs_count =cpu_to_le16 (le16_to_cpu (desc->bg_used_dirs_count) +1 ); +dcounter_add (&EXT2_SB (sb)->dirs_dc,1 ); + }spin_unlock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); +dcounter_add (&EXT2_SB (sb)->free_inodes_dc,-1 ); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -111,10 +114,13 @@spin_lock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); desc->bg_free_inodes_count =cpu_to_le16 (le16_to_cpu (desc->bg_free_inodes_count) +1 ); -if (dir) +if (dir) { desc->bg_used_dirs_count =cpu_to_le16 (le16_to_cpu (desc->bg_used_dirs_count) -1 ); +dcounter_add (&EXT2_SB (sb)->dirs_dc,-1 ); + }spin_unlock (&EXT2_SB (sb)->s_bgi[group].ialloc_lock); +dcounter_add (&EXT2_SB (sb)->free_inodes_dc,1 ); sb->s_dirt =1 ;mark_buffer_dirty (bh); }
@@ -317,7 +323,7 @@int free_blocks =ext2_count_free_blocks (sb);int avefreeb = free_blocks / ngroups;int blocks_per_dir; -int ndirs =ext2_count_dirs (sb); +int ndirs =dcounter_value (&sbi->dirs_dc);int max_debt, max_dirs, min_blocks, min_inodes;int group =-1 , i;struct ext2_group_desc *desc;
@@ -624,7 +630,12 @@ goto repeat; } -unsigned long ext2_count_free_inodes (struct super_block * sb) +unsigned long ext2_count_free_inodes (struct super_block *sb) +{ +return dcounter_value (&EXT2_SB (sb)->free_inodes_dc); +} + +unsigned long ext2_count_free_inodes_old (struct super_block *sb) {struct ext2_group_desc *desc;unsigned long desc_count =0 ;
fs/ext2/super.c +40 -5
71 lines not on this page · raw message
include/linux/dcounter.h +85 -0
85 lines not on this page · raw message
include/linux/ext2_fs_sb.h +5 -0
@@ -16,6 +16,8 @@ #ifndef _LINUX_EXT2_FS_SB #define _LINUX_EXT2_FS_SB +#include <linux/dcounter.h> + struct ext2_bg_info { u8 debts; spinlock_t balloc_lock;
@@ -52,6 +54,9 @@u32 s_next_generation;unsigned long s_dir_count;struct ext2_bg_info *s_bgi; +struct dcounter free_blocks_dc; +struct dcounter free_inodes_dc; + struct dcounter dirs_dc; };#endif /* _LINUX_EXT2_FS_SB */
Quoted 5 lines · Alex Tomas
Quoted 3 lines
Also, while your goal is to reduce cache ping-pong between CPUs, we will now have cache ping-pong for the "diff" array. We need to do per-cpu values or make each value cacheline aligned to avoid ping-pong.
yes, you're right. fixed
Um. But ... let's say I'm on a P4 box running a distro kernel. I suspect most distros will set NR_CPUs to 8. So that's 128 byte cachelines * 8 CPUs gives 1024 bytes -- 1k. Per dcounter (never mind the size of seqlock or dc_base/dc_min):
Quoted 6 lines
include/linux/dcounter.h +6
-0+struct dcounter_diff { +long dd_value; +}____cacheline_aligned_in_smp ; + +struct dcounter { +long dc_base;
include/linux/dcounter.h
Quoted 10 lines
include/linux/dcounter.h +8
-0+long dc_min; +struct dcounter_diff dc_diff[NR_CPUS ]; +seqlock_t dc_lock; +}; +++ edited/include/linux/ext2_fs_sb.h Mon Mar 17 00:12:00 2003struct ext2_bg_info *s_bgi; +struct dcounter free_blocks_dc; +struct dcounter free_inodes_dc; +struct dcounter dirs_dc;
And then we have 3 of these (an additional 3k..). Per blockgroup. My 4GB / has 30 blockgroups; my 30GB /home has 232. So that's a little under 8 per GB. My _laptop_ has a 40GB drive, so that's on the order of 320 blockgroups -- almost an additional megabyte of ram consumed for these counters.
Maybe it makes big boxes go faster, but this makes my dual CPU desktop go slower, and that's not acceptable.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Matthew Wilcox (MW) writes:
MW> And then we have 3 of these (an additional 3k..). Per MW> blockgroup. My 4GB / has 30 blockgroups; my 30GB /home has 232. MW> So that's a little under 8 per GB. My _laptop_ has a 40GB drive, MW> so that's on the order of 320 blockgroups -- almost an additional MW> megabyte of ram consumed for these counters.
no-no!
_one_ dcounter to maintain number of free blocks _per_ fs. _one_ dcounter to maintain number of inode blocks _per_ fs. _one_ dcounter to maintain number of dirs _per_ fs.
3 dcounter per fs. no more.
Quoted 7 lines · Alex Tomas
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Matthew Wilcox (MW) writes:
MW> And then we have 3 of these (an additional 3k..). Per MW> blockgroup. My 4GB / has 30 blockgroups; my 30GB /home has 232. MW> So that's a little under 8 per GB. My _laptop_ has a 40GB drive, MW> so that's on the order of 320 blockgroups -- almost an additional MW> megabyte of ram consumed for these counters.
Quoted 7 lines
no-no!
_one_ dcounter to maintain number of free blocks _per_ fs. _one_ dcounter to maintain number of inode blocks _per_ fs. _one_ dcounter to maintain number of dirs _per_ fs.
3 dcounter per fs. no more.
Gah. That's your fault. Use diff -p in future; I saw:
include/linux/ext2_fs_sb.h Mon Mar 17 00:12:00 2003 renamed from include/linux/ext2_fs_sb.h Sun Mar 16 17:21:34 2003 +5 -0
@@ -16,6 +16,8 @@ #ifndef _LINUX_EXT2_FS_SB #define _LINUX_EXT2_FS_SB +#include <linux/dcounter.h> + struct ext2_bg_info { u8 debts; spinlock_t balloc_lock;
@@ -52,6 +54,9 @@ u32 s_next_generation; unsigned long s_dir_count; struct ext2_bg_info *s_bgi; + struct dcounter free_blocks_dc; + struct dcounter free_inodes_dc; + struct dcounter dirs_dc; };
which makes it look like the dcounters are added to ext2_bg_info. diff -p would have put the name of the struct after the @@ line. Not to mention you didn't follow the `s_' prefix style used everywhere else in that struct.
Anyway, I think dcounters should probably be allocated from kmalloc_percpu() rather than as part of the dcounter struct.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Matthew Wilcox (MW) writes:
MW> Gah. That's your fault. Use diff -p in future; I saw:
thanks for advice. I will.
MW> which makes it look like the dcounters are added to ext2_bg_info. MW> diff -p would have put the name of the struct after the @@ line. MW> Not to mention you didn't follow the `s_' prefix style used MW> everywhere else in that struct.
this makes sense too.
MW> Anyway, I think dcounters should probably be allocated from MW> kmalloc_percpu() rather than as part of the dcounter struct.
take a look.
Quoted 3 lines · Matthew Wilcox
Anyway, I think dcounters should probably be allocated from
kmalloc_percpu()rather than as part of the dcounter struct.
That will still consume up to 4 kilobytes per 32-bit counter. We'd need to merge Kiran & Dipankar's interlace allocator to do this less grossly.
Which is why I'm waiting to see some profiles and benchmarks. Judging from the last set of profiles, in which ext2_count_free_blocks() was not present, this may not be justified.
Quoted 8 lines · Andrew Morton
Quoted 3 lines · Matthew Wilcox
Anyway, I think dcounters should probably be allocated from
kmalloc_percpu()rather than as part of the dcounter struct.That will still consume up to 4 kilobytes per 32-bit counter. We'd need to merge Kiran & Dipankar's interlace allocator to do this less grossly.
Right -- or have dcounter manage a pool of memory itself. That's maybe too much work though.
Quoted 3 lines
Which is why I'm waiting to see some profiles and benchmarks. Judging from the last set of profiles, in which
ext2_count_free_blocks()was not present, this may not be justified.
If we can manage without it, that's even better of course.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
hi!
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Andrew Morton (AM) writes:
AM> Which is why I'm waiting to see some profiles and benchmarks. AM> Judging from the last set of profiles, in which AM> ext2_count_free_blocks() was not present, this may not be AM> justified.
first of all, ext2_count_free_blocks() is used by orlov allocator only which in turn is used to create dirs only. so, I do not think dbench may show possible improvement. also, I understand it isn't bottleneck absolutely, but I think it may reduce memory footprint. Probably, we may use dcounters for huge fs only (i.e. make it optional).
with best regards, Alex
Quoted 6 lines · Alex Tomas
ext2 with concurrent balloc/ialloc doesn't maintain global free inodes/blocks counters. this is due to badness of spinlocks and
atomic_tfrom big iron's viewpoint. therefore, to know these values we should scan all group descriptors. there are 81 groups for 10G fs. I believe there is method to avoid scaning and decrease memory footprint.
benching now
-- wli
Quoted 6 lines · Alex Tomas
Quoted 6 lines
ext2 with concurrent balloc/ialloc doesn't maintain global free inodes/blocks counters. this is due to badness of spinlocks and
atomic_tfrom big iron's viewpoint. therefore, to know these values we should scan all group descriptors. there are 81 groups for 10G fs. I believe there is method to avoid scaning and decrease memory footprint.
Quoted 1 line · William Lee Irwin III
benching now
Bad news. I don't have big enough fs's to do this one. Working it...
$ df -HT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 ext2 4.2G 2.8G 1.2G 72% / /dev/sdb1 ext2 9.1G 7.0G 1.6G 82% /home /dev/sdb2 ext2 9.1G 42M 8.6G 1% /results /dev/sdd1 ext2 19G 8.0G 9.2G 47% /work /dev/sde1 ext2 19G 1.7G 16G 10% /test $
-- wli
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
William Lee Irwin (WLI) writes:
Quoted 6 lines · Alex Tomas
Quoted 6 lines
ext2 with concurrent balloc/ialloc doesn't maintain global free inodes/blocks counters. this is due to badness of spinlocks and
atomic_tfrom big iron's viewpoint. therefore, to know these values we should scan all group descriptors. there are 81 groups for 10G fs. I believe there is method to avoid scaning and decrease memory footprint.
WLI> benching now
here is the patch against virgin 2.5.64 containing:
1) concurrent balloc
2) concurrent ialloc
3) no-space fix
4) distributed counters for free blocks, free inodes and dirs
4) LOTS of Andrew Morton's corrections
fs/ext2/balloc.c +106 -88
@@ -94,69 +94,71 @@return bh; } -static inline int reserve_blocks (struct super_block *sb,int count) +/* +* Set sb->s_dirt here because the superblock was "logically" altered. We +* need to recalculate its free blocks count and flush it out. +*/ +static int +group_reserve_blocks (struct super_block *sb,struct ext2_bg_info *bgi, +struct ext2_group_desc *desc,struct buffer_head *bh, +int count,int use_reserve) { -struct ext2_sb_info * sbi =EXT2_SB (sb); -struct ext2_super_block * es = sbi->s_es; -unsigned free_blocks =le32_to_cpu (es->s_free_blocks_count); -unsigned root_blocks =le32_to_cpu (es->s_r_blocks_count); +struct ext2_sb_info *sbi =EXT2_SB (sb); +unsigned free_blocks; +unsigned root_blocks; + +spin_lock (&bgi->balloc_lock); + free_blocks =le16_to_cpu (desc->bg_free_blocks_count);if (free_blocks < count) count = free_blocks; + root_blocks = bgi->reserved; + +if (free_blocks < bgi->reserved && !use_reserve) { +/* don't use reserved blocks */ +spin_unlock (&bgi->balloc_lock); +return 0 ; + } -if (free_blocks < root_blocks + count && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->fsuid && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { +if (free_blocks < bgi->reserved + count && + !capable (CAP_SYS_RESOURCE ) && + sbi->s_resuid != current->fsuid && + (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) {/* * We are too close to reserve and we are not privileged. * Can we allocate anything at all? */ -if (free_blocks > root_blocks) - count = free_blocks - root_blocks; -else +if (free_blocks > bgi->reserved) { + count = free_blocks - bgi->reserved; + }else { +spin_unlock (&bgi->balloc_lock);return 0 ; + } } + desc->bg_free_blocks_count =cpu_to_le16 (free_blocks - count); - es->s_free_blocks_count =cpu_to_le32 (free_blocks - count); -mark_buffer_dirty (sbi->s_sbh); +spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, -count); sb->s_dirt =1 ; +mark_buffer_dirty (bh);return count; } -static inline void release_blocks (struct super_block *sb,int count) +static void group_release_blocks (struct super_block *sb, +struct ext2_bg_info *bgi,struct ext2_group_desc *desc, +struct buffer_head *bh,int count) {if (count) { -struct ext2_sb_info * sbi =EXT2_SB (sb); -struct ext2_super_block * es = sbi->s_es; -unsigned free_blocks =le32_to_cpu (es->s_free_blocks_count); - es->s_free_blocks_count =cpu_to_le32 (free_blocks + count); -mark_buffer_dirty (sbi->s_sbh); - sb->s_dirt =1 ; - } -} - -static inline int group_reserve_blocks (struct ext2_group_desc *desc, -struct buffer_head *bh,int count) -{ -unsigned free_blocks; +unsigned free_blocks; -if (!desc->bg_free_blocks_count) -return 0 ; - - free_blocks =le16_to_cpu (desc->bg_free_blocks_count); -if (free_blocks < count) - count = free_blocks; - desc->bg_free_blocks_count =cpu_to_le16 (free_blocks - count); -mark_buffer_dirty (bh); -return count; -} +spin_lock (&bgi->balloc_lock); -static inline void group_release_blocks (struct ext2_group_desc *desc, -struct buffer_head *bh,int count) -{ -if (count) { -unsigned free_blocks =le16_to_cpu (desc->bg_free_blocks_count); + free_blocks =le16_to_cpu (desc->bg_free_blocks_count); desc->bg_free_blocks_count =cpu_to_le16 (free_blocks + count); + +spin_unlock (&bgi->balloc_lock); +dcounter_add (&EXT2_SB (sb)->free_blocks_dc, count); + sb->s_dirt =1 ;mark_buffer_dirty (bh); } }
@@ -172,12 +174,11 @@unsigned long i;unsigned long overflow;struct super_block * sb = inode->i_sb; +struct ext2_sb_info * sbi =EXT2_SB (sb);struct ext2_group_desc * desc; -struct ext2_super_block * es; +struct ext2_super_block * es = sbi->s_es;unsigned freed =0 , group_freed; -lock_super (sb); - es =EXT2_SB (sb)->s_es;if (block <le32_to_cpu (es->s_first_data_block) || block + count < block || block + count >le32_to_cpu (es->s_blocks_count)) {
@@ -215,16 +216,17 @@if (in_range (le32_to_cpu (desc->bg_block_bitmap), block, count) ||in_range (le32_to_cpu (desc->bg_inode_bitmap), block, count) ||in_range (block,le32_to_cpu (desc->bg_inode_table), -EXT2_SB (sb)->s_itb_per_group) || + sbi->s_itb_per_group) ||in_range (block + count -1 ,le32_to_cpu (desc->bg_inode_table), -EXT2_SB (sb)->s_itb_per_group)) + sbi->s_itb_per_group))ext2_error (sb,"ext2_free_blocks" ,"Freeing blocks in system zones - " "Block = %lu, count = %lu" , block, count);for (i =0 , group_freed =0 ; i < count; i++) { -if (!ext2_clear_bit (bit + i, bitmap_bh->b_data)) +if (!ext2_clear_bit_atomic (&sbi->s_bgi[block_group].balloc_lock, + bit + i, (void *) bitmap_bh->b_data))ext2_error (sb,"ext2_free_blocks" ,"bit already cleared for block %lu" , block + i);
@@ -236,7 +238,8 @@if (sb->s_flags &MS_SYNCHRONOUS )sync_dirty_buffer (bitmap_bh); -group_release_blocks (desc, bh2, group_freed); +group_release_blocks (sb, &sbi->s_bgi[block_group], + desc, bh2, group_freed); freed += group_freed;if (overflow) {
@@ -246,18 +249,18 @@ } error_return:brelse (bitmap_bh); -release_blocks (sb, freed); -unlock_super (sb);DQUOT_FREE_BLOCK (inode, freed); } -static int grab_block (char *map,unsigned size,int goal) +static int grab_block (spinlock_t *lock,char *map,unsigned size,int goal) {int k;char *p, *r;if (!ext2_test_bit (goal, map)) goto got_it; + +repeat:if (goal) {/* * The goal was occupied; search forward for a free
@@ -297,7 +300,8 @@ }return -1 ; got_it: -ext2_set_bit (goal, map); +if (ext2_set_bit_atomic (lock, goal, (void *) map)) + goto repeat;return goal; }
@@ -309,17 +313,17 @@* bitmap, and then for any free bit if that fails. * This function also updates quota and i_blocks field. */ -int ext2_new_block (struct inode * inode,unsigned long goal, -u32 * prealloc_count,u32 * prealloc_block,int * err) +int ext2_new_block (struct inode *inode,unsigned long goal, +u32 *prealloc_count,u32 *prealloc_block,int *err) {struct buffer_head *bitmap_bh =NULL ;struct buffer_head *gdp_bh;/* bh2 */ struct ext2_group_desc *desc;int group_no;/* i */ int ret_block;/* j */ -int bit;/* k */ +int bit;/* k */ int target_block;/* tmp */ -int block =0 ; +int block =0 , use_reserve =0 ;struct super_block *sb = inode->i_sb;struct ext2_sb_info *sbi =EXT2_SB (sb);struct ext2_super_block *es = sbi->s_es;
@@ -341,14 +345,7 @@ prealloc_goal--; dq_alloc = prealloc_goal +1 ; - -lock_super (sb); - - es_alloc =reserve_blocks (sb, dq_alloc); -if (!es_alloc) { - *err = -ENOSPC ; - goto out_unlock; - } + es_alloc = dq_alloc;ext2_debug ("goal=%lu.\n" , goal);
@@ -360,7 +357,8 @@if (!desc) goto io_error; - group_alloc =group_reserve_blocks (desc, gdp_bh, es_alloc); + group_alloc =group_reserve_blocks (sb, &sbi->s_bgi[group_no], + desc, gdp_bh, es_alloc,0 );if (group_alloc) { ret_block = ((goal -le32_to_cpu (es->s_first_data_block)) % group_size);
@@ -371,11 +369,13 @@ext2_debug ("goal is at %d:%d.\n" , group_no, ret_block); - ret_block =grab_block (bitmap_bh->b_data, + ret_block =grab_block (&sbi->s_bgi[group_no].balloc_lock, + bitmap_bh->b_data, group_size, ret_block);if (ret_block >=0 ) goto got_block; -group_release_blocks (desc, gdp_bh, group_alloc); +group_release_blocks (sb, &sbi->s_bgi[group_no], + desc, gdp_bh, group_alloc); group_alloc =0 ; }
@@ -385,6 +385,7 @@* Now search the rest of the groups. We assume that * i and desc correctly point to the last group visited. */ +repeat:for (bit =0 ; !group_alloc && bit < sbi->s_groups_count; bit++) { group_no++;
@@ -393,9 +394,18 @@ desc =ext2_get_group_desc (sb, group_no, &gdp_bh);if (!desc) goto io_error; - group_alloc =group_reserve_blocks (desc, gdp_bh, es_alloc); + group_alloc =group_reserve_blocks (sb, &sbi->s_bgi[group_no], + desc, gdp_bh, es_alloc, use_reserve); } -if (bit >= sbi->s_groups_count) { +if (!use_reserve) { +/* first time we did not try to allocate +* reserved blocks. now it looks like +* no more non-reserved blocks left. we +* will try to allocate reserved blocks -bzzz */ + use_reserve =1 ; + goto repeat; + } +if (!group_alloc) { *err = -ENOSPC ; goto out_release; }
@@ -404,13 +414,11 @@if (!bitmap_bh) goto io_error; - ret_block =grab_block (bitmap_bh->b_data, group_size,0 ); + ret_block =grab_block (&sbi->s_bgi[group_no].balloc_lock, + bitmap_bh->b_data, group_size,0 );if (ret_block <0 ) { -ext2_error (sb,"ext2_new_block" , -"Free blocks count corrupted for block group %d" , - group_no); group_alloc =0 ; - goto io_error; + goto repeat; } got_block:
@@ -452,7 +460,9 @@unsigned n;for (n =0 ; n < group_alloc && ++ret_block < group_size; n++) { -if (ext2_set_bit (ret_block, bitmap_bh->b_data)) +if (ext2_set_bit_atomic (&sbi->s_bgi[group_no].balloc_lock, + ret_block, + (void *) bitmap_bh->b_data))break ; } *prealloc_block = block +1 ;
@@ -471,10 +481,8 @@ *err =0 ; out_release: -group_release_blocks (desc, gdp_bh, group_alloc); -release_blocks (sb, es_alloc); -out_unlock: -unlock_super (sb); +group_release_blocks (sb, &sbi->s_bgi[group_no], + desc, gdp_bh, group_alloc);DQUOT_FREE_BLOCK (inode, dq_alloc); out:brelse (bitmap_bh);
@@ -485,13 +493,18 @@ goto out_release; } -unsigned long ext2_count_free_blocks (struct super_block * sb) +unsigned long ext2_count_free_blocks (struct super_block *sb) +{ +return dcounter_value (&EXT2_SB (sb)->free_blocks_dc); +} + +unsigned long ext2_count_free_blocks_old (struct super_block *sb) { -#ifdef EXT2FS_DEBUG -struct ext2_super_block * es; -unsigned long desc_count, bitmap_count, x;struct ext2_group_desc * desc; +unsigned long desc_count =0 ;int i; +#ifdef EXT2FS_DEBUG +unsigned long bitmap_count, x;lock_super (sb); es =EXT2_SB (sb)->s_es;
@@ -519,13 +532,18 @@unlock_super (sb);return bitmap_count;#else -return le32_to_cpu (EXT2_SB (sb)->s_es->s_free_blocks_count); +for (i =0 ; i <EXT2_SB (sb)->s_groups_count; i++) { + desc =ext2_get_group_desc (sb, i,NULL ); +if (!desc) +continue ; + desc_count +=le16_to_cpu (desc->bg_free_blocks_count); + } +return desc_count;#endif } -static inline int block_in_use (unsigned long block, -struct super_block * sb, -unsigned char * map) +static inline int +block_in_use (unsigned long block,struct super_block *sb,unsigned char *map) {return ext2_test_bit ((block -le32_to_cpu (EXT2_SB (sb)->s_es->s_first_data_block)) %EXT2_BLOCKS_PER_GROUP (sb), map);
fs/ext2/ialloc.c +112 -68
313 lines not on this page · raw message
fs/ext2/super.c +85 -10
168 lines not on this page · raw message
include/asm-alpha/bitops.h +2 -0
@@ -487,7 +487,9 @@#define ext2_set_bit __test_and_set_bit +#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a)#define ext2_clear_bit __test_and_clear_bit +#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a)#define ext2_test_bit test_bit#define ext2_find_first_zero_bit find_first_zero_bit#define ext2_find_next_zero_bit find_next_zero_bit
include/asm-arm/bitops.h +4 -0
@@ -357,8 +357,12 @@*/ #define ext2_set_bit (nr,p) \ __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_set_bit_atomic (lock,nr,p) \ + test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))#define ext2_clear_bit (nr,p) \ __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) +#define ext2_clear_bit_atomic (lock,nr,p) \ + test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))#define ext2_test_bit (nr,p) \ __test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))#define ext2_find_first_zero_bit (p,sz) \
include/asm-cris/bitops.h +2 -0
@@ -360,7 +360,9 @@#define hweight8 (x) generic_hweight8(x)#define ext2_set_bit test_and_set_bit +#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a)#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a)#define ext2_test_bit test_bit#define ext2_find_first_zero_bit find_first_zero_bit#define ext2_find_next_zero_bit find_next_zero_bit
include/asm-i386/bitops.h +4 -0
@@ -479,8 +479,12 @@#define ext2_set_bit (nr,addr) \ __test_and_set_bit((nr),(unsigned long*)addr) +#define ext2_set_bit_atomic (lock,nr,addr) \ + test_and_set_bit((nr),(unsigned long*)addr)#define ext2_clear_bit (nr, addr) \ __test_and_clear_bit((nr),(unsigned long*)addr) +#define ext2_clear_bit_atomic (lock,nr, addr) \ + test_and_clear_bit((nr),(unsigned long*)addr)#define ext2_test_bit (nr, addr) test_bit((nr),(unsigned long*)addr)#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_bit((unsigned long*)addr, size)
include/asm-ia64/bitops.h +2 -0
@@ -453,7 +453,9 @@#define __clear_bit (nr, addr) clear_bit(nr, addr)#define ext2_set_bit test_and_set_bit +#define ext2_set_atomic (l,n,a) test_and_set_bit(n,a)#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_atomic (l,n,a) test_and_clear_bit(n,a)#define ext2_test_bit test_bit#define ext2_find_first_zero_bit find_first_zero_bit#define ext2_find_next_zero_bit find_next_zero_bit
include/asm-m68k/bitops.h +18 -0
@@ -365,6 +365,24 @@return retval; } +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +extern __inline__int ext2_test_bit (int nr,const volatile void *vaddr) {
include/asm-m68knommu/bitops.h +18 -0
@@ -402,6 +402,24 @@return retval; } +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +extern __inline__int ext2_test_bit (int nr,const volatile void * addr) {int mask;
include/asm-mips/bitops.h +20 -0
@@ -824,6 +824,24 @@return retval; } +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +extern __inline__int ext2_test_bit (int nr,const void * addr) {int mask;
@@ -890,7 +908,9 @@/* Native ext2 byte ordering, just collapse using defines. */ #define ext2_set_bit (nr, addr) test_and_set_bit((nr), (addr)) +#define ext2_set_bit_atomic (lock, nr, addr) test_and_set_bit((nr), (addr))#define ext2_clear_bit (nr, addr) test_and_clear_bit((nr), (addr)) +#define ext2_clear_bit_atomic (lock, nr, addr) test_and_clear_bit((nr), (addr))#define ext2_test_bit (nr, addr) test_bit((nr), (addr))#define ext2_find_first_zero_bit (addr, size) find_first_zero_bit((addr), (size))#define ext2_find_next_zero_bit (addr, size, offset) \
include/asm-mips64/bitops.h +20 -0
@@ -531,6 +531,24 @@return retval; } +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +extern inline int ext2_test_bit (int nr,const void * addr) {
@@ -599,7 +617,9 @@/* Native ext2 byte ordering, just collapse using defines. */ #define ext2_set_bit (nr, addr) test_and_set_bit((nr), (addr)) +#define ext2_set_bit_atomic (lock, nr, addr) test_and_set_bit((nr), (addr))#define ext2_clear_bit (nr, addr) test_and_clear_bit((nr), (addr)) +#define ext2_clear_bit_atomic (lock, nr, addr) test_and_clear_bit((nr), (addr))#define ext2_test_bit (nr, addr) test_bit((nr), (addr))#define ext2_find_first_zero_bit (addr, size) find_first_zero_bit((addr), (size))#define ext2_find_next_zero_bit (addr, size, offset) \
include/asm-parisc/bitops.h +4 -0
@@ -389,10 +389,14 @@*/ #ifdef __LP64__#define ext2_set_bit (nr, addr) test_and_set_bit((nr) ^ 0x38, addr) +#define ext2_set_bit_atomic (l,nr,addr) test_and_set_bit((nr) ^ 0x38, addr)#define ext2_clear_bit (nr, addr) test_and_clear_bit((nr) ^ 0x38, addr) +#define ext2_clear_bit_atomic (l,nr,addr) test_and_clear_bit((nr) ^ 0x38, addr)#else #define ext2_set_bit (nr, addr) test_and_set_bit((nr) ^ 0x18, addr) +#define ext2_set_bit_atomic (l,nr,addr) test_and_set_bit((nr) ^ 0x18, addr)#define ext2_clear_bit (nr, addr) test_and_clear_bit((nr) ^ 0x18, addr) +#define ext2_clear_bit_atomic (l,nr,addr) test_and_clear_bit((nr) ^ 0x18, addr)#endif #endif /* __KERNEL__ */
include/asm-ppc/bitops.h +2 -0
@@ -392,7 +392,9 @@#define ext2_set_bit (nr, addr) __test_and_set_bit((nr) ^ 0x18, (unsigned long *)(addr)) +#define ext2_set_bit_atomic (lock, nr, addr) test_and_set_bit((nr) ^ 0x18, (unsigned long *)(addr))#define ext2_clear_bit (nr, addr) __test_and_clear_bit((nr) ^ 0x18, (unsigned long *)(addr)) +#define ext2_clear_bit_atomic (lock, nr, addr) test_and_clear_bit((nr) ^ 0x18, (unsigned long *)(addr)) static __inline__ int ext2_test_bit(int nr, __const__ void * addr) {
include/asm-ppc64/bitops.h +19 -0
@@ -338,6 +338,25 @@ __test_and_set_le_bit((nr),(unsigned long*)addr)#define ext2_clear_bit (nr, addr) \ __test_and_clear_le_bit((nr),(unsigned long*)addr) + +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +#define ext2_test_bit (nr, addr) test_le_bit((nr),(unsigned long*)addr)#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_le_bit((unsigned long*)addr, size)
include/asm-s390/bitops.h +4 -0
@@ -805,8 +805,12 @@#define ext2_set_bit (nr, addr) \ test_and_set_bit((nr)^24, (unsigned long *)addr) +#define ext2_set_bit_atomic (lock, nr, addr) \ + test_and_set_bit((nr)^24, (unsigned long *)addr)#define ext2_clear_bit (nr, addr) \ test_and_clear_bit((nr)^24, (unsigned long *)addr) +#define ext2_clear_bit_atomic (lock, nr, addr) \ + test_and_clear_bit((nr)^24, (unsigned long *)addr)#define ext2_test_bit (nr, addr) \ test_bit((nr)^24, (unsigned long *)addr)
include/asm-s390x/bitops.h +4 -0
@@ -838,8 +838,12 @@#define ext2_set_bit (nr, addr) \ test_and_set_bit((nr)^56, (unsigned long *)addr) +#define ext2_set_bit_atomic (lock, nr, addr) \ + test_and_set_bit((nr)^56, (unsigned long *)addr)#define ext2_clear_bit (nr, addr) \ test_and_clear_bit((nr)^56, (unsigned long *)addr) +#define ext2_clear_bit_atomic (lock, nr, addr) \ + test_and_clear_bit((nr)^56, (unsigned long *)addr)#define ext2_test_bit (nr, addr) \ test_bit((nr)^56, (unsigned long *)addr)
include/asm-sh/bitops.h +18 -0
@@ -344,6 +344,24 @@ }#endif +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +/* Bitmap functions for the minix filesystem. */ #define minix_test_and_set_bit (nr,addr) test_and_set_bit(nr,addr)#define minix_set_bit (nr,addr) set_bit(nr,addr)
include/asm-sparc/bitops.h +19 -0
@@ -455,6 +455,25 @@#define ext2_set_bit __test_and_set_le_bit#define ext2_clear_bit __test_and_clear_le_bit + +#define ext2_set_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic (lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (addr)); \ + spin_unlock(lock); \ + ret; \ + }) +#define ext2_test_bit test_le_bit#define ext2_find_first_zero_bit find_first_zero_le_bit#define ext2_find_next_zero_bit find_next_zero_le_bit
include/asm-sparc64/bitops.h +2 -0
@@ -351,7 +351,9 @@#ifdef __KERNEL__#define ext2_set_bit (nr,addr) test_and_set_le_bit((nr),(unsigned long *)(addr)) +#define ext2_set_bit_atomic (lock,nr,addr) test_and_set_le_bit((nr),(unsigned long *)(addr))#define ext2_clear_bit (nr,addr) test_and_clear_le_bit((nr),(unsigned long *)(addr)) +#define ext2_clear_bit_atomic (lock,nr,addr) test_and_clear_le_bit((nr),(unsigned long *)(addr))#define ext2_test_bit (nr,addr) test_le_bit((nr),(unsigned long *)(addr))#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_le_bit((unsigned long *)(addr), (size))
include/asm-v850/bitops.h +2 -0
@@ -252,7 +252,9 @@#define hweight8 (x) generic_hweight8 (x)#define ext2_set_bit test_and_set_bit +#define ext2_set_bit_atomic (l,n,a) test_and_set_bit(n,a)#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_bit_atomic (l,n,a) test_and_clear_bit(n,a)#define ext2_test_bit test_bit#define ext2_find_first_zero_bit find_first_zero_bit#define ext2_find_next_zero_bit find_next_zero_bit
include/asm-x86_64/bitops.h +4 -0
@@ -487,8 +487,12 @@#define ext2_set_bit (nr,addr) \ __test_and_set_bit((nr),(unsigned long*)addr) +#define ext2_set_bit_atomic (lock,nr,addr) \ + test_and_set_bit((nr),(unsigned long*)addr)#define ext2_clear_bit (nr, addr) \ __test_and_clear_bit((nr),(unsigned long*)addr) +#define ext2_clear_bit_atomic (lock,nr,addr) \ + test_and_clear_bit((nr),(unsigned long*)addr)#define ext2_test_bit (nr, addr) test_bit((nr),(unsigned long*)addr)#define ext2_find_first_zero_bit (addr, size) \ find_first_zero_bit((unsigned long*)addr, size)
include/linux/dcounter.h +85 -0
85 lines not on this page · raw message
include/linux/ext2_fs_sb.h +13 -1
@@ -16,6 +16,15 @@#ifndef _LINUX_EXT2_FS_SB#define _LINUX_EXT2_FS_SB +#include <linux/dcounter.h> + +struct ext2_bg_info { +u8 debts; +spinlock_t balloc_lock; +spinlock_t ialloc_lock; +unsigned int reserved; +}____cacheline_aligned_in_smp ; +/* * second extended-fs super-block data in memory */
@@ -44,7 +53,10 @@int s_first_ino;u32 s_next_generation;unsigned long s_dir_count; - u8 *s_debts; +struct ext2_bg_info *s_bgi; +struct dcounter free_blocks_dc; +struct dcounter free_inodes_dc; + struct dcounter dirs_dc; };#endif /* _LINUX_EXT2_FS_SB */