--- x/mm/mmu_gather.c +++ y/mm/mmu_gather.c @@ -26,7 +26,11 @@ static bool tlb_next_batch(struct mmu_ga batch = tlb->active; if (batch->next) { tlb->active = batch->next; - return true; + batch = tlb->active; + if (batch->nr < batch->max) + return true; + else + return false; } if (tlb->batch_count == MAX_GATHER_BATCH_COUNT) --- x/block/bio.c +++ y/block/bio.c @@ -1253,6 +1253,7 @@ static int __bio_iov_iter_get_pages(stru unsigned len, i = 0; size_t offset, trim; int ret = 0; + int setref = 0; /* * Move page array up in the allocated memory for the bio vecs as far as @@ -1302,13 +1303,16 @@ static int __bio_iov_iter_get_pages(stru bio_iov_add_page(bio, page, len, offset); offset = 0; + get_page(page); } + setref = i; - iov_iter_revert(iter, left); out: while (i < nr_pages) bio_release_page(bio, pages[i++]); + if (setref) + bio_set_flag(bio, BIO_PAGE_REFFED); return ret; } @@ -1342,8 +1346,6 @@ int bio_iov_iter_get_pages(struct bio *b return 0; } - if (iov_iter_extract_will_pin(iter)) - bio_set_flag(bio, BIO_PAGE_PINNED); do { ret = __bio_iov_iter_get_pages(bio, iter); } while (!ret && iov_iter_count(iter) && !bio_full(bio, 0));