]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
fs: move code out of buffer.c
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 16 Sep 2011 06:31:11 +0000 (02:31 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 4 Jan 2012 03:54:07 +0000 (22:54 -0500)
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>
28 files changed:
arch/powerpc/sysdev/axonram.c
block/genhd.c
block/ioctl.c
drivers/block/amiflop.c
drivers/block/brd.c
drivers/block/floppy.c
drivers/block/loop.c
drivers/cdrom/cdrom.c
drivers/md/dm.c
drivers/md/md.c
drivers/mtd/devices/block2mtd.c
drivers/s390/block/dasd.c
drivers/scsi/scsicam.c
drivers/tty/sysrq.c
fs/block_dev.c
fs/buffer.c
fs/cachefiles/interface.c
fs/cramfs/inode.c
fs/fs-writeback.c
fs/libfs.c
fs/quota/dquot.c
fs/quota/quota.c
fs/splice.c
fs/sync.c
include/linux/fs.h
kernel/power/swap.c
mm/page-writeback.c
mm/swap_state.c

index ba4271919062d65005c80156ac524baf796cf612..1c16141c031c9e2d2512b0d308a8456c15fd1ae1 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/bio.h>
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
index bf443a71b93e00356f44b4c048ad1dc73ce334dc..b7d1a0e42686c326d63615f277cffc70a1c27780 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/slab.h>
 #include <linux/kmod.h>
 #include <linux/kobj_map.h>
-#include <linux/buffer_head.h>
 #include <linux/mutex.h>
 #include <linux/idr.h>
 #include <linux/log2.h>
index ca939fc1030f29489f8a5f2c5a142c4e6a6f2264..91e7b19c86f476c1545c43f737e8075051530d50 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
 #include <linux/backing-dev.h>
-#include <linux/buffer_head.h>
+#include <linux/fs.h>
 #include <linux/blktrace_api.h>
 #include <asm/uaccess.h>
 
index 8eba86bba5992ec2b546559c96f7a848e0c2c4e4..386146d792d1a5e51ae8af06ed1ec001d08d1b06 100644 (file)
@@ -63,7 +63,7 @@
 #include <linux/mutex.h>
 #include <linux/amifdreg.h>
 #include <linux/amifd.h>
-#include <linux/buffer_head.h>
+#include <linux/fs.h>
 #include <linux/blkdev.h>
 #include <linux/elevator.h>
 #include <linux/interrupt.h>
index d22119d49e53e31073c4c5c8ab22438b7e7f9422..ec246437f5a44273911f6f6358f2a1fcc409478d 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/highmem.h>
 #include <linux/mutex.h>
 #include <linux/radix-tree.h>
-#include <linux/buffer_head.h> /* invalidate_bh_lrus() */
+#include <linux/fs.h>
 #include <linux/slab.h>
 
 #include <asm/uaccess.h>
@@ -402,14 +402,13 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode,
        error = -EBUSY;
        if (bdev->bd_openers <= 1) {
                /*
-                * Invalidate the cache first, so it isn't written
-                * back to the device.
+                * Kill the cache first, so it isn't written back to the
+                * device.
                 *
                 * Another thread might instantiate more buffercache here,
                 * but there is not much we can do to close that race.
                 */
-               invalidate_bh_lrus();
-               truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
+               kill_bdev(bdev);
                brd_free_pages(brd);
                error = 0;
        }
index 9955a53733b29c4501e9200d6870d2d771c23312..510fb10ec45a9fc532820b5a9cb3158c2abd66d9 100644 (file)
@@ -188,7 +188,6 @@ static int print_unex = 1;
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mod_devicetable.h>
-#include <linux/buffer_head.h> /* for invalidate_buffers() */
 #include <linux/mutex.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
index 1e888c9e85b3dd10a42238a6588dd4f0b2f7c9e1..f00257782fccd34af45fc233ecb26255828e7a0a 100644 (file)
@@ -69,7 +69,6 @@
 #include <linux/freezer.h>
 #include <linux/mutex.h>
 #include <linux/writeback.h>
-#include <linux/buffer_head.h>         /* for invalidate_bdev() */
 #include <linux/completion.h>
 #include <linux/highmem.h>
 #include <linux/kthread.h>
index f997c27d79e299579975badce89975aefc9f941a..2118211aff99835e457f266a10caeed72de7c110 100644 (file)
 
 #include <linux/module.h>
 #include <linux/fs.h>
-#include <linux/buffer_head.h>
 #include <linux/major.h>
 #include <linux/types.h>
 #include <linux/errno.h>
index 4720f68f817e66eb1e08da1535512b9cd6455fff..b89c548ec3f88612eb4a6fec4d6230ad413ed9c1 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/moduleparam.h>
 #include <linux/blkpg.h>
 #include <linux/bio.h>
-#include <linux/buffer_head.h>
 #include <linux/mempool.h>
 #include <linux/slab.h>
 #include <linux/idr.h>
index f47f1f8ac44bc16677b212f35b398dae093dab87..5d1b6762f108263f5e9ea7861215543b34b42685 100644 (file)
@@ -36,8 +36,7 @@
 #include <linux/blkdev.h>
 #include <linux/sysctl.h>
 #include <linux/seq_file.h>
-#include <linux/mutex.h>
-#include <linux/buffer_head.h> /* for invalidate_bdev */
+#include <linux/fs.h>
 #include <linux/poll.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
index b78f23169d4e7dce23848eba02b7cf9b8f6cd43f..ebeabc727f70319b35ca2c1ab80b4aeee283c081 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/list.h>
 #include <linux/init.h>
 #include <linux/mtd/mtd.h>
-#include <linux/buffer_head.h>
 #include <linux/mutex.h>
 #include <linux/mount.h>
 #include <linux/slab.h>
index 65894f05a801d073974ae11a6599b59c45e5daee..2de5b60ee8c85f20868059c8764fa02708c6c778 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/ctype.h>
 #include <linux/major.h>
 #include <linux/slab.h>
-#include <linux/buffer_head.h>
 #include <linux/hdreg.h>
 #include <linux/async.h>
 #include <linux/mutex.h>
index 6803b1e26eccd63986dda5198bcc9cc2abe36f38..92d24d6dcb395399da066c6604e830b0c775a482 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/genhd.h>
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <asm/unaligned.h>
 
 #include <scsi/scsicam.h>
index 43db715f15026d491d87cc1d3c7e443ddcf2f341..7867b7c4538e1cb02b7b4192f53f2f6783bed104 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/module.h>
 #include <linux/suspend.h>
 #include <linux/writeback.h>
-#include <linux/buffer_head.h>         /* for fsync_bdev() */
 #include <linux/swap.h>
 #include <linux/spinlock.h>
 #include <linux/vt_kern.h>
@@ -41,6 +40,7 @@
 #include <linux/oom.h>
 #include <linux/slab.h>
 #include <linux/input.h>
+#include <linux/uaccess.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq_regs.h>
index 7866cdd9fe7020ad6909551c62a80b0864306cb4..69a5b6fbee2bd9a000a92b34afe4e8338ae989ab 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/blkpg.h>
 #include <linux/buffer_head.h>
+#include <linux/swap.h>
 #include <linux/pagevec.h>
 #include <linux/writeback.h>
 #include <linux/mpage.h>
@@ -25,6 +26,7 @@
 #include <linux/namei.h>
 #include <linux/log2.h>
 #include <linux/kmemleak.h>
+#include <linux/cleancache.h>
 #include <asm/uaccess.h>
 #include "internal.h"
 
@@ -82,13 +84,35 @@ static sector_t max_block(struct block_device *bdev)
 }
 
 /* Kill _all_ buffers and pagecache , dirty or not.. */
