Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1072563imm; Fri, 1 Jun 2018 14:56:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIF3CZvyrRuvggQN0lU3xga5+QtXrzZLxIUdWOboqdxW54+z+2CIc2yjK26BQGJMCPhQt1v X-Received: by 2002:a17:902:581:: with SMTP id f1-v6mr12801785plf.48.1527890212901; Fri, 01 Jun 2018 14:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527890212; cv=none; d=google.com; s=arc-20160816; b=VU4uMzUzMRcmIGYvrXkgisODGn+93gYPL33VnN1kRd6MM4U2TCEDeTGRo0mtjJoyzM 4PZNYmY9V8IovqgbjlfwPXbWiywkS0Il/QFmSHnqPZ14lRBLWExqRjQFftkNdoh8sWQB MwhSFD3GWjw0r6htBd2Z2QeQEtTnkUXFw5dyZj8ZceuKfurSo5xf6pEZ5MtMLEGTyFNX Nd6kG5BG4klx5RQgpt8UKbfh9K6Gi1CmKulUAvJLMYky30c/mqEOP9RcT1O8/2VhRz56 10l1IPgNr3HCHE6SHQYlyJ+f+yXln4LXKu7W+9qHfLuxnvmMi/edHrMz4B0JtU6Y5QbQ xLZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=J5JmQZQEp8nvpGBtg1RREVL6ptz+llSScNAFdm7BeX0=; b=YhIjaiCnxhUh7BO+3TQn9NtGFDtcoADwEc18NMf6LKOlzli4TEbyuUcbcWT0oGNjjG clkUm6/Gn4rM/5misylh81MvWoh/SnkwpHsz1VL2VjA+7sc99gKubisWyU1jwz30n9Ol FyxIPV7aPaiKzX9FR5dTHHq24+fxTOIdO34/2wuN1sg8plyDC+sbsjyBv0SVaICF15d9 tSz8Au8MOP89ADaPJAnpDY/vEtooekdRY4R83tV6S0+W+uWwEd1qzqAdG4TxPvu/QrZp CCnYAFSB9sCUcC45whKV2j7OLCxCWIPA2xZ8OyIAt7lHVQKdoqzKpmEKq6obzCG1MZUk AyfQ== 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 t184-v6si39406755pfb.98.2018.06.01.14.56.38; Fri, 01 Jun 2018 14:56:52 -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 S1751238AbeFAVzQ (ORCPT + 99 others); Fri, 1 Jun 2018 17:55:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55064 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750934AbeFAVzP (ORCPT ); Fri, 1 Jun 2018 17:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A02C859A9; Fri, 1 Jun 2018 21:55:14 +0000 (UTC) Received: from localhost (unknown [10.18.25.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 195BC20244E0; Fri, 1 Jun 2018 21:55:13 +0000 (UTC) Date: Fri, 1 Jun 2018 17:55:13 -0400 From: Mike Snitzer To: Ross Zwisler Cc: Toshi Kani , dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH v2 4/7] dm: prevent DAX mounts if not supported Message-ID: <20180601215513.GA18712@redhat.com> References: <20180529195106.14268-1-ross.zwisler@linux.intel.com> <20180529195106.14268-5-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180529195106.14268-5-ross.zwisler@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 01 Jun 2018 21:55:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 01 Jun 2018 21:55:14 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'msnitzer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29 2018 at 3:51pm -0400, Ross Zwisler wrote: > Currently the code in dm_dax_direct_access() only checks whether the target > type has a direct_access() operation defined, not whether the underlying > block devices all support DAX. This latter property can be seen by looking > at whether we set the QUEUE_FLAG_DAX request queue flag when creating the > DM device. Wait... I thought DAX support was all or nothing? > This is problematic if we have, for example, a dm-linear device made up of > a PMEM namespace in fsdax mode followed by a ramdisk from BRD. > QUEUE_FLAG_DAX won't be set on the dm-linear device's request queue, but > we have a working direct_access() entry point and the first member of the > dm-linear set *does* support DAX. If you don't have a uniformly capable device then it is very dangerous to advertise that the entire device has a certain capability. That completely bit me in the past with discard (because for every IO I wasn't then checking if the destination device supported discards). It is all well and good that you're adding that check here. But what I don't like is how you're saying QUEUE_FLAG_DAX implies direct_access() operation exists.. yet for raw PMEM namespaces we just discussed how that is a lie. SO this type of change showcases how the QUEUE_FLAG_DAX doesn't _really_ imply direct_access() exists. > This allows the user to create a filesystem on the dm-linear device, and > then mount it with DAX. The filesystem's bdev_dax_supported() test will > pass because it'll operate on the first member of the dm-linear device, > which happens to be a fsdax PMEM namespace. > > All DAX I/O will then fail to that dm-linear device because the lack of > QUEUE_FLAG_DAX prevents fs_dax_get_by_bdev() from working. This means that > the struct dax_device isn't ever set in the filesystem, so > dax_direct_access() will always return -EOPNOTSUPP. Now you've lost me... these past 2 paragraphs. Why can a user mount it is DAX mode? Because bdev_dax_supported() only accesses the first portion (which happens to have DAX capabilities?) Isn't this exactly why you should be checking for QUEUE_FLAG_DAX in the caller (bdev_dax_supported)? Why not use bdev_get_queue() and verify QUEUE_FLAG_DAX is set in there? > By failing out of dm_dax_direct_access() if QUEUE_FLAG_DAX isn't set we let > the filesystem know we don't support DAX at mount time. The filesystem > will then silently fall back and remove the dax mount option, causing it to > work properly. This shouldn't be needed. Again, QUEUE_FLAG_DAX wasn't set.. so don't allow code to falsely try operations that should've been gated by the fact it wasn't set. SO Nack on this patch.. until/unless I'm corrected ;) Thanks, Mike > Signed-off-by: Ross Zwisler > Fixes: commit 545ed20e6df6 ("dm: add infrastructure for DAX support") > --- > drivers/md/dm.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 0a7b0107ca78..9728433362d1 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -1050,14 +1050,13 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, > > if (!ti) > goto out; > - if (!ti->type->direct_access) > + if (!blk_queue_dax(md->queue)) > goto out; > len = max_io_len(sector, ti) / PAGE_SECTORS; > if (len < 1) > goto out; > nr_pages = min(len, nr_pages); > - if (ti->type->direct_access) > - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); > + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); > > out: > dm_put_live_table(md, srcu_idx); > -- > 2.14.3 >