mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
94ea4158f1
commit
ff01bb4832
28 changed files with 40 additions and 83 deletions
50
fs/buffer.c
50
fs/buffer.c
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue