forked from luck/tmp_suning_uos_patched
fs: Add helper to clean bdev aliases under a bh and use it
Add a helper function that clears buffer heads from a block device aliasing passed bh. Use this helper function from filesystems instead of the original unmap_underlying_metadata() to save some boiler plate code and also have a better name for the functionalily since it is not unmapping anything for a *long* time. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
parent
69a9bea146
commit
e64855c6cf
|
@ -1821,8 +1821,7 @@ int __block_write_full_page(struct inode *inode, struct page *page,
|
||||||
if (buffer_new(bh)) {
|
if (buffer_new(bh)) {
|
||||||
/* blockdev mappings never come here */
|
/* blockdev mappings never come here */
|
||||||
clear_buffer_new(bh);
|
clear_buffer_new(bh);
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bh = bh->b_this_page;
|
bh = bh->b_this_page;
|
||||||
|
@ -2068,8 +2067,7 @@ int __block_write_begin_int(struct page *page, loff_t pos, unsigned len,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_new(bh)) {
|
if (buffer_new(bh)) {
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
if (PageUptodate(page)) {
|
if (PageUptodate(page)) {
|
||||||
clear_buffer_new(bh);
|
clear_buffer_new(bh);
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
|
@ -2709,7 +2707,7 @@ int nobh_write_begin(struct address_space *mapping,
|
||||||
if (!buffer_mapped(bh))
|
if (!buffer_mapped(bh))
|
||||||
is_mapped_to_disk = 0;
|
is_mapped_to_disk = 0;
|
||||||
if (buffer_new(bh))
|
if (buffer_new(bh))
|
||||||
unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
|
clean_bdev_bh_alias(bh);
|
||||||
if (PageUptodate(page)) {
|
if (PageUptodate(page)) {
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1123,8 +1123,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
if (buffer_new(bh)) {
|
if (buffer_new(bh)) {
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
if (PageUptodate(page)) {
|
if (PageUptodate(page)) {
|
||||||
clear_buffer_new(bh);
|
clear_buffer_new(bh);
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
|
|
|
@ -457,7 +457,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
|
||||||
}
|
}
|
||||||
if (buffer_new(bh)) {
|
if (buffer_new(bh)) {
|
||||||
clear_buffer_new(bh);
|
clear_buffer_new(bh);
|
||||||
unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
|
clean_bdev_bh_alias(bh);
|
||||||
}
|
}
|
||||||
set_buffer_async_write(bh);
|
set_buffer_async_write(bh);
|
||||||
nr_to_submit++;
|
nr_to_submit++;
|
||||||
|
|
|
@ -555,8 +555,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
|
||||||
if (mpd->get_block(inode, block_in_file, &map_bh, 1))
|
if (mpd->get_block(inode, block_in_file, &map_bh, 1))
|
||||||
goto confused;
|
goto confused;
|
||||||
if (buffer_new(&map_bh))
|
if (buffer_new(&map_bh))
|
||||||
unmap_underlying_metadata(map_bh.b_bdev,
|
clean_bdev_bh_alias(&map_bh);
|
||||||
map_bh.b_blocknr);
|
|
||||||
if (buffer_boundary(&map_bh)) {
|
if (buffer_boundary(&map_bh)) {
|
||||||
boundary_block = map_bh.b_blocknr;
|
boundary_block = map_bh.b_blocknr;
|
||||||
boundary_bdev = map_bh.b_bdev;
|
boundary_bdev = map_bh.b_bdev;
|
||||||
|
|
|
@ -765,7 +765,7 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc)
|
||||||
}
|
}
|
||||||
// TODO: Instantiate the hole.
|
// TODO: Instantiate the hole.
|
||||||
// clear_buffer_new(bh);
|
// clear_buffer_new(bh);
|
||||||
// unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
|
// clean_bdev_bh_alias(bh);
|
||||||
ntfs_error(vol->sb, "Writing into sparse regions is "
|
ntfs_error(vol->sb, "Writing into sparse regions is "
|
||||||
"not supported yet. Sorry.");
|
"not supported yet. Sorry.");
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
|
|
|
@ -740,8 +740,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
|
||||||
set_buffer_uptodate(bh);
|
set_buffer_uptodate(bh);
|
||||||
if (unlikely(was_hole)) {
|
if (unlikely(was_hole)) {
|
||||||
/* We allocated the buffer. */
|
/* We allocated the buffer. */
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
if (bh_end <= pos || bh_pos >= end)
|
if (bh_end <= pos || bh_pos >= end)
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
else
|
else
|
||||||
|
@ -784,7 +783,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* We allocated the buffer. */
|
/* We allocated the buffer. */
|
||||||
unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
|
clean_bdev_bh_alias(bh);
|
||||||
/*
|
/*
|
||||||
* If the buffer is fully outside the write, zero it,
|
* If the buffer is fully outside the write, zero it,
|
||||||
* set it uptodate, and mark it dirty so it gets
|
* set it uptodate, and mark it dirty so it gets
|
||||||
|
|
|
@ -630,7 +630,7 @@ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
|
||||||
|
|
||||||
if (!buffer_mapped(bh)) {
|
if (!buffer_mapped(bh)) {
|
||||||
map_bh(bh, inode->i_sb, *p_blkno);
|
map_bh(bh, inode->i_sb, *p_blkno);
|
||||||
unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr);
|
clean_bdev_bh_alias(bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageUptodate(page)) {
|
if (PageUptodate(page)) {
|
||||||
|
|
|
@ -307,8 +307,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
|
||||||
(unsigned long long)(pos + newb), pos);
|
(unsigned long long)(pos + newb), pos);
|
||||||
|
|
||||||
bh->b_blocknr = newb + pos;
|
bh->b_blocknr = newb + pos;
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
++j;
|
++j;
|
||||||
bh = bh->b_this_page;
|
bh = bh->b_this_page;
|
||||||
|
|
|
@ -1070,8 +1070,7 @@ static int ufs_alloc_lastblock(struct inode *inode, loff_t size)
|
||||||
|
|
||||||
if (buffer_new(bh)) {
|
if (buffer_new(bh)) {
|
||||||
clear_buffer_new(bh);
|
clear_buffer_new(bh);
|
||||||
unmap_underlying_metadata(bh->b_bdev,
|
clean_bdev_bh_alias(bh);
|
||||||
bh->b_blocknr);
|
|
||||||
/*
|
/*
|
||||||
* we do not zeroize fragment, because of
|
* we do not zeroize fragment, because of
|
||||||
* if it maped to hole, it already contains zeroes
|
* if it maped to hole, it already contains zeroes
|
||||||
|
|
|
@ -171,6 +171,10 @@ int sync_mapping_buffers(struct address_space *mapping);
|
||||||
void unmap_underlying_metadata(struct block_device *bdev, sector_t block);
|
void unmap_underlying_metadata(struct block_device *bdev, sector_t block);
|
||||||
void clean_bdev_aliases(struct block_device *bdev, sector_t block,
|
void clean_bdev_aliases(struct block_device *bdev, sector_t block,
|
||||||
sector_t len);
|
sector_t len);
|
||||||
|
static inline void clean_bdev_bh_alias(struct buffer_head *bh)
|
||||||
|
{
|
||||||
|
clean_bdev_aliases(bh->b_bdev, bh->b_blocknr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void mark_buffer_async_write(struct buffer_head *bh);
|
void mark_buffer_async_write(struct buffer_head *bh);
|
||||||
void __wait_on_buffer(struct buffer_head *);
|
void __wait_on_buffer(struct buffer_head *);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user