-static void kill_bdev(struct block_device *bdev)
+void kill_bdev(struct block_device *bdev)
 {
-       if (bdev->bd_inode->i_mapping->nrpages == 0)
+       struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+       if (mapping->nrpages == 0)
                return;
+
        invalidate_bh_lrus();
-       truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
+       truncate_inode_pages(mapping, 0);
 }      
+EXPORT_SYMBOL(kill_bdev);
+
+/* Invalidate clean unused buffers and pagecache. */
+void invalidate_bdev(struct block_device *bdev)
+{
+       struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+       if (mapping->nrpages == 0)
+               return;
+
+       invalidate_bh_lrus();
+       lru_add_drain_all();    /* make sure all lru add caches are flushed */
+       invalidate_mapping_pages(mapping, 0, -1);
+       /* 99% of the time, we don't need to flush the cleancache on the bdev.
+        * But, for the strange corners, lets be cautious
+        */
+       cleancache_flush_inode(mapping);
+}
+EXPORT_SYMBOL(invalidate_bdev);
 
 int set_blocksize(struct block_device *bdev, int size)
 {
index 19d8eb7fdc81a1ed4be1fd4bd248d1037598fb1a..1a30db77af3257505eae9706db2c366146666751 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/bitops.h>
 #include <linux/mpage.h>
 #include <linux/bit_spinlock.h>
-#include <linux/cleancache.h>
 
 static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
 
@@ -231,55 +230,6 @@ out:
        return ret;
 }
 
