Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp243719pxf; Wed, 10 Mar 2021 05:31:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKq5FbAqsJakC+39KTutrtKvZRLxSO99GO2a7xtMiB+2saQWN2UnziKidRu2Q6jLx94OuM X-Received: by 2002:a17:906:4a19:: with SMTP id w25mr3620627eju.180.1615383079907; Wed, 10 Mar 2021 05:31:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383079; cv=none; d=google.com; s=arc-20160816; b=sHeWEh5laeFjlzwTuTbw08+jsQgvgXtNY6Sam9DOUzP0bR8+0f0/6V8qpCZHSiK12t e/ZC4HfPGxzftVdpDOssBfB27xT6NvINGte/d4YlU+j/WEDjsItziXqmMpPsQl2fvbW4 FslcSXCB9l7v4iEgkZrQnB8rj++FIzItm16JnQxeQhJCSVP6Bth2AaXVSowQMr4t+oZQ I9XJYrzWyHbl6ZUfiJWb5Y/71I53guXJKL8RcWhJzj98NLuJN9Pg6Nzsz0RBVAMW4Z4V TF6fXpE/9AyhQX9mguwri9Qn2O291CauoYofsa5eKPfuItDCkA0d4cGWWwtMm2VgUdp/ XQog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yR3HjRmc5UxYs1MRa6sENtCmGjQRBLB/sjTb8XFRlnE=; b=o+EdVKAWWeQXmK04YNP9gY47G7CEcBU2yO2U3rB+7JGSl0aWlygGrCS482uWVsUQxk NRdyTND48BZWm24HqDQnpXrOmJwzLD/PkX1I3cOuVIeSTgZ+6oSUWW3g4t57HSj5E4AR V+MEwHeuLypoko4xAb895NHX5XI685Q3Y0Xv8aeZoJt7VcbEoY6F7DYCEBrPVyn2U8YN c4b3x+lOT5MaMk154SqkNebFPLaPeL84sho+aNsY4EVziEF5/1dQgnLAD+8zYBQ96VKO BlqWhjFFHTB0C4kzWrD8Oh+3kwPM+9ZYryBPL2/uOXVVMKXQv8Ef/CiKxfbuNmwjc+vw DcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aKSSsNIE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si11331312edw.446.2021.03.10.05.30.56; Wed, 10 Mar 2021 05:31:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aKSSsNIE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbhCJN3t (ORCPT + 99 others); Wed, 10 Mar 2021 08:29:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:48258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233417AbhCJNZf (ORCPT ); Wed, 10 Mar 2021 08:25:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4652B64FD8; Wed, 10 Mar 2021 13:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382732; bh=2iw24BEOWyyZtefbU2bj3t8duAtEonYWegb9qJCp4wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKSSsNIEmrY8uQpTEnMKRjefYkIRPdg1tT1z4Jng0pf4hHfb9YsHKxk7Ux/V3iDaX ppODvRRUHVjs917jgp+2R+9ufGCwnL/Sbehesw3+0GSZlVlqFnJ+HgXFaAeXhJYEn7 baGQlEATanKc/eVFk1pHG5Zboy2rxnjoqpxWrdWg= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeffle Xu , Mike Snitzer Subject: [PATCH 4.19 23/39] dm table: fix DAX iterate_devices based device capability checks Date: Wed, 10 Mar 2021 14:24:31 +0100 Message-Id: <20210310132320.449328244@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Jeffle Xu commit 5b0fab508992c2e120971da658ce80027acbc405 upstream. Fix dm_table_supports_dax() and invert logic of both iterate_devices_callout_fn so that all devices' DAX capabilities are properly checked. Fixes: 545ed20e6df6 ("dm: add infrastructure for DAX support") Cc: stable@vger.kernel.org Signed-off-by: Jeffle Xu Signed-off-by: Mike Snitzer [jeffle: no dax synchronous] Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-table.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -891,10 +891,10 @@ void dm_table_set_type(struct dm_table * } EXPORT_SYMBOL_GPL(dm_table_set_type); -static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, +static int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { - return bdev_dax_supported(dev->bdev, PAGE_SIZE); + return !bdev_dax_supported(dev->bdev, PAGE_SIZE); } static bool dm_table_supports_dax(struct dm_table *t) @@ -910,7 +910,7 @@ static bool dm_table_supports_dax(struct return false; if (!ti->type->iterate_devices || - !ti->type->iterate_devices(ti, device_supports_dax, NULL)) + ti->type->iterate_devices(ti, device_not_dax_capable, NULL)) return false; } @@ -1731,23 +1731,6 @@ static int device_dax_write_cache_enable return false; } -static int dm_table_supports_dax_write_cache(struct dm_table *t) -{ - struct dm_target *ti; - unsigned i; - - for (i = 0; i < dm_table_get_num_targets(t); i++) { - ti = dm_table_get_target(t, i); - - if (ti->type->iterate_devices && - ti->type->iterate_devices(ti, - device_dax_write_cache_enabled, NULL)) - return true; - } - - return false; -} - static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { @@ -1946,7 +1929,7 @@ void dm_table_set_restrictions(struct dm else blk_queue_flag_clear(QUEUE_FLAG_DAX, q); - if (dm_table_supports_dax_write_cache(t)) + if (dm_table_any_dev_attr(t, device_dax_write_cache_enabled)) dax_write_cache(t->md->dax_dev, true); /* Ensure that all underlying devices are non-rotational. */