Commit 5339178e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Song Liu

md-bitmap: split file writes into a separate helper

Split the file write code out of write_page into a separate helper.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230615064840.629492-5-hch@lst.de
parent 92348518
......@@ -296,18 +296,10 @@ static void write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
}
static void md_bitmap_file_kick(struct bitmap *bitmap);
/*
* write out a page to a file
*/
static void write_page(struct bitmap *bitmap, struct page *page, int wait)
{
struct buffer_head *bh;
if (bitmap->storage.file == NULL) {
write_sb_page(bitmap, page, wait);
} else {
bh = page_buffers(page);
static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
{
struct buffer_head *bh = page_buffers(page);
while (bh && bh->b_blocknr) {
atomic_inc(&bitmap->pending_writes);
......@@ -319,10 +311,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
if (wait)
wait_event(bitmap->write_wait,
atomic_read(&bitmap->pending_writes)==0);
}
if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
md_bitmap_file_kick(bitmap);
atomic_read(&bitmap->pending_writes) == 0);
}
static void end_bitmap_write(struct buffer_head *bh, int uptodate)
......@@ -429,6 +418,17 @@ static int read_page(struct file *file, unsigned long index,
* bitmap file superblock operations
*/
/*
* write out a page to a file
*/
static void write_page(struct bitmap *bitmap, struct page *page, int wait)
{
if (bitmap->storage.file)
write_file_page(bitmap, page, wait);
else
write_sb_page(bitmap, page, wait);
}
/*
* md_bitmap_wait_writes() should be called before writing any bitmap
* blocks, to ensure previous writes, particularly from
......
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