Commit 0431d926 authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong

xfs: async blkdev cache flush

The new checkpoint cache flush mechanism requires us to issue an
unconditional cache flush before we start a new checkpoint. We don't
want to block for this if we can help it, and we have a fair chunk
of CPU work to do between starting the checkpoint and issuing the
first journal IO.

Hence it makes sense to amortise the latency cost of the cache flush
by issuing it asynchronously and then waiting for it only when we
need to issue the first IO in the transaction.

To do this, we need async cache flush primitives to submit the cache
flush bio and to wait on it. The block layer has no such primitives
for filesystems, so roll our own for the moment.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent b5071ada
...@@ -9,6 +9,41 @@ static inline unsigned int bio_max_vecs(unsigned int count) ...@@ -9,6 +9,41 @@ static inline unsigned int bio_max_vecs(unsigned int count)
return bio_max_segs(howmany(count, PAGE_SIZE)); return bio_max_segs(howmany(count, PAGE_SIZE));
} }
static void
xfs_flush_bdev_async_endio(
struct bio *bio)
{
complete(bio->bi_private);
}
/*
* Submit a request for an async cache flush to run. If the request queue does
* not require flush operations, just skip it altogether. If the caller needs
* to wait for the flush completion at a later point in time, they must supply a
* valid completion. This will be signalled when the flush completes. The
* caller never sees the bio that is issued here.
*/
void
xfs_flush_bdev_async(
struct bio *bio,
struct block_device *bdev,
struct completion *done)
{
struct request_queue *q = bdev->bd_disk->queue;
if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
complete(done);
return;
}
bio_init(bio, NULL, 0);
bio_set_dev(bio, bdev);
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
bio->bi_private = done;
bio->bi_end_io = xfs_flush_bdev_async_endio;
submit_bio(bio);
}
int int
xfs_rw_bdev( xfs_rw_bdev(
struct block_device *bdev, struct block_device *bdev,
......
...@@ -196,6 +196,8 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y) ...@@ -196,6 +196,8 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)
int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count, int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
char *data, unsigned int op); char *data, unsigned int op);
void xfs_flush_bdev_async(struct bio *bio, struct block_device *bdev,
struct completion *done);
#define ASSERT_ALWAYS(expr) \ #define ASSERT_ALWAYS(expr) \
(likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__)) (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
......
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