From patchwork Wed Aug 19 22:19:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11725151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4790715E4 for ; Wed, 19 Aug 2020 22:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DFAC20888 for ; Wed, 19 Aug 2020 22:23:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QCvHdkv7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727888AbgHSWXB (ORCPT ); Wed, 19 Aug 2020 18:23:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41725 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727878AbgHSWVH (ORCPT ); Wed, 19 Aug 2020 18:21:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597875666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+4JPYlZ9QDYDC/mD0F6lPDwdYttMSKvhVad1UZeeChA=; b=QCvHdkv71lb2bdFhO1lyKnus7D7uXAej5V93BRHiIVnNxFVv0/N7UGTVl88mcvDWAJ67jx 26rIYlCLWH/+wDoxbZyQNF1hW1W9fqJ7XOySJJqCvrmf12257BVCCIU5ImolR78NmvaYdk Dnj8m55Z7fXKZlfziTepcqE8I0l+7hM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-mzDGoN68MzeM2JWyxMOSZw-1; Wed, 19 Aug 2020 18:21:02 -0400 X-MC-Unique: mzDGoN68MzeM2JWyxMOSZw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E05028030A1; Wed, 19 Aug 2020 22:21:00 +0000 (UTC) Received: from horse.redhat.com (ovpn-115-197.rdu2.redhat.com [10.10.115.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B0A35C88D; Wed, 19 Aug 2020 22:20:54 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id C68142254FA; Wed, 19 Aug 2020 18:20:53 -0400 (EDT) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, virtio-fs@redhat.com Cc: vgoyal@redhat.com, miklos@szeredi.hu, stefanha@redhat.com, dgilbert@redhat.com, dan.j.williams@intel.com, Jan Kara , Christoph Hellwig , Vishal L Verma , "Weiny, Ira" Subject: [PATCH v3 01/18] dax: Modify bdev_dax_pgoff() to handle NULL bdev Date: Wed, 19 Aug 2020 18:19:39 -0400 Message-Id: <20200819221956.845195-2-vgoyal@redhat.com> In-Reply-To: <20200819221956.845195-1-vgoyal@redhat.com> References: <20200819221956.845195-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org virtiofs does not have a block device but it has dax device. Modify bdev_dax_pgoff() to be able to handle that. If there is no bdev, that means dax offset is 0. (It can't be a partition block device starting at an offset in dax device). This is little hackish. There have been discussions about getting rid of dax not supporting partitions. https://lore.kernel.org/linux-fsdevel/20200107125159.GA15745@infradead.org/ IMHO, this path can easily break exisitng users. For example ioctl(BLKPG_ADD_PARTITION) will start breaking on block devices supporting DAX. Also, I personally find it very useful to be able to partition dax devices and still be able to use DAX. Alternatively, I tried to store offset into dax device information in iomap interface, but that got NACKed. https://lore.kernel.org/linux-fsdevel/20200217133117.GB20444@infradead.org/ I can't think of a good path to solve this issue properly. So to make progress, it seems this patch is least bad option for now and I hope we can take it. Signed-off-by: Stefan Hajnoczi Signed-off-by: Vivek Goyal Reviewed-by: Jan Kara Cc: Christoph Hellwig Cc: Dan Williams Cc: Jan Kara Cc: Vishal L Verma Cc: "Weiny, Ira" Cc: linux-nvdimm@lists.01.org --- drivers/dax/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index c82cbcb64202..505165752d8f 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);