From patchwork Tue Jul 15 19:44:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 4558461 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 07B359F295 for ; Tue, 15 Jul 2014 19:48:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DC702017E for ; Tue, 15 Jul 2014 19:48:33 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 2D1DC20179 for ; Tue, 15 Jul 2014 19:48:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJiCPp030742; Tue, 15 Jul 2014 15:44:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJiB09018770 for ; Tue, 15 Jul 2014 15:44:11 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJiAkk026640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Jul 2014 15:44:11 -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 s6FJiAjG023814; Tue, 15 Jul 2014 15:44:10 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id s6FJiAOq023810; Tue, 15 Jul 2014 15:44:10 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 15 Jul 2014 15:44:10 -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.24 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 15/15] dm kcopyd: call copy offload with asynchronous callback 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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Change dm kcopyd so that it calls blkdev_issue_copy with an asynchronous callback. There can be large number of pending kcopyd requests and holding a process context for each of them may put too much load on the workqueue subsystem. This patch changes it so that blkdev_issue_copy returns after it submitted the requests and copy_offload_callback is called when the copy operation finishes. Signed-off-by: Mikulas Patocka --- drivers/md/dm-kcopyd.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) -- 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 19:24:20.000000000 +0200 +++ linux-3.16-rc5/drivers/md/dm-kcopyd.c 2014-07-15 19:24:54.000000000 +0200 @@ -361,8 +361,6 @@ struct kcopyd_job { sector_t progress; struct kcopyd_job *master_job; - - struct work_struct copy_work; }; static struct kmem_cache *_job_cache; @@ -628,8 +626,9 @@ static void segment_complete(int read_er struct kcopyd_job *sub_job = (struct kcopyd_job *) context; struct kcopyd_job *job = sub_job->master_job; struct dm_kcopyd_client *kc = job->kc; + unsigned long flags; - spin_lock(&job->lock); + spin_lock_irqsave(&job->lock, flags); /* update the error */ if (read_err) @@ -653,7 +652,7 @@ static void segment_complete(int read_er job->progress += count; } } - spin_unlock(&job->lock); + spin_unlock_irqrestore(&job->lock, flags); if (count) { int i; @@ -714,29 +713,25 @@ static void submit_job(struct kcopyd_job } } -static void copy_offload_work(struct work_struct *work) +static void copy_offload_callback(void *ptr, int error) { - struct kcopyd_job *job = container_of(work, struct kcopyd_job, copy_work); - sector_t copied; + struct kcopyd_job *job = ptr; - 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; + job->source.sector += job->progress; + job->source.count -= job->progress; + job->dests[0].sector += job->progress; + job->dests[0].count -= job->progress; 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); + 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, + copy_offload_callback, job, &job->progress); } int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,