Commit e059d5da authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add blk_run_page()

From: Andrea Arcangeli <andrea@suse.de>

From: Jens Axboe

Add blk_run_page() API.  This is so that we can pass the target page all the
way down to (for example) the swap unplug function.  So swap can work out
which blockdevs back this particular page.
parent 485ba3c3
......@@ -1147,7 +1147,8 @@ void generic_unplug_device(request_queue_t *q)
}
EXPORT_SYMBOL(generic_unplug_device);
static void blk_backing_dev_unplug(struct backing_dev_info *bdi)
static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
struct page *page)
{
request_queue_t *q = bdi->unplug_io_data;
......
......@@ -113,12 +113,7 @@ static int bh_wake_function(wait_queue_t *wait, unsigned mode,
static void sync_buffer(struct buffer_head *bh)
{
struct block_device *bd;
smp_mb();
bd = bh->b_bdev;
if (bd)
blk_run_address_space(bd->bd_inode->i_mapping);
blk_run_page(bh->b_page);
}
void fastcall __lock_buffer(struct buffer_head *bh)
......@@ -2960,10 +2955,7 @@ EXPORT_SYMBOL(try_to_free_buffers);
int block_sync_page(struct page *page)
{
struct address_space *mapping;
smp_mb();
mapping = page->mapping;
blk_run_address_space(mapping);
blk_run_page(page);
return 0;
}
......
......@@ -28,12 +28,12 @@ struct backing_dev_info {
int memory_backed; /* Cannot clean pages with writepage */
congested_fn *congested_fn; /* Function pointer if device is md/dm */
void *congested_data; /* Pointer to aux data for congested func */
void (*unplug_io_fn)(struct backing_dev_info *);
void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
void *unplug_io_data;
};
extern struct backing_dev_info default_backing_dev_info;
void default_unplug_io_fn(struct backing_dev_info *bdi);
void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
int writeback_acquire(struct backing_dev_info *bdi);
int writeback_in_progress(struct backing_dev_info *bdi);
......
......@@ -532,16 +532,27 @@ static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
return bdev->bd_disk->queue;
}
static inline void blk_run_backing_dev(struct backing_dev_info *bdi)
static inline void blk_run_backing_dev(struct backing_dev_info *bdi,
struct page *page)
{
if (bdi && bdi->unplug_io_fn)
bdi->unplug_io_fn(bdi);
bdi->unplug_io_fn(bdi, page);
}
static inline void blk_run_address_space(struct address_space *mapping)
{
if (mapping)
blk_run_backing_dev(mapping->backing_dev_info);
blk_run_backing_dev(mapping->backing_dev_info, NULL);
}
static inline void blk_run_page(struct page *page)
{
struct address_space *mapping;
smp_mb();
mapping = page->mapping;
if (mapping)
blk_run_backing_dev(mapping->backing_dev_info, page);
}
/*
......
......@@ -15,7 +15,7 @@
#include <linux/backing-dev.h>
#include <linux/pagevec.h>
void default_unplug_io_fn(struct backing_dev_info *bdi)
void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
{
}
EXPORT_SYMBOL(default_unplug_io_fn);
......
......@@ -100,7 +100,7 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi)
if (bdev == NULL)
break;
bdi = bdev->bd_inode->i_mapping->backing_dev_info;
(*bdi->unplug_io_fn)(bdi);
bdi->unplug_io_fn(bdi, page);
}
up(&swap_bdevs_sem);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment