From patchwork Sat Mar 12 14:56:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8571581 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC1069F294 for ; Sat, 12 Mar 2016 14:56:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD02D20396 for ; Sat, 12 Mar 2016 14:56:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9A1E20377 for ; Sat, 12 Mar 2016 14:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752618AbcCLO4d (ORCPT ); Sat, 12 Mar 2016 09:56:33 -0500 Received: from mail-ob0-f178.google.com ([209.85.214.178]:35823 "EHLO mail-ob0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbcCLO4d (ORCPT ); Sat, 12 Mar 2016 09:56:33 -0500 Received: by mail-ob0-f178.google.com with SMTP id fp4so139423486obb.2; Sat, 12 Mar 2016 06:56:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+LF/7xjwDjPBHr/UWLocVgCt+wzVNkhKh5hdhxGuFco=; b=IFJMDQhxFwqE/68zaHR3pG+7aCI7kSaBalDc3wE8CLxTPKCppqHkDBeP5DkTTgbqRx FYmWYU2ElmbbjvQQ/iDjgnE3hZ9q7QFX1SLmjKWKAFfZKXkXC8YOJt67fxIEf4yNNZdM zh3Dkl6wvJLDs4MVyLvkKnNlxaxXnvXnjkWcYuPcD+ahKt2b77x56GFuQKlEvGFkvFKm e+IwsV9thdNwgUlW4/q1oJ3H0qJQLz+DtTQGTSET8WJirEHbub+jCe27D5jZ8TXyB1EK fpxtKwXgEEK80KD/mhLHTHqME/62Ydoy3Llwzxf16CG6sN8d9dbCapuF5r3/ktER6jud esjA== X-Gm-Message-State: AD7BkJIssYux5elithRzOhUvVIfO41WH2nHhqUv3PdBmCB+yuFgXYkJWiZH3y0BjyVsXDA== X-Received: by 10.182.33.101 with SMTP id q5mr8868617obi.28.1457794592089; Sat, 12 Mar 2016 06:56:32 -0800 (PST) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id d1sm5926005oby.16.2016.03.12.06.56.30 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sat, 12 Mar 2016 06:56:31 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Kent Overstreet , Ming Lei , stable@vger.kernel.org Subject: [PATCH] block: don't optimize for non-cloned bio in bio_get_last_bvec() Date: Sat, 12 Mar 2016 22:56:19 +0800 Message-Id: <1457794579-6125-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For !BIO_CLONED bio, we can use .bi_vcnt safely, but it doesn't mean we can just simply return .bi_io_vec[.bi_vcnt - 1] because the start postion may have been moved in the middle of the bvec, such as splitting in the middle of bvec. Fixes: 7bcd79ac50d9(block: bio: introduce helpers to get the 1st and last bvec) Cc: stable@vger.kernel.org Reported-by: Kent Overstreet Signed-off-by: Ming Lei --- Jens, I am fine with either reverting previous patchset or applying this one to v4.5, and you decide it. Thanks Kent for reporting the issue! include/linux/bio.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 1e7248f..4abc129 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -267,11 +267,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) struct bvec_iter iter = bio->bi_iter; int idx; - if (!bio_flagged(bio, BIO_CLONED)) { - *bv = bio->bi_io_vec[bio->bi_vcnt - 1]; - return; - } - if (unlikely(!bio_multiple_segments(bio))) { *bv = bio_iovec(bio); return;