From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g4t3427.houston.hp.com (g4t3427.houston.hp.com [15.201.208.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB0761A1EF1 for ; Mon, 9 May 2016 11:21:45 -0700 (PDT) Message-ID: <1462817565.27137.102.camel@hpe.com> Subject: Re: [PATCH v3 2/5] block: Add bdev_supports_dax() for dax mount checks From: Toshi Kani Date: Mon, 09 May 2016 12:12:45 -0600 In-Reply-To: References: <1462494596-20938-1-git-send-email-toshi.kani@hpe.com> <1462494596-20938-3-git-send-email-toshi.kani@hpe.com> Mime-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: Jan Kara , Christoph Hellwig , "linux-nvdimm@lists.01.org" , david , "linux-kernel@vger.kernel.org" , micah.parrish@hpe.com, Jens Axboe , Andreas Dilger , Al Viro , linux-fsdevel , Theodore Ts'o List-ID: T24gU3VuLCAyMDE2LTA1LTA4IGF0IDEyOjE0IC0wNzAwLCBEYW4gV2lsbGlhbXMgd3JvdGU6Cj4g T24gVGh1LCBNYXkgNSwgMjAxNiBhdCA1OjI5IFBNLCBUb3NoaSBLYW5pIDx0b3NoaS5rYW5pQGhw ZS5jb20+IHdyb3RlOgrCoDoKPiA+ICtpbnQgYmRldl9zdXBwb3J0c19kYXgoc3RydWN0IHN1cGVy X2Jsb2NrICpzYiwgaW50IGJsb2Nrc2l6ZSkKPiA+ICt7Cj4gPiArwqDCoMKgwqDCoMKgwqBzdHJ1 Y3QgYmxrX2RheF9jdGwgZGF4ID0gewo+ID4gK8KgwqDCoMKgwqDCoMKgwqDCoMKgwqDCoMKgwqDC oC5zZWN0b3IgPSAwLAo+ID4gK8KgwqDCoMKgw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Npbmcg c29tZXRoaW5nPwoKR29vZCBxdWVzdGlvbi4gwqBiZGV2X3N1cHBvcnRzX2RheCgpIGlzIGEgaGVs cGVyIGZ1bmN0aW9uIHRhaWxvcmVkIGZvciB0aGUKZmlsZXN5c3RlbSdzIG1vdW50IC1vIGRheCBj YXNlLiDCoFdoaWxlIGJsa2Rldl9kYXhfY2FwYWJsZSgpIGlzIHNpbWlsYXIsIGl0CmRvZXMgbm90 IG5lZWQgZXJyb3IgbWVzc2FnZXMgbGlrZSAiZGV2aWNlIGRvZXMgbm90IHN1cHBvcnQgZGF4IiBz aW5jZSBpdAppbXBsaWNpdGx5IGVuYWJsZXMgZGF4IHdoZW4gY2FwYWJsZS4gwqBTbywgSSB0aGlu ayB3ZSBjYW4ga2VlcApibGtkZXZfZGF4X2NhcGFibGUoKSwgYnV0IGNoYW5nZSBpdCB0byBjYWxs wqBiZGV2X2RpcmVjdF9hY2Nlc3MoKSBzbyB0aGF0CmFjdHVhbCBjaGVjayBpcyBwZXJmb3JtZWQg aW4gYSBzaW5nbGUgcGxhY2UuCgpUaGFua3MsCi1Ub3NoaQoKCgoKX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTGludXgtbnZkaW1tIG1haWxpbmcgbGlzdApM aW51eC1udmRpbW1AbGlzdHMuMDEub3JnCmh0dHBzOi8vbGlzdHMuMDEub3JnL21haWxtYW4vbGlz dGluZm8vbGludXgtbnZkaW1tCg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <1462817565.27137.102.camel@hpe.com> Subject: Re: [PATCH v3 2/5] block: Add bdev_supports_dax() for dax mount checks From: Toshi Kani To: Dan Williams Cc: Jan Kara , david , Al Viro , Jens Axboe , Christoph Hellwig , Boaz Harrosh , Theodore Ts'o , Andreas Dilger , Ross Zwisler , micah.parrish@hpe.com, "linux-nvdimm@lists.01.org" , linux-fsdevel , "linux-kernel@vger.kernel.org" Date: Mon, 09 May 2016 12:12:45 -0600 In-Reply-To: References: <1462494596-20938-1-git-send-email-toshi.kani@hpe.com> <1462494596-20938-3-git-send-email-toshi.kani@hpe.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: On Sun, 2016-05-08 at 12:14 -0700, Dan Williams wrote: > On Thu, May 5, 2016 at 5:29 PM, Toshi Kani wrote:  : > > +int bdev_supports_dax(struct super_block *sb, int blocksize) > > +{ > > +       struct blk_dax_ctl dax = { > > +               .sector = 0, > > +               .size = PAGE_SIZE, > > +       }; > > +       int err; > > + > > +       if (blocksize != PAGE_SIZE) { > > +               vfs_msg(sb, KERN_ERR, "error: unsupported blocksize for > > dax"); > > +               return -EINVAL; > > +       } > > + > > +       err = bdev_direct_access(sb->s_bdev, &dax); > > +       if (err < 0) { > > +               switch (err) { > > +               case -EOPNOTSUPP: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: device does not support dax"); > > +                       break; > > +               case -EINVAL: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: unaligned partition for dax"); > > +                       break; > > +               default: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: dax access failed (%d)", err); > > +               } > > +               return err; > > +       } > > + > > +       return 0; > > +} > > +EXPORT_SYMBOL_GPL(bdev_supports_dax); > > This patch should replace blkdev_dax_capable(), or just reuse that > existing routine, or am I missing something? Good question.  bdev_supports_dax() is a helper function tailored for the filesystem's mount -o dax case.  While blkdev_dax_capable() is similar, it does not need error messages like "device does not support dax" since it implicitly enables dax when capable.  So, I think we can keep blkdev_dax_capable(), but change it to call bdev_direct_access() so that actual check is performed in a single place. Thanks, -Toshi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751937AbcEISVr (ORCPT ); Mon, 9 May 2016 14:21:47 -0400 Received: from g4t3427.houston.hp.com ([15.201.208.55]:41685 "EHLO g4t3427.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbcEISVq (ORCPT ); Mon, 9 May 2016 14:21:46 -0400 Message-ID: <1462817565.27137.102.camel@hpe.com> Subject: Re: [PATCH v3 2/5] block: Add bdev_supports_dax() for dax mount checks From: Toshi Kani To: Dan Williams Cc: Jan Kara , david , Al Viro , Jens Axboe , Christoph Hellwig , Boaz Harrosh , "Theodore Ts'o" , Andreas Dilger , Ross Zwisler , micah.parrish@hpe.com, "linux-nvdimm@lists.01.org" , linux-fsdevel , "linux-kernel@vger.kernel.org" Date: Mon, 09 May 2016 12:12:45 -0600 In-Reply-To: References: <1462494596-20938-1-git-send-email-toshi.kani@hpe.com> <1462494596-20938-3-git-send-email-toshi.kani@hpe.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2 (3.18.5.2-1.fc23) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2016-05-08 at 12:14 -0700, Dan Williams wrote: > On Thu, May 5, 2016 at 5:29 PM, Toshi Kani wrote:  : > > +int bdev_supports_dax(struct super_block *sb, int blocksize) > > +{ > > +       struct blk_dax_ctl dax = { > > +               .sector = 0, > > +               .size = PAGE_SIZE, > > +       }; > > +       int err; > > + > > +       if (blocksize != PAGE_SIZE) { > > +               vfs_msg(sb, KERN_ERR, "error: unsupported blocksize for > > dax"); > > +               return -EINVAL; > > +       } > > + > > +       err = bdev_direct_access(sb->s_bdev, &dax); > > +       if (err < 0) { > > +               switch (err) { > > +               case -EOPNOTSUPP: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: device does not support dax"); > > +                       break; > > +               case -EINVAL: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: unaligned partition for dax"); > > +                       break; > > +               default: > > +                       vfs_msg(sb, KERN_ERR, > > +                               "error: dax access failed (%d)", err); > > +               } > > +               return err; > > +       } > > + > > +       return 0; > > +} > > +EXPORT_SYMBOL_GPL(bdev_supports_dax); > > This patch should replace blkdev_dax_capable(), or just reuse that > existing routine, or am I missing something? Good question.  bdev_supports_dax() is a helper function tailored for the filesystem's mount -o dax case.  While blkdev_dax_capable() is similar, it does not need error messages like "device does not support dax" since it implicitly enables dax when capable.  So, I think we can keep blkdev_dax_capable(), but change it to call bdev_direct_access() so that actual check is performed in a single place. Thanks, -Toshi