From patchwork Tue Jul 15 19:43:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 4558391 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 47D9DC0514 for ; Tue, 15 Jul 2014 19:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DA9D201B4 for ; Tue, 15 Jul 2014 19:46:32 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id 730A32017E for ; Tue, 15 Jul 2014 19:46:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJhLg6024628; Tue, 15 Jul 2014 15:43:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJhKIu017435 for ; Tue, 15 Jul 2014 15:43:20 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJhJP7011584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Jul 2014 15:43:20 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJhJfk023705; Tue, 15 Jul 2014 15:43:19 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id s6FJhJ7K023701; Tue, 15 Jul 2014 15:43:19 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 15 Jul 2014 15:43:19 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: "Alasdair G. Kergon" , Mike Snitzer , Jonathan Brassow , Edward Thornber , "Martin K. Petersen" , Jens Axboe , Christoph Hellwig In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [dm-devel] [PATCH 13/15] dm kcopyd: support copy offload X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This patch adds copy offload support to dm-kcopyd. If copy offload fails, copying is performed using dm-io, just like before. There is a module parameter "copy_offload" that can be set to enable or disable this feature. It can be used to test performance of copy offload. Signed-off-by: Mikulas Patocka --- drivers/md/dm-kcopyd.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-3.16-rc5/drivers/md/dm-kcopyd.c =================================================================== --- linux-3.16-rc5.orig/drivers/md/dm-kcopyd.c 2014-07-15 16:18:15.000000000 +0200 +++ linux-3.16-rc5/drivers/md/dm-kcopyd.c 2014-07-15 19:20:34.000000000 +0200 @@ -96,6 +96,9 @@ static DEFINE_SPINLOCK(throttle_spinlock */ #define MAX_SLEEPS 10 +static bool copy_offload = true; +module_param(copy_offload, bool, S_IRUGO | S_IWUSR); + static void io_job_start(struct dm_kcopyd_throttle *t) { unsigned throttle, now, difference; @@ -358,6 +361,8 @@ struct kcopyd_job { sector_t progress; struct kcopyd_job *master_job; + + struct work_struct copy_work; }; static struct kmem_cache *_job_cache; @@ -709,6 +714,31 @@ static void submit_job(struct kcopyd_job } } +static void copy_offload_work(struct work_struct *work) +{ + struct kcopyd_job *job = container_of(work, struct kcopyd_job, copy_work); + sector_t copied; + + blkdev_issue_copy(job->source.bdev, job->source.sector, + job->dests[0].bdev, job->dests[0].sector, + job->source.count, + GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN, + NULL, NULL, &copied); + + job->source.sector += copied; + job->source.count -= copied; + job->dests[0].sector += copied; + job->dests[0].count -= copied; + + submit_job(job); +} + +static void try_copy_offload(struct kcopyd_job *job) +{ + INIT_WORK(&job->copy_work, copy_offload_work); + queue_work(job->kc->kcopyd_wq, &job->copy_work); +} + int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, unsigned int num_dests, struct dm_io_region *dests, unsigned int flags, dm_kcopyd_notify_fn fn, void *context) @@ -757,7 +787,13 @@ int dm_kcopyd_copy(struct dm_kcopyd_clie job->context = context; job->master_job = job; - submit_job(job); + if (copy_offload && num_dests == 1 && + bdev_copy_offload(job->source.bdev) && + bdev_copy_offload(job->dests[0].bdev)) { + try_copy_offload(job); + } else { + submit_job(job); + } return 0; }