From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> page_is_mergeable() would incorrectly claim that two IOs were on different pages because they were on different base pages rather than on the same THP. This led to a reference counting bug in iomap. Simplify the 'same_page' test by just comparing whether we have the same struct page instead of doing arithmetic on the physical addresses. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 5235da6434aa..cd677cde853d 100644 --- a/block/bio.c +++ b/block/bio.c @@ -747,7 +747,7 @@ static inline bool page_is_mergeable(const struct bio_vec *bv, if (xen_domain() && !xen_biovec_phys_mergeable(bv, page)) return false; - *same_page = ((vec_end_addr & PAGE_MASK) == page_addr); + *same_page = bv->bv_page == page; if (!*same_page && pfn_to_page(PFN_DOWN(vec_end_addr)) + 1 != page) return false; return true; -- 2.26.2