From patchwork Fri May 22 15:39:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 11565871 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 340FD1392 for ; Fri, 22 May 2020 15:40:08 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4E93208DB for ; Fri, 22 May 2020 15:40:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XIs20y6A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4E93208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590162006; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LNa9DfXZCB54u11tJShT+u0ZxiidvBI6SUsNDwfQvGQ=; b=XIs20y6ASri66SRHbh/e8NghyNRN32Jvnwn2UNNdTCkJxKjqTNE0buAMBI9kNgdvH9aOJN tetX7FBJ6Rh0jYnrRSn/ty9Qc81NFB/1pK+HbRuw9jpF23R96axwW6VkQWjZH1/F6/wy8n XhwzheIYlCT9fVvNEB/ElsKFaBLmH6s= 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-476-0BA1aAOLPIuPNz9ThMyA0A-1; Fri, 22 May 2020 11:40:04 -0400 X-MC-Unique: 0BA1aAOLPIuPNz9ThMyA0A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19A47DFDF0; Fri, 22 May 2020 15:39:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFE6760CD3; Fri, 22 May 2020 15:39:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CA6AF54D0D; Fri, 22 May 2020 15:39:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04MFdNk4012695 for ; Fri, 22 May 2020 11:39:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A30D2026FFE; Fri, 22 May 2020 15:39:23 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66C932029F61 for ; Fri, 22 May 2020 15:39:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52D2886BCD4 for ; Fri, 22 May 2020 15:39:23 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-NVnWKa12NZqvm2BxsTy1qw-1; Fri, 22 May 2020 11:39:13 -0400 X-MC-Unique: NVnWKa12NZqvm2BxsTy1qw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C701FB22B; Fri, 22 May 2020 15:39:12 +0000 (UTC) From: Hannes Reinecke To: Damien LeMoal Date: Fri, 22 May 2020 17:39:00 +0200 Message-Id: <20200522153901.133375-12-hare@suse.de> In-Reply-To: <20200522153901.133375-1-hare@suse.de> References: <20200522153901.133375-1-hare@suse.de> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Mike Snitzer Subject: [dm-devel] [PATCH 11/12] dm-zoned: round-robin load balancer for reclaiming zones X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When reclaiming zones we should arbitrate between the zoned devices to get a better throughput. So implement a simple round-robin load balancer between the zoned devices. Signed-off-by: Hannes Reinecke --- drivers/md/dm-zoned-metadata.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c index 87784e7785bc..25dcad2a565f 100644 --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -171,6 +171,8 @@ struct dmz_metadata { unsigned int nr_reserved_seq; unsigned int nr_chunks; + unsigned int last_alloc_idx; + /* Zone information array */ struct xarray zones; @@ -2178,7 +2180,7 @@ struct dm_zone *dmz_alloc_zone(struct dmz_metadata *zmd, unsigned long flags) { struct list_head *list; struct dm_zone *zone; - unsigned int dev_idx = 0; + unsigned int dev_idx = zmd->last_alloc_idx; again: if (flags & DMZ_ALLOC_CACHE) @@ -2214,6 +2216,9 @@ struct dm_zone *dmz_alloc_zone(struct dmz_metadata *zmd, unsigned long flags) zone = list_first_entry(list, struct dm_zone, link); list_del_init(&zone->link); + if (!(flags & DMZ_ALLOC_CACHE)) + zmd->last_alloc_idx = (dev_idx + 1) % zmd->nr_devs; + if (dmz_is_cache(zone)) atomic_dec(&zmd->unmap_nr_cache); else if (dmz_is_rnd(zone)) @@ -2839,6 +2844,7 @@ int dmz_ctr_metadata(struct dmz_dev *dev, int num_dev, zmd->dev = dev; zmd->nr_devs = num_dev; zmd->mblk_rbtree = RB_ROOT; + zmd->last_alloc_idx = 0; init_rwsem(&zmd->mblk_sem); mutex_init(&zmd->mblk_flush_lock); spin_lock_init(&zmd->mblk_lock);