Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3291452pxk; Mon, 21 Sep 2020 09:50:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW3ZejUnNLr8FE1Fry41YRK14x0ae9PyPcPaRNaAGAlAVLSh4pLFQk+mwDFxdD274HYE8h X-Received: by 2002:a17:906:c289:: with SMTP id r9mr374688ejz.402.1600707050832; Mon, 21 Sep 2020 09:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707050; cv=none; d=google.com; s=arc-20160816; b=MOFZqZP+E0dw1trk8eF/JHcfpDne60nNuk3412AIvKvGmanIw3qiMpA/kkk19loH4y 3UwoPuLtig+e2SOrYyTh1+TOXXMiwEtoCKH9Eab9GCk+o8ImcEG9av32CZZRLMKxJTCf SJm43WF0XjhjqPUWRfIt8XTp3QsQb2NOA7OQ5A80yPbpZz6NMRFps1xTQ3F3+JD1gQUy 4oR756IUqc+wZ6cMWnX+1DV5bsNKd0FZ3LGsuMcA5qP8vWR8iNhrKJGwd2e8Ldljl5iy 5D0XmUIxCjH5fvq4uV5VFy9h5W80ShVhdCG7xeyZqU4z3Io8ItSMnL86wGQCDUHBdh0i l5Dg== 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=q6XWf204B6b56njG0q4yppcEWLq1OzAZ7ubO8psRT8U=; b=yD7V0tYKZb6YUWzYiLJfvOpvpk6v2pAQumFsJeMW3qgPoP8rXIgPNgkYWc3UBkrIBr QIKXFyBTrqhdR1Z30wRQgSuOzJ9/L+cmyT43O7zwnTYFbd1tHJgGVH1V9f0ChLTYmp7f Cg7335m6bBNGsx7PcnULNTzrFT9rvEKWilXc8FC9k7X8omGAHnyuYm+P9jDfhPwKA09m PYuGQSHZX1ZO/RrQ5+SxhyHhqac9RAfJcoV78u0QL3XT0x0zlaYynPX84YblWRZvyIv/ Rj8Zu9fkcCG06IqBZBMqyh4MaNqcEEBUTP2ZADIDyQJL/QFtc3O+a1hXXNO/BVIhq44J pCTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VYvpZBag; 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=fail (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 u21si8400750edx.3.2020.09.21.09.50.26; Mon, 21 Sep 2020 09:50:50 -0700 (PDT) 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=@kernel.org header.s=default header.b=VYvpZBag; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727517AbgIUQrb (ORCPT + 99 others); Mon, 21 Sep 2020 12:47:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbgIUQrX (ORCPT ); Mon, 21 Sep 2020 12:47:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D398023888; Mon, 21 Sep 2020 16:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706841; bh=HqGhaZOrV/fvlOdkuznf58lF8tBY9lsqo3KdrJ7Cz18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VYvpZBag1Y0RIoLOgJ+Bn6YmVRA99fnreLpYsO/EvRdYZ0sRLXDym49iWYbM7DEMC i/h+xaC7AutIx6+zpNow7GAWb7aYSegzmY50vfN1ZLRuKynWM0L/OABA7126dc9FDc ZmH0MPwdfx2SKQ/3nXmDCbUKUDQxZI8kdHopD/TU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Huang , Jan Kara , Mike Snitzer , kernel test robot , Dan Williams Subject: [PATCH 5.8 115/118] dm: Call proper helper to determine dax support Date: Mon, 21 Sep 2020 18:28:47 +0200 Message-Id: <20200921162041.736094189@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@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: Jan Kara commit e2ec5128254518cae320d5dc631b71b94160f663 upstream. DM was calling generic_fsdax_supported() to determine whether a device referenced in the DM table supports DAX. However this is a helper for "leaf" device drivers so that they don't have to duplicate common generic checks. High level code should call dax_supported() helper which that calls into appropriate helper for the particular device. This problem manifested itself as kernel messages: dm-3: error: dax access failed (-95) when lvm2-testsuite run in cases where a DM device was stacked on top of another DM device. Fixes: 7bf7eac8d648 ("dax: Arrange for dax_supported check to span multiple devices") Cc: Tested-by: Adrian Huang Signed-off-by: Jan Kara Acked-by: Mike Snitzer Reported-by: kernel test robot Link: https://lore.kernel.org/r/160061715195.13131.5503173247632041975.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/dax/super.c | 4 ++++ drivers/md/dm-table.c | 10 +++++++--- include/linux/dax.h | 22 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -318,11 +318,15 @@ EXPORT_SYMBOL_GPL(dax_direct_access); bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev, int blocksize, sector_t start, sector_t len) { + if (!dax_dev) + return false; + if (!dax_alive(dax_dev)) return false; return dax_dev->ops->dax_supported(dax_dev, bdev, blocksize, start, len); } +EXPORT_SYMBOL_GPL(dax_supported); size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -865,10 +865,14 @@ EXPORT_SYMBOL_GPL(dm_table_set_type); int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { - int blocksize = *(int *) data; + int blocksize = *(int *) data, id; + bool rc; - return generic_fsdax_supported(dev->dax_dev, dev->bdev, blocksize, - start, len); + id = dax_read_lock(); + rc = dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len); + dax_read_unlock(id); + + return rc; } /* Check devices support synchronous DAX */ --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -130,6 +130,8 @@ static inline bool generic_fsdax_support return __generic_fsdax_supported(dax_dev, bdev, blocksize, start, sectors); } +bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev, + int blocksize, sector_t start, sector_t len); static inline void fs_put_dax(struct dax_device *dax_dev) { @@ -157,6 +159,13 @@ static inline bool generic_fsdax_support return false; } +static inline bool dax_supported(struct dax_device *dax_dev, + struct block_device *bdev, int blocksize, sector_t start, + sector_t len) +{ + return false; +} + static inline void fs_put_dax(struct dax_device *dax_dev) { } @@ -189,14 +198,23 @@ static inline void dax_unlock_page(struc } #endif +#if IS_ENABLED(CONFIG_DAX) int dax_read_lock(void); void dax_read_unlock(int id); +#else +static inline int dax_read_lock(void) +{ + return 0; +} + +static inline void dax_read_unlock(int id) +{ +} +#endif /* CONFIG_DAX */ bool dax_alive(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn); -bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev, - int blocksize, sector_t start, sector_t len); size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,