-/* If invalidate_buffers() will trash dirty buffers, it means some kind
-   of fs corruption is going on. Trashing dirty data always imply losing
-   information that was supposed to be just stored on the physical layer
-   by the user.
-
-   Thus invalidate_buffers in general usage is not allwowed to trash
-   dirty buffers. For example ioctl(FLSBLKBUF) expects dirty data to
-   be preserved.  These buffers are simply skipped.
-  
-   We also skip buffers which are still in use.  For example this can
-   happen if a userspace program is reading the block device.
-
-   NOTE: In the case where the user removed a removable-media-disk even if
-   there's still dirty data not synced on disk (due a bug in the device driver
-   or due an error of the user), by not destroying the dirty buffers we could
-   generate corruption also on the next media inserted, thus a parameter is
-   necessary to handle this case in the most safe way possible (trying
-   to not corrupt also the new disk inserted with the data belonging to
-   the old now corrupted disk). Also for the ramdisk the natural thing
-   to do in order to release the ramdisk memory is to destroy dirty buffers.
-
-   These are two special cases. Normal usage imply the device driver
-   to issue a sync on the device (without waiting I/O completion) and
-   then an invalidate_buffers call that doesn't trash dirty buffers.
-
-   For handling cache coherency with the blkdev pagecache the 'update' case
-   is been introduced. It is needed to re-read from disk any pinned
-   buffer. NOTE: re-reading from disk is destructive so we can do it only
-   when we assume nobody is changing the buffercache under our I/O and when
-   we think the disk contains more recent information than the buffercache.
-   The update == 1 pass marks the buffers we need to update, the update == 2
-   pass does the actual I/O. */
-void invalidate_bdev(struct block_device *bdev)
-{
-       struct address_space *mapping = bdev->bd_inode->i_mapping;
-
-       if (mapping->nrpages == 0)
-               return;
-
-       invalidate_bh_lrus();
-       lru_add_drain_all();    /* make sure all lru add caches are flushed */
-       invalidate_mapping_pages(mapping, 0, -1);
-       /* 99% of the time, we don't need to flush the cleancache on the bdev.
-        * But, for the strange corners, lets be cautious
-        */
-       cleancache_flush_inode(mapping);
-}
-EXPORT_SYMBOL(invalidate_bdev);
-
 /*
  * Kick the writeback threads then try to free up some ZONE_NORMAL memory.
  */
index 1064805e653b481a086f3b51ad4d8bf32784b56b..67bef6d01484a1b058f6513fce1277db72903650 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/slab.h>
 #include <linux/mount.h>
-#include <linux/buffer_head.h>
 #include "internal.h"
 
 #define list_to_page(head) (list_entry((head)->prev, struct page, lru))
index 739fb59bcdc25123f3bdc620246045ddabdac34d..c37adb2221132d357aaa78919cc0ce40c2135d69 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/cramfs_fs.h>
 #include <linux/slab.h>
 #include <linux/cramfs_fs_sb.h>
-#include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/mutex.h>
 
index 517f211a3bd45c60f607e5da7d957bc739d55d47..80a4574028f106f76db786033f95972f33e39bab 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/writeback.h>
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
-#include <linux/buffer_head.h>
 #include <linux/tracepoint.h>
 #include "internal.h"
 
