From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2FF8C2D0F8 for ; Wed, 13 May 2020 03:48:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1C26205ED for ; Wed, 13 May 2020 03:48:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P8RQ4YNS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728651AbgEMDsn (ORCPT ); Tue, 12 May 2020 23:48:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42595 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727107AbgEMDsn (ORCPT ); Tue, 12 May 2020 23:48:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589341721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vIAYDXBt9wwIZZ2W14gLNPcdGmjLM07bSq3AjCxVeVE=; b=P8RQ4YNSmlg/8uHTqxigR1z0Ezzm/4iHomBBgfJ7mczjjSA60P5THET0/5+S14IxWsWqaQ +i6SpPk/RfeBqtdowK/LNw0My0GUGwm0HeANh/+0TDfeluRqizrwTAK7ZNsKPH8DRLE4XE 6PXKb/PCtDCOdBfXJAS+v6Ag/MBVYMM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-h5eSeWcaNK2SRraL2O8TkQ-1; Tue, 12 May 2020 23:48:37 -0400 X-MC-Unique: h5eSeWcaNK2SRraL2O8TkQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6028D800687; Wed, 13 May 2020 03:48:36 +0000 (UTC) Received: from localhost (ovpn-12-166.pek2.redhat.com [10.72.12.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1BA25D9DD; Wed, 13 May 2020 03:48:27 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei , John Garry , Bart Van Assche , Hannes Reinecke , Christoph Hellwig , Thomas Gleixner , Mike Snitzer , dm-devel@redhat.com, Hannes Reinecke , "Martin K . Petersen" Subject: [PATCH V11 02/12] block: add helper for copying request Date: Wed, 13 May 2020 11:47:53 +0800 Message-Id: <20200513034803.1844579-3-ming.lei@redhat.com> In-Reply-To: <20200513034803.1844579-1-ming.lei@redhat.com> References: <20200513034803.1844579-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add one new helper of blk_rq_copy_request() to copy request, and the helper will be used in this patch for re-submitting request, so make it as a block layer internal helper. Cc: John Garry Cc: Bart Van Assche Cc: Hannes Reinecke Cc: Christoph Hellwig Cc: Thomas Gleixner Cc: Mike Snitzer Cc: dm-devel@redhat.com Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Signed-off-by: Ming Lei --- block/blk-core.c | 31 ++++++++++++++++++------------- block/blk.h | 2 ++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 08ee92baa451..ffb1579fd4da 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1620,6 +1620,23 @@ void blk_rq_unprep_clone(struct request *rq) } EXPORT_SYMBOL_GPL(blk_rq_unprep_clone); +void blk_rq_copy_request(struct request *rq, struct request *rq_src) +{ + /* Copy attributes of the original request to the clone request. */ + rq->__sector = blk_rq_pos(rq_src); + rq->__data_len = blk_rq_bytes(rq_src); + if (rq_src->rq_flags & RQF_SPECIAL_PAYLOAD) { + rq->rq_flags |= RQF_SPECIAL_PAYLOAD; + rq->special_vec = rq_src->special_vec; + } +#ifdef CONFIG_BLK_DEV_INTEGRITY + rq->nr_integrity_segments = rq_src->nr_integrity_segments; +#endif + rq->nr_phys_segments = rq_src->nr_phys_segments; + rq->ioprio = rq_src->ioprio; + rq->write_hint = rq_src->write_hint; +} + /** * blk_rq_prep_clone - Helper function to setup clone request * @rq: the request to be setup @@ -1662,19 +1679,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src, rq->bio = rq->biotail = bio; } - /* Copy attributes of the original request to the clone request. */ - rq->__sector = blk_rq_pos(rq_src); - rq->__data_len = blk_rq_bytes(rq_src); - if (rq_src->rq_flags & RQF_SPECIAL_PAYLOAD) { - rq->rq_flags |= RQF_SPECIAL_PAYLOAD; - rq->special_vec = rq_src->special_vec; - } -#ifdef CONFIG_BLK_DEV_INTEGRITY - rq->nr_integrity_segments = rq_src->nr_integrity_segments; -#endif - rq->nr_phys_segments = rq_src->nr_phys_segments; - rq->ioprio = rq_src->ioprio; - rq->write_hint = rq_src->write_hint; + blk_rq_copy_request(rq, rq_src); return 0; diff --git a/block/blk.h b/block/blk.h index e5cd350ca379..faf616cb0463 100644 --- a/block/blk.h +++ b/block/blk.h @@ -120,6 +120,8 @@ static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio, rq->rq_disk = bio->bi_disk; } +void blk_rq_copy_request(struct request *rq, struct request *rq_src); + #ifdef CONFIG_BLK_DEV_INTEGRITY void blk_flush_integrity(void); bool __bio_integrity_endio(struct bio *); -- 2.25.2