From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933403AbcBZPlR (ORCPT ); Fri, 26 Feb 2016 10:41:17 -0500 Received: from mail-pa0-f66.google.com ([209.85.220.66]:34197 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932737AbcBZPlP (ORCPT ); Fri, 26 Feb 2016 10:41:15 -0500 From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Kent Overstreet , Keith Busch , Elliott Robert Subject: [PATCH v2 0/4] block: fix bio_will_gap() Date: Fri, 26 Feb 2016 23:40:49 +0800 Message-Id: <1456501253-7269-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guys, The bio passed to bio_will_gap() may be fast cloned from upper layer(dm, md, bcache, fs, ...), or from bio splitting in block core. Unfortunately bio_will_gap() just figures out the last bvec via 'bi_io_vec[prev->bi_vcnt - 1]' directly, and this way is obviously wrong in case of fast-cloned bio. It is observed that lots of BIOs are still merged even if the virt boundary limit is violated by the merge, and the issue was reported from Sagi Grimberg. This patch introduces two helpers for getting the first and last bvec of one bio and applys them to fix the issue. Sagi has confirmed the fix. Thanks for Sagi and Christoph's review. V2: - remove unnecessary comment - add reviewed-by V1: - get bvec directly for non-cloned bio - implement bio_get_last_bvec() with single bio_advance_iter(), and avoid to use bio_for_each_segment() which looks a bit inefficient - avoid to double check queue_virt_boundary() in bio_will_gap() block/blk-merge.c | 8 ++------ include/linux/bio.h | 37 +++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 23 +++++++++++++++++------ 3 files changed, 56 insertions(+), 12 deletions(-) Thanks, Ming