From patchwork Wed Apr 17 14:19:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 10905409 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 4BB7813B5 for ; Wed, 17 Apr 2019 14:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30E7B2869B for ; Wed, 17 Apr 2019 14:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22F6E28762; Wed, 17 Apr 2019 14:20:43 +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 AFAB52869B for ; Wed, 17 Apr 2019 14:20:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1060301989A; Wed, 17 Apr 2019 14:20:33 +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 DF9AA5C205; Wed, 17 Apr 2019 14:20:28 +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 4DAC341F3D; Wed, 17 Apr 2019 14:20:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3HEJddd026241 for ; Wed, 17 Apr 2019 10:19:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65BE960C66; Wed, 17 Apr 2019 14:19:39 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6084560C64 for ; Wed, 17 Apr 2019 14:19:37 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (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 2211A64394 for ; Wed, 17 Apr 2019 14:19:28 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id y13so32240552wrd.3 for ; Wed, 17 Apr 2019 07:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arrikto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=5ACBSc16l+P/s0RYAhBpSgTfhfBMUsSNC7RsUTdW3s4=; b=DK3ofNP020i8i97dQWQUIxljWYNXJQWQkme3OrQBkH1NKaRybjkz3YHB353IqxCtYd GAEfxN4vo0V1+G4a+F0212A94bqNahVDn/C80SToTMGIj/pl0XPTtw1nLQ4Fymi9cdg+ b8GkHKyhwMhRrSochJMblTJDlB7/l0dMLR9deGpxX3tP/L/z5I5lmrK4YxbK7SwCJHm7 a6ft/0MZpyHeFrV+8zBtQ2Luma4kRDH6DsVnHuuTEyj5ehcw9ze1O0N6EuGomU4Qa5XH ZbmmhtCxrx0OKF9oK6ZQPp3hQD0rzcpxZa6uop5gs6+jII/qNsNjfNWauB5cLU3XdzWg He5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5ACBSc16l+P/s0RYAhBpSgTfhfBMUsSNC7RsUTdW3s4=; b=i25rJTUyYZe90NA/cDx76dFIpQb89XtTP0I42/6NFKIBCCIjAF8R1LXm6Q7lOc4vBK s8WRNoIJxUrO21Ykl+ZKzDJz/V+cQtwPACW3lLaRjj6g6pshwYF5ODDQ0iPK5D/LzxIu rdcHYFaqaCD3ATcVwxXkYE6Uuv5Bb/VLrlc8SkMPIoqOfePGm5ELY1s2b432TEwOV//u ZAy18Q9U+psWPG2icx0YAmVQEC7KAqXwXUXCET9LIUkQa0RqP1fJWQMxYInB3ZUyP2PT xJqEAaR7bHEnKcGKVZezsG21d04BWtMvcCIJCrIuYmIydPg0pSfJeBp+NUWAFkErpD3W +xlg== X-Gm-Message-State: APjAAAUlhLzeJpDa6Ft5x+qtMEPASN2MVVvx3OS9Ktycx1T/9WctgWSS l842CVoW0Of7MV5tD4A+firh7LQg8Kk= X-Google-Smtp-Source: APXvYqxYVxERVnsyuZDpUyMSS0Biec7hRSgpXD43R4XQ3a7aMXuGEB/3nAwM9zD9gRFokoA7xdxwvw== X-Received: by 2002:adf:de07:: with SMTP id b7mr28961846wrm.196.1555510766907; Wed, 17 Apr 2019 07:19:26 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id u189sm4941031wme.25.2019.04.17.07.19.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 07:19:26 -0700 (PDT) From: Nikos Tsironis To: snitzer@redhat.com, agk@redhat.com, dm-devel@redhat.com Date: Wed, 17 Apr 2019 17:19:18 +0300 Message-Id: <20190417141918.10648-1-ntsironis@arrikto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 17 Apr 2019 14:19:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 17 Apr 2019 14:19:28 +0000 (UTC) for IP:'209.85.221.67' DOMAIN:'mail-wr1-f67.google.com' HELO:'mail-wr1-f67.google.com' FROM:'ntsironis@arrikto.com' RCPT:'' X-RedHat-Spam-Score: -0.018 (DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.67 mail-wr1-f67.google.com 209.85.221.67 mail-wr1-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: ejt@redhat.com Subject: [dm-devel] [PATCH] dm cache metadata: Fix loading discard bitset 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Apr 2019 14:20:42 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Add missing dm_bitset_cursor_next() to properly advance the bitset cursor. Otherwise, the discarded state of all blocks is set according to the discarded state of the first block. Fixes: ae4a46a1f6 ("dm cache metadata: use bitset cursor api to load discard bitset") Signed-off-by: Nikos Tsironis --- drivers/md/dm-cache-metadata.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 6fc93834da44..151aa95775be 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -1167,11 +1167,18 @@ static int __load_discards(struct dm_cache_metadata *cmd, if (r) return r; - for (b = 0; b < from_dblock(cmd->discard_nr_blocks); b++) { + for (b = 0; ; b++) { r = fn(context, cmd->discard_block_size, to_dblock(b), dm_bitset_cursor_get_value(&c)); if (r) break; + + if (b >= (from_dblock(cmd->discard_nr_blocks) - 1)) + break; + + r = dm_bitset_cursor_next(&c); + if (r) + break; } dm_bitset_cursor_end(&c);