block: return from __bio_try_merge_page if merging occured in the same page
We currently have an input same_page parameter to __bio_try_merge_page to prohibit merging in the same page. The rationale for that is that some callers need to account for every page added to a bio. Instead of letting these callers call twice into the merge code to account for the new vs existing page cases, just turn the paramter into an output one that returns if a merge in the same page occured and let them act accordingly. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:

committed by
Jens Axboe

parent
1d0c06513b
commit
ff896738be
@@ -758,6 +758,7 @@ xfs_add_to_ioend(
|
||||
struct block_device *bdev = xfs_find_bdev_for_inode(inode);
|
||||
unsigned len = i_blocksize(inode);
|
||||
unsigned poff = offset & (PAGE_SIZE - 1);
|
||||
bool merged, same_page = false;
|
||||
sector_t sector;
|
||||
|
||||
sector = xfs_fsb_to_db(ip, wpc->imap.br_startblock) +
|
||||
@@ -774,9 +775,13 @@ xfs_add_to_ioend(
|
||||
wpc->imap.br_state, offset, bdev, sector);
|
||||
}
|
||||
|
||||
if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, true)) {
|
||||
if (iop)
|
||||
atomic_inc(&iop->write_count);
|
||||
merged = __bio_try_merge_page(wpc->ioend->io_bio, page, len, poff,
|
||||
&same_page);
|
||||
|
||||
if (iop && !same_page)
|
||||
atomic_inc(&iop->write_count);
|
||||
|
||||
if (!merged) {
|
||||
if (bio_full(wpc->ioend->io_bio))
|
||||
xfs_chain_bio(wpc->ioend, wbc, bdev, sector);
|
||||
bio_add_page(wpc->ioend->io_bio, page, len, poff);
|
||||
|
Reference in New Issue
Block a user