index f6d411eef1e73d52c4d62c3b65432565accdff49..5b2dbb3ba4fca95f3aab72c39f570c16a61c5c02 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/mutex.h>
 #include <linux/exportfs.h>
 #include <linux/writeback.h>
-#include <linux/buffer_head.h>
+#include <linux/buffer_head.h> /* sync_mapping_buffers */
 
 #include <asm/uaccess.h>
 
index 5b572c89e6c4bcbb028b5faf417c098503cc2991..5d81e92daf837e66d4a8862e1c06ff012ec8d827 100644 (file)
@@ -73,7 +73,6 @@
 #include <linux/security.h>
 #include <linux/kmod.h>
 #include <linux/namei.h>
-#include <linux/buffer_head.h>
 #include <linux/capability.h>
 #include <linux/quotaops.h>
 #include "../internal.h" /* ugh */
index 35f4b0ecdeb3de1ba41756c3985436c6f67b5148..7898cd688a0073b8caf6c193fc3deb1dc8722f5f 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/kernel.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
-#include <linux/buffer_head.h>
 #include <linux/capability.h>
 #include <linux/quotaops.h>
 #include <linux/types.h>
index fa2defa8afcf3d18e2fd8fcebcc0a88f1d12fdac..1ec0493266b3783e6af4e053668136d0ec458138 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/mm_inline.h>
 #include <linux/swap.h>
 #include <linux/writeback.h>
-#include <linux/buffer_head.h>
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/uio.h>
index 101b8ef901d78625d00c337d0df1c4e2e25c5133..f3501ef392354c9a4ae7a13a63b6aa98f6ec9b3f 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -14,7 +14,6 @@
 #include <linux/linkage.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
-#include <linux/buffer_head.h>
 #include <linux/backing-dev.h>
 #include "internal.h"
 
index cec429d76ab06a51e0a0d3c5b872822f3c245f69..e853ba5eddd4c9e9b2ce17cdc91c36c2e01de8cb 100644 (file)
@@ -2092,6 +2092,7 @@ extern void bd_forget(struct inode *inode);
 extern void bdput(struct block_device *);
 extern void invalidate_bdev(struct block_device *);
 extern int sync_blockdev(struct block_device *bdev);
+extern void kill_bdev(struct block_device *);
 extern struct super_block *freeze_bdev(struct block_device *);
 extern void emergency_thaw_all(void);
 extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
@@ -2099,6 +2100,7 @@ extern int fsync_bdev(struct block_device *);
 #else
 static inline void bd_forget(struct inode *inode) {}
 static inline int sync_blockdev(struct block_device *bdev) { return 0; }
+static inline void kill_bdev(struct block_device *bdev) {}
 static inline void invalidate_bdev(struct block_device *bdev) {}
 
 static inline struct super_block *freeze_bdev(struct block_device *sb)
@@ -2415,6 +2417,7 @@ extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
                                unsigned long nr_segs, loff_t pos);
 extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
                        int datasync);
+extern void block_sync_page(struct page *page);
 
 /* fs/splice.c */
 extern ssize_t generic_file_splice_read(struct file *, loff_t *,
index 11a594c4ba251227c6fc25b62c307747356fccfc..3739ecced085db0141557feec608bb3eccbb0c07 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/bitops.h>
 #include <linux/genhd.h>
 #include <linux/device.h>
-#include <linux/buffer_head.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/swap.h>
index 50f08241f9815668d73b1adfcd5c9585f11bbc15..8616ef3025a44a80e59448f960620b858b7445e3 100644 (file)
@@ -32,7 +32,7 @@
 #include <linux/sysctl.h>
 #include <linux/cpu.h>
 #include <linux/syscalls.h>
-#include <linux/buffer_head.h>
+#include <linux/buffer_head.h> /* __set_page_dirty_buffers */
 #include <linux/pagevec.h>
 #include <trace/events/writeback.h>
 
index 78cc4d1f6ccefe617698761cf198a7eb8a6db2bc..ea6b32d61873185f59db1eb9ae303488ec6de471 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/swapops.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
-#include <linux/buffer_head.h>
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 #include <linux/migrate.h>