diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-05-06 17:49:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:55 -0400 |
commit | f9a14399aea13830d8af6798a53207bb0a900945 (patch) | |
tree | b2501f1ce1d2a4564cd9a29c55705e524f594ad1 /fs | |
parent | f98393a64ca1392130724c3acb4e3f325801d2b6 (diff) |
mm: optimize kill_bdev()
Remove duplicate work in kill_bdev().
It currently invalidates and then truncates the bdev's mapping.
invalidate_mapping_pages() will opportunistically remove pages from the
mapping. And truncate_inode_pages() will forcefully remove all pages.
The only thing truncate doesn't do is flush the bh lrus. So do that
explicitly. This avoids (very unlikely) but possible invalid lookup
results if the same bdev is quickly re-issued.
It also will prevent extreme kernel latencies which are observed when
blockdevs which have a large amount of pagecache are unmounted, by avoiding
invalidate_mapping_pages() on that path. invalidate_mapping_pages() has no
cond_resched (it can be called under spinlock), whereas truncate_inode_pages()
has one.
[akpm@linux-foundation.org: restore nrpages==0 optimisation]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 6 | ||||
-rw-r--r-- | fs/buffer.c | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 21e59acbcfdf..6fe49b9349ea 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -55,10 +55,12 @@ static sector_t max_block(struct block_device *bdev) | |||
55 | return retval; | 55 | return retval; |
56 | } | 56 | } |
57 | 57 | ||
58 | /* Kill _all_ buffers, dirty or not.. */ | 58 | /* Kill _all_ buffers and pagecache , dirty or not.. */ |
59 | static void kill_bdev(struct block_device *bdev) | 59 | static void kill_bdev(struct block_device *bdev) |
60 | { | 60 | { |
61 | invalidate_bdev(bdev); | 61 | if (bdev->bd_inode->i_mapping->nrpages == 0) |
62 | return; | ||
63 | invalidate_bh_lrus(); | ||
62 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); | 64 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); |
63 | } | 65 | } |
64 | 66 | ||
diff --git a/fs/buffer.c b/fs/buffer.c index 630df3e6fe0c..80291aad6de6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/bit_spinlock.h> | 44 | #include <linux/bit_spinlock.h> |
45 | 45 | ||
46 | static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); | 46 | static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); |
47 | static void invalidate_bh_lrus(void); | ||
48 | 47 | ||
49 | #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers) | 48 | #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers) |
50 | 49 | ||
@@ -1403,7 +1402,7 @@ static void invalidate_bh_lru(void *arg) | |||
1403 | put_cpu_var(bh_lrus); | 1402 | put_cpu_var(bh_lrus); |
1404 | } | 1403 | } |
1405 | 1404 | ||
1406 | static void invalidate_bh_lrus(void) | 1405 | void invalidate_bh_lrus(void) |
1407 | { | 1406 | { |
1408 | on_each_cpu(invalidate_bh_lru, NULL, 1, 1); | 1407 | on_each_cpu(invalidate_bh_lru, NULL, 1, 1); |
1409 | } | 1408 | } |