diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-09-16 02:31:11 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:54:07 -0500 |
commit | ff01bb4832651c6d25ac509a06a10fcbd75c461c (patch) | |
tree | bbfdebd317db97d346df78293566f36e883b1be9 /fs | |
parent | 94ea4158f1733e3b10cef067d535f504866e0c41 (diff) |
fs: move code out of buffer.c
Move invalidate_bdev, block_sync_page into fs/block_dev.c. Export
kill_bdev as well, so brd doesn't have to open code it. Reduce
buffer_head.h requirement accordingly.
Removed a rather large comment from invalidate_bdev, as it looked a bit
obsolete to bother moving. The small comment replacing it says enough.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 30 | ||||
-rw-r--r-- | fs/buffer.c | 50 | ||||
-rw-r--r-- | fs/cachefiles/interface.c | 1 | ||||
-rw-r--r-- | fs/cramfs/inode.c | 1 | ||||
-rw-r--r-- | fs/fs-writeback.c | 1 | ||||
-rw-r--r-- | fs/libfs.c | 2 | ||||
-rw-r--r-- | fs/quota/dquot.c | 1 | ||||
-rw-r--r-- | fs/quota/quota.c | 1 | ||||
-rw-r--r-- | fs/splice.c | 1 | ||||
-rw-r--r-- | fs/sync.c | 1 |
10 files changed, 28 insertions, 61 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 7866cdd9fe70..69a5b6fbee2b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/blkpg.h> | 18 | #include <linux/blkpg.h> |
19 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> |
20 | #include <linux/swap.h> | ||
20 | #include <linux/pagevec.h> | 21 | #include <linux/pagevec.h> |
21 | #include <linux/writeback.h> | 22 | #include <linux/writeback.h> |
22 | #include <linux/mpage.h> | 23 | #include <linux/mpage.h> |
@@ -25,6 +26,7 @@ | |||
25 | #include <linux/namei.h> | 26 | #include <linux/namei.h> |
26 | #include <linux/log2.h> | 27 | #include <linux/log2.h> |
27 | #include <linux/kmemleak.h> | 28 | #include <linux/kmemleak.h> |
29 | #include <linux/cleancache.h> | ||
28 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
29 | #include "internal.h" | 31 | #include "internal.h" |
30 | 32 | ||
@@ -82,13 +84,35 @@ static sector_t max_block(struct block_device *bdev) | |||
82 | } | 84 | } |
83 | 85 | ||
84 | /* Kill _all_ buffers and pagecache , dirty or not.. */ | 86 | /* Kill _all_ buffers and pagecache , dirty or not.. */ |
85 | static void kill_bdev(struct block_device *bdev) | 87 | void kill_bdev(struct block_device *bdev) |
86 | { | 88 | { |
87 | if (bdev->bd_inode->i_mapping->nrpages == 0) | 89 | struct address_space *mapping = bdev->bd_inode->i_mapping; |
90 | |||
91 | if (mapping->nrpages == 0) | ||
88 | return; | 92 | return; |
93 | |||
89 | invalidate_bh_lrus(); | 94 | invalidate_bh_lrus(); |
90 | truncate_inode_pages(bdev->bd_inode->i_mapping, 0); | 95 | truncate_inode_pages(mapping, 0); |
91 | } | 96 | } |
97 | EXPORT_SYMBOL(kill_bdev); | ||
98 | |||
99 | /* Invalidate clean unused buffers and pagecache. */ | ||
100 | void invalidate_bdev(struct block_device *bdev) | ||
101 | { | ||
102 | struct address_space *mapping = bdev->bd_inode->i_mapping; | ||
103 | |||
104 | if (mapping->nrpages == 0) | ||
105 | return; | ||
106 | |||
107 | invalidate_bh_lrus(); | ||
108 | lru_add_drain_all(); /* make sure all lru add caches are flushed */ | ||
109 | invalidate_mapping_pages(mapping, 0, -1); | ||
110 | /* 99% of the time, we don't need to flush the cleancache on the bdev. | ||
111 | * But, for the strange corners, lets be cautious | ||
112 | */ | ||
113 | cleancache_flush_inode(mapping); | ||
114 | } | ||
115 | EXPORT_SYMBOL(invalidate_bdev); | ||
92 | 116 | ||
93 | int set_blocksize(struct block_device *bdev, int size) | 117 | int set_blocksize(struct block_device *bdev, int size) |
94 | { | 118 | { |
diff --git a/fs/buffer.c b/fs/buffer.c index 19d8eb7fdc81..1a30db77af32 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/bitops.h> | 41 | #include <linux/bitops.h> |
42 | #include <linux/mpage.h> | 42 | #include <linux/mpage.h> |
43 | #include <linux/bit_spinlock.h> | 43 | #include <linux/bit_spinlock.h> |
44 | #include <linux/cleancache.h> | ||
45 | 44 | ||
46 | static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); | 45 | static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); |
47 | 46 | ||
@@ -231,55 +230,6 @@ out: | |||
231 | return ret; | 230 | return ret; |
232 | } | 231 | } |
233 | 232 | ||
234 | /* If invalidate_buffers() will trash dirty buffers, it means some kind | ||
235 | of fs corruption is going on. Trashing dirty data always imply losing | ||
236 | information that was supposed to be just stored on the physical layer | ||
237 | by the user. | ||
238 | |||
239 | Thus invalidate_buffers in general usage is not allwowed to trash | ||
240 | dirty buffers. For example ioctl(FLSBLKBUF) expects dirty data to | ||
241 | be preserved. These buffers are simply skipped. | ||
242 | |||
243 | We also skip buffers which are still in use. For example this can | ||
244 | happen if a userspace program is reading the block device. | ||
245 | |||
246 | NOTE: In the case where the user removed a removable-media-disk even if | ||
247 | there's still dirty data not synced on disk (due a bug in the device driver | ||
248 | or due an error of the user), by not destroying the dirty buffers we could | ||
249 | generate corruption also on the next media inserted, thus a parameter is | ||
250 | necessary to handle this case in the most safe way possible (trying | ||
251 | to not corrupt also the new disk inserted with the data belonging to | ||
252 | the old now corrupted disk). Also for the ramdisk the natural thing | ||
253 | to do in order to release the ramdisk memory is to destroy dirty buffers. | ||
254 | |||
255 | These are two special cases. Normal usage imply the device driver | ||
256 | to issue a sync on the device (without waiting I/O completion) and | ||
257 | then an invalidate_buffers call that doesn't trash dirty buffers. | ||
258 | |||
259 | For handling cache coherency with the blkdev pagecache the 'update' case | ||
260 | is been introduced. It is needed to re-read from disk any pinned | ||
261 | buffer. NOTE: re-reading from disk is destructive so we can do it only | ||
262 | when we assume nobody is changing the buffercache under our I/O and when | ||
263 | we think the disk contains more recent information than the buffercache. | ||
264 | The update == 1 pass marks the buffers we need to update, the update == 2 | ||
265 | pass does the actual I/O. */ | ||
266 | void invalidate_bdev(struct block_device *bdev) | ||
267 | { | ||
268 | struct address_space *mapping = bdev->bd_inode->i_mapping; | ||
269 | |||
270 | if (mapping->nrpages == 0) | ||
271 | return; | ||
272 | |||
273 | invalidate_bh_lrus(); | ||
274 | lru_add_drain_all(); /* make sure all lru add caches are flushed */ | ||
275 | invalidate_mapping_pages(mapping, 0, -1); | ||
276 | /* 99% of the time, we don't need to flush the cleancache on the bdev. | ||
277 | * But, for the strange corners, lets be cautious | ||
278 | */ | ||
279 | cleancache_flush_inode(mapping); | ||
280 | } | ||
281 | EXPORT_SYMBOL(invalidate_bdev); | ||
282 | |||
283 | /* | 233 | /* |
284 | * Kick the writeback threads then try to free up some ZONE_NORMAL memory. | 234 | * Kick the writeback threads then try to free up some ZONE_NORMAL memory. |
285 | */ | 235 | */ |
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 1064805e653b..67bef6d01484 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/mount.h> | 13 | #include <linux/mount.h> |
14 | #include <linux/buffer_head.h> | ||
15 | #include "internal.h" | 14 | #include "internal.h" |
16 | 15 | ||
17 | #define list_to_page(head) (list_entry((head)->prev, struct page, lru)) | 16 | #define list_to_page(head) (list_entry((head)->prev, struct page, lru)) |
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 739fb59bcdc2..c37adb222113 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/cramfs_fs.h> | 20 | #include <linux/cramfs_fs.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/cramfs_fs_sb.h> | 22 | #include <linux/cramfs_fs_sb.h> |
23 | #include <linux/buffer_head.h> | ||
24 | #include <linux/vfs.h> | 23 | #include <linux/vfs.h> |
25 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
26 | 25 | ||
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 517f211a3bd4..80a4574028f1 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/writeback.h> | 25 | #include <linux/writeback.h> |
26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
27 | #include <linux/backing-dev.h> | 27 | #include <linux/backing-dev.h> |
28 | #include <linux/buffer_head.h> | ||
29 | #include <linux/tracepoint.h> | 28 | #include <linux/tracepoint.h> |
30 | #include "internal.h" | 29 | #include "internal.h" |
31 | 30 | ||
diff --git a/fs/libfs.c b/fs/libfs.c index f6d411eef1e7..5b2dbb3ba4fc 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/mutex.h> | 12 | #include <linux/mutex.h> |
13 | #include <linux/exportfs.h> | 13 | #include <linux/exportfs.h> |
14 | #include <linux/writeback.h> | 14 | #include <linux/writeback.h> |
15 | #include <linux/buffer_head.h> | 15 | #include <linux/buffer_head.h> /* sync_mapping_buffers */ |
16 | 16 | ||
17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | 18 | ||
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 5b572c89e6c4..5d81e92daf83 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -73,7 +73,6 @@ | |||
73 | #include <linux/security.h> | 73 | #include <linux/security.h> |
74 | #include <linux/kmod.h> | 74 | #include <linux/kmod.h> |
75 | #include <linux/namei.h> | 75 | #include <linux/namei.h> |
76 | #include <linux/buffer_head.h> | ||
77 | #include <linux/capability.h> | 76 | #include <linux/capability.h> |
78 | #include <linux/quotaops.h> | 77 | #include <linux/quotaops.h> |
79 | #include "../internal.h" /* ugh */ | 78 | #include "../internal.h" /* ugh */ |
diff --git a/fs/quota/quota.c b/fs/quota/quota.c index 35f4b0ecdeb3..7898cd688a00 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/security.h> | 14 | #include <linux/security.h> |
15 | #include <linux/syscalls.h> | 15 | #include <linux/syscalls.h> |
16 | #include <linux/buffer_head.h> | ||
17 | #include <linux/capability.h> | 16 | #include <linux/capability.h> |
18 | #include <linux/quotaops.h> | 17 | #include <linux/quotaops.h> |
19 | #include <linux/types.h> | 18 | #include <linux/types.h> |
diff --git a/fs/splice.c b/fs/splice.c index fa2defa8afcf..1ec0493266b3 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/mm_inline.h> | 25 | #include <linux/mm_inline.h> |
26 | #include <linux/swap.h> | 26 | #include <linux/swap.h> |
27 | #include <linux/writeback.h> | 27 | #include <linux/writeback.h> |
28 | #include <linux/buffer_head.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/syscalls.h> | 29 | #include <linux/syscalls.h> |
31 | #include <linux/uio.h> | 30 | #include <linux/uio.h> |
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/linkage.h> | 14 | #include <linux/linkage.h> |
15 | #include <linux/pagemap.h> | 15 | #include <linux/pagemap.h> |
16 | #include <linux/quotaops.h> | 16 | #include <linux/quotaops.h> |
17 | #include <linux/buffer_head.h> | ||
18 | #include <linux/backing-dev.h> | 17 | #include <linux/backing-dev.h> |
19 | #include "internal.h" | 18 | #include "internal.h" |
20 | 19 | ||