Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3930625imu; Mon, 10 Dec 2018 10:04:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/VYz/wXF4+EOawUS1LR1VnXWNhx049IJ0bp8u/6dr2eH6q59VuvdDN0jMwewMp1X1SdR8yP X-Received: by 2002:a17:902:7c0c:: with SMTP id x12mr13305641pll.265.1544465049103; Mon, 10 Dec 2018 10:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544465049; cv=none; d=google.com; s=arc-20160816; b=t4kblcvwG/ClQseQPgee/jsxEBy5vdMMeK+iSTT37EW+bwJBSEh95yAH7mtXLCbOHL 7Yp5c4xcVvAqLlS6CmSiKencKa690yQL8+Mr5Eclgxm7Bc3/4LMG1lKnpckvdWDZdVej 2PygmBzGZUYZ38wv6abfjade7dHG4aN9AdU8b69UWXHxUxridoxUzXwwS6rk5uroyu4W N8YVmSXXfRB0d0l7sE3/sCkzSSC1U0fGWCYz9MgTO5ywc/kjoDKf0hig1K4gV16mNrif K4mbBD4cETWi9mvajvNl8ZwSvzw2/2s5wb2ZnvMN0U6aqqImDJ6XvromipczAX650mBn Rvng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+FOJaAOei88ugLv2rdz0wD4IO8u/YcN+6jU0EMh8S3E=; b=bN1jL4xeaz+uim6WzIJLCO6dl/2Bigh3cf4w5z/q5vjMrWSUwAz0xAppSwh7jsK0rc pK3qVBo1xn6WMJ8YkKOXJl9BZaCm3iHfCwsalUGk9CRcEZ0gnchhcCRGMpnyQWmf6x5B MM5/ggq2MGwEqkeB4DtytxOxilHgBId8BGev9YyKGMBGUmY37O+UgCnHFbQf3T7MqwX4 3Iw0CanrySFPFJr2+sjs9Mvkc4XR4shKP4nir49D9xy+tdHIDruYnlr3QJ1hSodfjosx 13y+LGYYLH69g3maisWPTDk2wToVlq5E2I0/EUozVRzWSmVVXnp2isyCOWKZmKGGCrri VdGg== 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 10si10134768pgl.30.2018.12.10.10.03.51; Mon, 10 Dec 2018 10:04:09 -0800 (PST) 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 S1729174AbeLJRUA (ORCPT + 99 others); Mon, 10 Dec 2018 12:20:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58414 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728358AbeLJRNe (ORCPT ); Mon, 10 Dec 2018 12:13:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C4C930014CC; Mon, 10 Dec 2018 17:13:34 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id E608A1001914; Mon, 10 Dec 2018 17:13:33 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 3708D223C11; Mon, 10 Dec 2018 12:13:30 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, sweil@redhat.com, swhiteho@redhat.com Subject: [PATCH 13/52] dax: remove block device dependencies Date: Mon, 10 Dec 2018 12:12:39 -0500 Message-Id: <20181210171318.16998-14-vgoyal@redhat.com> In-Reply-To: <20181210171318.16998-1-vgoyal@redhat.com> References: <20181210171318.16998-1-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 10 Dec 2018 17:13:34 +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. 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 6e928f37d084..74f3bf7ae822 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -52,7 +52,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 9bcce89ea18e..6431c3aba182 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1021,7 +1021,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.13.6