Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1159483ybl; Wed, 21 Aug 2019 11:02:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3JD470T9JP2mSi12R0QEJEPaVEOG33wsgZeCwo1jkIwWTLjq+ON2KrwG2aHq7J36MPNhY X-Received: by 2002:a62:f24b:: with SMTP id y11mr37430925pfl.0.1566410520192; Wed, 21 Aug 2019 11:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566410520; cv=none; d=google.com; s=arc-20160816; b=rC+tLfYRQqVnywcMLKiFHuRs2zjaL1JRGaVe7FbFIUP2+Z6IO51Sm54BD7H5BoPGqU NEiG/KEe0SVeT8Zq5CJTx2iGCuaRUiRBRufVGmZOl/Qj5OhQkmkbpdHMMlJPg/qjCYv2 bxpyUvLBsqKMYhJSUfJqODg7uFoHP2t9PsWOw5xLBLtw6VItGkdZGm4OkFoAUnsZdsXY D+7HJCKjO4IaQKWWk5Yxo6XqMLeWgLcNhr92d4+k1Ke9fZNJeaPVnoGy/Q/uMI47vGPd cppzrmJ0AveZiCVMLguM5TZtAgCP6mY7wKCg9WY/8QUTgrjMnc1LCYLDgdi27Mp+UDJ5 EWIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=D47fWMlhAuEMeee2QuaPUcf/I+7QSIGIWj69QwSV1qk=; b=Gexmw7foGR9q6gvMtqdJ+/tFaKQzF31QSMak+IIQ6kNmUdDqxVdXJ8oyWi6abBBAo5 TTr4GqAkmrI4Y65e7BiVet8To8jaF3o+B9BT7h3zDxkWSOBEl8Tw8SeRePDeuYqqG38n PZXTmvgQVr1L5BnYjUEVNU1sSwhMPUbmFsLZ8UwUsS5rAcbrvet0cD1qJwcaMwIF7P5p l8Wbfhcz/7ZpxA2z9EX3yJCv2IQb661osRudIRcYVrHFshXvSxqaRD1EVzRaj9ucVj36 yPiqOL+5fv4RY9XNbDNJWQbjhhTSOVp7yLgRraQGb2Li8UMA5UMKckvnqWu4XSZVFv/X z3Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f29si12499710pfq.100.2019.08.21.11.01.42; Wed, 21 Aug 2019 11:02:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730156AbfHUR5o (ORCPT + 99 others); Wed, 21 Aug 2019 13:57:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729817AbfHUR5n (ORCPT ); Wed, 21 Aug 2019 13:57:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B723F1105201; Wed, 21 Aug 2019 17:57:42 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id F167C60127; Wed, 21 Aug 2019 17:57:32 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 7C3D6223CFD; Wed, 21 Aug 2019 13:57:32 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Cc: virtio-fs@redhat.com, vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, Dan Williams Subject: [PATCH 01/19] dax: remove block device dependencies Date: Wed, 21 Aug 2019 13:57:02 -0400 Message-Id: <20190821175720.25901-2-vgoyal@redhat.com> In-Reply-To: <20190821175720.25901-1-vgoyal@redhat.com> References: <20190821175720.25901-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 21 Aug 2019 17:57:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Hajnoczi Although struct dax_device itself is not tied to a block device, some DAX code assumes there is a block device. Make block devices optional by allowing bdev to be NULL in commonly used DAX APIs. When there is no block device: * Skip the partition offset calculation in bdev_dax_pgoff() * Skip the blkdev_issue_zeroout() optimization Note that more block device assumptions remain but I haven't reach those code paths yet. Cc: Dan Williams Signed-off-by: Stefan Hajnoczi --- drivers/dax/super.c | 3 ++- fs/dax.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 26a654dbc69a..3cbc97f3e653 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -46,7 +46,8 @@ EXPORT_SYMBOL_GPL(dax_read_unlock); int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, pgoff_t *pgoff) { - phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512; + sector_t start_sect = bdev ? get_start_sect(bdev) : 0; + phys_addr_t phys_off = (start_sect + sector) * 512; if (pgoff) *pgoff = PHYS_PFN(phys_off); diff --git a/fs/dax.c b/fs/dax.c index 6bf81f931de3..a11147bbaf9e 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1046,7 +1046,12 @@ static vm_fault_t dax_load_hole(struct xa_state *xas, static bool dax_range_is_aligned(struct block_device *bdev, unsigned int offset, unsigned int length) { - unsigned short sector_size = bdev_logical_block_size(bdev); + unsigned short sector_size; + + if (!bdev) + return false; + + sector_size = bdev_logical_block_size(bdev); if (!IS_ALIGNED(offset, sector_size)) return false; -- 2.20.1