From patchwork Thu Dec 1 10:27:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ritesh Harjani X-Patchwork-Id: 9455761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D9F1460585 for ; Thu, 1 Dec 2016 10:28:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6492284CB for ; Thu, 1 Dec 2016 10:28:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB2A8284CF; Thu, 1 Dec 2016 10:28:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382C7284CB for ; Thu, 1 Dec 2016 10:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756546AbcLAK2I (ORCPT ); Thu, 1 Dec 2016 05:28:08 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:38004 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756625AbcLAK2H (ORCPT ); Thu, 1 Dec 2016 05:28:07 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3D2CC61515; Thu, 1 Dec 2016 10:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1480588073; bh=EWZofJV7+uTC21c2zzCoL98UOv5FBLVqGB2lIXtaQng=; h=From:To:Cc:Subject:Date:From; b=Q7ZC2j96oJlXH9AY7MzPNs+aKHMvJj90D+TRpnyYIZpSw89xLSTQ94jFsgj1rGuog 5ZHH16hSeRES/l7As0IkTbB4OCrLrZwQFeg8Z4Oj2vbRqiurtpPEQZ8eAMOGVEI6vs pm38jQT5Oe2q3cH6FBjASNUIkSOmvTqodvjjdu8M= Received: from rharjani-linux.qualcomm.com (unknown [202.46.23.54]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: riteshh@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 848D3614E5; Thu, 1 Dec 2016 10:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1480588072; bh=EWZofJV7+uTC21c2zzCoL98UOv5FBLVqGB2lIXtaQng=; h=From:To:Cc:Subject:Date:From; b=DOE7zgkp/SzGz9Eoqpl7BzK+K0Tse9D8cpwuPcpZ9UxHwiQ4qsmELD84TLa4I62Ir fuB8lD5pSqjj5ZXuN14taQEFbyIr2oQzHWmLfDCQQFOuF85AlsZESXHmADpCV7EUwh 0vGCQNTqOdnSX2MXuPsp8Tca2wClARYhec97jgWo= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 848D3614E5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=riteshh@codeaurora.org From: Ritesh Harjani To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, Ritesh Harjani Subject: [PATCH] block: Factor out req_set_nomerge Date: Thu, 1 Dec 2016 15:57:38 +0530 Message-Id: <1480588058-29998-1-git-send-email-riteshh@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Factor out common code for setting REQ_NOMERGE flag which is being used out at certain places and make it a helper instead (req_set_nomerge). Signed-off-by: Ritesh Harjani --- block/blk-merge.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 2642e5f..4549fec 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -492,6 +492,14 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, } EXPORT_SYMBOL(blk_rq_map_sg); +static inline void req_set_nomerge(struct request_queue *q, + struct request *req) +{ + req->cmd_flags |= REQ_NOMERGE; + if (req == q->last_merge) + q->last_merge = NULL; +} + static inline int ll_new_hw_segment(struct request_queue *q, struct request *req, struct bio *bio) @@ -512,9 +520,7 @@ static inline int ll_new_hw_segment(struct request_queue *q, return 1; no_merge: - req->cmd_flags |= REQ_NOMERGE; - if (req == q->last_merge) - q->last_merge = NULL; + req_set_nomerge(q, req); return 0; } @@ -528,9 +534,7 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > blk_rq_get_max_sectors(req, blk_rq_pos(req))) { - req->cmd_flags |= REQ_NOMERGE; - if (req == q->last_merge) - q->last_merge = NULL; + req_set_nomerge(q, req); return 0; } if (!bio_flagged(req->biotail, BIO_SEG_VALID)) @@ -552,9 +556,7 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req, return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > blk_rq_get_max_sectors(req, bio->bi_iter.bi_sector)) { - req->cmd_flags |= REQ_NOMERGE; - if (req == q->last_merge) - q->last_merge = NULL; + req_set_nomerge(q, req); return 0; } if (!bio_flagged(bio, BIO_SEG_VALID))