From patchwork Tue Nov 24 02:35:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 7687331 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B685BF90C for ; Tue, 24 Nov 2015 02:36:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A85DC20877 for ; Tue, 24 Nov 2015 02:36:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D999C2086F for ; Tue, 24 Nov 2015 02:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752921AbbKXCgm (ORCPT ); Mon, 23 Nov 2015 21:36:42 -0500 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35039 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360AbbKXCg1 (ORCPT ); Mon, 23 Nov 2015 21:36:27 -0500 Received: by padhk6 with SMTP id hk6so631955pad.2; Mon, 23 Nov 2015 18:36:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E2njvoQSQtaYVogpXrFfqei2KqnvHdpe9cQmZOW76jc=; b=Tt2TUnKy93PtKFubkn0wkQfCpkcTi+ZMHpQhSpVRS6joblWoLWNEv1uD04Ykg1dYai aqeLd6EClM75N/kDeVprr7LNf3pIr2mV7npffL/VvTCfm7hDf/3rFOX+mhleZyWktJMR EEvx30TiQX+05wIGn+eAuk7G4bqEl+X6pM6B90Bcx00FSBFDccD7Iaql9rztfbhYhWYn q1odx5Rl50RaTjr8r5hrnqT6kdSlMLwc7Qv/M8oJUnn9P7PUHUjNi0N+Tw/GSdW5tJXR i7rwHrzrKMDt27hjcFTDGno26IToJSZoOojEoEoRkYmrGc01HaljECPlQ4Tw++mAFzUK mp3Q== X-Received: by 10.68.163.195 with SMTP id yk3mr39092670pbb.120.1448332586772; Mon, 23 Nov 2015 18:36:26 -0800 (PST) Received: from localhost ([116.251.217.174]) by smtp.gmail.com with ESMTPSA id hg2sm12031976pbb.7.2015.11.23.18.36.25 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 23 Nov 2015 18:36:26 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Michael Ellerman , Laurent Dufour , Mark Salter , Hannes Reinecke , Pratyush Anand , Ming Lei Subject: [PATCH 3/3] blk-merge: warn if figured out segment number is bigger than nr_phys_segments Date: Tue, 24 Nov 2015 10:35:31 +0800 Message-Id: <1448332531-10704-4-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448332531-10704-1-git-send-email-ming.lei@canonical.com> References: <1448332531-10704-1-git-send-email-ming.lei@canonical.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.5 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 We had seen lots of reports of this kind issue, so add one warnning in blk-merge, then it can be triggered easily and avoid to depend on warning/bug from drivers. Signed-off-by: Ming Lei --- block/blk-merge.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/blk-merge.c b/block/blk-merge.c index 50793cd..41a55ba 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -428,6 +428,12 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, if (sg) sg_mark_end(sg); + /* + * Something must have been wrong if the figured number of + * segment is bigger than number of req's physical segments + */ + WARN_ON(nsegs > rq->nr_phys_segments); + return nsegs; } EXPORT_SYMBOL(blk_rq_map_sg);