From patchwork Mon Dec 10 22:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10722743 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47D9191E for ; Mon, 10 Dec 2018 22:46:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3634E2A67A for ; Mon, 10 Dec 2018 22:46:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A7F12A6E5; Mon, 10 Dec 2018 22:46:06 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1E232A67A for ; Mon, 10 Dec 2018 22:46:05 +0000 (UTC) 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 mx1.redhat.com (Postfix) with ESMTPS id 69F4C30820D6; Mon, 10 Dec 2018 22:46:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F16FE60C5C; Mon, 10 Dec 2018 22:46:03 +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 4B9AB181B9E5; Mon, 10 Dec 2018 22:46:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wBAMk14w011954 for ; Mon, 10 Dec 2018 17:46:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id B89F26090E; Mon, 10 Dec 2018 22:46:01 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BB1C608F6 for ; Mon, 10 Dec 2018 22:45:57 +0000 (UTC) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99DCE3DDBE for ; Mon, 10 Dec 2018 22:45:56 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id b5so5936967plr.4 for ; Mon, 10 Dec 2018 14:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=dKNvozK2xSfQmlVfpwnGnoWDXXv8BZt4SEn4xfoa714=; b=UBAj190Ju/XSSJs7u8geITpZqoor4VlaLxZLHbCM9ZdMxTB+9Gs3yZ0F0so1jHvw+V TaoUWXz8j1Ls6oUgoCP/kvEgWKgqGGDxvSnLY6wswSA507O4xVWlEhJuudho+DM5/0f4 qLPDiziJLMJPuMNDsW6LNDUgXsLezZdVE/UjskayvOz7XVGn51x/8DUcpocspEQ2fK88 0DeSF585EUvGfngkAsPfSmVQNsEAfYia+DYl/TbxxkG/IPecuhU+9JSa3CWOjEVxJhre 31hIaU+xzsWox8iP6kEkDtBZs4Y7wbgmjNPBBoAHzDMTOM2Oyp5nxNwUCZM8IMpZkiwU Jwvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=dKNvozK2xSfQmlVfpwnGnoWDXXv8BZt4SEn4xfoa714=; b=lXdkbLPuoL/qE26AeKiJnOyCCGsgxl+yYpIOU+PkXM8pJQM90zClOnnNFTGcFI96Wo NiXlbcYotRaHSEKEi5vMWpuEzXXq5j35jk78KKGcsSSr5g9e92Hyg5R2UvqwWuu+G/9t fguQS5c5J7xWszqhVKTh0dwZTH8KWgXWTo4SbEyOnjKgLaeLJhycMW0D0Dk8TBFKb5s5 ChqOwGM1y085L4vu0SIvPxUNfCahgwi5mgoYN0n5I2sL7k+Y+LefhqYWSr8gpQ0UXexd YnNb81nKUrCIpvW+/Udbals51toQZ3VkPz4aNvwQwEgHwmV9K8GISxazTFb3mrrtOOMf Mo+w== X-Gm-Message-State: AA+aEWZ8xbzo2X72FB8yDQ6UK5cvEqcDEp+DjRg6P71CVlFbhMSrH/s1 xuNt7Ic54EPwDOHgrJgiy57oYQ== X-Google-Smtp-Source: AFSGD/WXN18W40T/JEWOIOyE0LpLmA3u2tPbpLCB0YmSvWFxWBH9280Yv+68F9OdRcGVj9+GgXNhAA== X-Received: by 2002:a17:902:96a:: with SMTP id 97mr13440512plm.45.1544481956036; Mon, 10 Dec 2018 14:45:56 -0800 (PST) Received: from [192.168.1.121] (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id k15sm21762197pfb.147.2018.12.10.14.45.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 14:45:54 -0800 (PST) To: "linux-block@vger.kernel.org" , device-mapper development From: Jens Axboe Message-ID: <4fec4b01-35f9-8008-22ec-2ac8af58b854@kernel.dk> Date: Mon, 10 Dec 2018 15:45:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 10 Dec 2018 22:45:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 10 Dec 2018 22:45:56 +0000 (UTC) for IP:'209.85.214.194' DOMAIN:'mail-pl1-f194.google.com' HELO:'mail-pl1-f194.google.com' FROM:'axboe@kernel.dk' RCPT:'' X-RedHat-Spam-Score: -0.01 (DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.214.194 mail-pl1-f194.google.com 209.85.214.194 mail-pl1-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Christoph Hellwig , Mike Snitzer Subject: [dm-devel] [PATCH] dm: fix inflight IO check 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: , 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 10 Dec 2018 22:46:05 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP After switching to percpu inflight counters, the inflight check is totally buggy. It's perfectly valid for some counters to be non-zero while having a total inflight IO count of 0, that's how these kinds of counters work (inc on one CPU, dec on another). Fix the md_in_flight() check to sum all counters before returning a false positive, potentially. While at it, remove the inflight read for IO completion. We don't need it, just wake anyone that's waiting for the IO count to drop to zero. The caller needs to re-check that value anyway when woken, which it does. Fixes: 6f75723190d8 ("dm: remove the pending IO accounting") Reported-by: Christoph Hellwig Signed-off-by: Jens Axboe Acked-by: Mike Snitzer diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 70568f8b6c53..79ad4b3d215c 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -650,14 +650,14 @@ static bool md_in_flight(struct mapped_device *md) { int cpu; struct hd_struct *part = &dm_disk(md)->part0; + long sum = 0; for_each_possible_cpu(cpu) { - if (part_stat_local_read_cpu(part, in_flight[0], cpu) || - part_stat_local_read_cpu(part, in_flight[1], cpu)) - return true; + sum += part_stat_local_read_cpu(part, in_flight[0], cpu); + sum += part_stat_local_read_cpu(part, in_flight[1], cpu); } - return false; + return sum != 0; } static void start_io_acct(struct dm_io *io) @@ -691,10 +691,8 @@ static void end_io_acct(struct dm_io *io) true, duration, &io->stats_aux); /* nudge anyone waiting on suspend queue */ - if (unlikely(waitqueue_active(&md->wait))) { - if (!md_in_flight(md)) - wake_up(&md->wait); - } + if (unlikely(waitqueue_active(&md->wait))) + wake_up(&md->wait); } /*