From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D81072 for ; Wed, 27 Oct 2021 23:07:18 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id i5so3088862pla.5 for ; Wed, 27 Oct 2021 16:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3af0vrDw+XvQKylIm0LDLH9D6xoJ74LhsidYuXkOM7g=; b=d6phRBLSNqEavLbFGa7qsltfCwCXOIkQGNewJdYfiMwINhHDbJ+v3Tvr+m7SXCKglh f1Y9JyoYsY7pru2o0qaf9ZrRobsN47Jue96kM8PwOADE6VAIkbXtDJTZy+mzrce1H5ii TDWfFC/E9fe8cXOG72hb4HndsLJ5qovtA1WXr8x1UXXNXsg6OU7/y9sWKZsB9Ro8FzaF 3kotXlCmovzhrPQGnkvqh1aQ4+kBEwqSKMSlKnEz5Ahj4QsLMDMTI4jX5+IsmEJsZDOu D4ACx/M3ONMf14xOrt8n/jVyvHMKdyB04vPcp4aB9RBAawLg1e2wm7UXNUEREJEycjA9 pSnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3af0vrDw+XvQKylIm0LDLH9D6xoJ74LhsidYuXkOM7g=; b=HdhCT+iFz5r4Jt0NdtFvfvev0qHUK8t9ZCvLenYYrEGD7Sc619hZWU3JQTRzzk8k7x gEI+nHUVrG3grJ+IbKmx5OTpRqW0V0ElBppSEFycezVBJkJNENxl2iW2D93Pzu9b2WYG 8AhgT8TSDL0dZKdp7shp+SGJrvek0bZpwbjp4AjrBxcR42gcPWM0pbEuY6UeSIYS9g1a TbR6HY7kpBF4q88DzKMUhlP6GHO2tSCuf65xfBCbH59mvK3+bReNv45NpToaqESf6va/ nanyuIEYNyihqsqQxI9jaJ7xa4Rr8/5cZm6PYz7HCgHeYBkVu2Km7EpFYCQPfKdQQ3dh 3mYA== X-Gm-Message-State: AOAM533WmdepFhcUuJEg+tTVR0i2hnzZQMJQ2s+exidqN/dnPJlVzWu3 LL7R6+Uh1d7AtA6+MVeKeqKCkztM4wqGOlqtz9Hx9A== X-Google-Smtp-Source: ABdhPJxTOfk9fcqxHjqgG3f1vnNsNPlrTHxqnz6/LIE7U1wpYxfkWo7JAy9TqN/B72HDrJA9DjHrJAEIhgWs2Md2+FA= X-Received: by 2002:a17:90b:350f:: with SMTP id ls15mr618659pjb.220.1635376038542; Wed, 27 Oct 2021 16:07:18 -0700 (PDT) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-6-hch@lst.de> In-Reply-To: <20211018044054.1779424-6-hch@lst.de> From: Dan Williams Date: Wed, 27 Oct 2021 16:07:07 -0700 Message-ID: Subject: Re: [PATCH 05/11] dax: move the partition alignment check into fs_dax_get_by_bdev To: Christoph Hellwig Cc: Mike Snitzer , Ira Weiny , device-mapper development , linux-xfs , Linux NVDIMM , linux-s390 , linux-fsdevel , linux-erofs@lists.ozlabs.org, linux-ext4 , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" On Sun, Oct 17, 2021 at 9:41 PM Christoph Hellwig wrote: > > fs_dax_get_by_bdev is the primary interface to find a dax device for a > block device, so move the partition alignment check there instead of > wiring it up through ->dax_supported. Looks good. > > Signed-off-by: Christoph Hellwig > --- > drivers/dax/super.c | 23 ++++++----------------- > 1 file changed, 6 insertions(+), 17 deletions(-) > > diff --git a/drivers/dax/super.c b/drivers/dax/super.c > index 04fc680542e8d..482fe775324a4 100644 > --- a/drivers/dax/super.c > +++ b/drivers/dax/super.c > @@ -93,6 +93,12 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev) > if (!blk_queue_dax(bdev->bd_disk->queue)) > return NULL; > > + if ((get_start_sect(bdev) * SECTOR_SIZE) % PAGE_SIZE || > + (bdev_nr_sectors(bdev) * SECTOR_SIZE) % PAGE_SIZE) { > + pr_info("%pg: error: unaligned partition for dax\n", bdev); > + return NULL; > + } > + > id = dax_read_lock(); > dax_dev = xa_load(&dax_hosts, (unsigned long)bdev->bd_disk); > if (!dax_dev || !dax_alive(dax_dev) || !igrab(&dax_dev->inode)) > @@ -107,10 +113,6 @@ bool generic_fsdax_supported(struct dax_device *dax_dev, > struct block_device *bdev, int blocksize, sector_t start, > sector_t sectors) > { > - pgoff_t pgoff, pgoff_end; > - sector_t last_page; > - int err; > - > if (blocksize != PAGE_SIZE) { > pr_info("%pg: error: unsupported blocksize for dax\n", bdev); > return false; > @@ -121,19 +123,6 @@ bool generic_fsdax_supported(struct dax_device *dax_dev, > return false; > } > > - err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff); > - if (err) { > - pr_info("%pg: error: unaligned partition for dax\n", bdev); > - return false; > - } > - > - last_page = PFN_DOWN((start + sectors - 1) * 512) * PAGE_SIZE / 512; > - err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end); > - if (err) { > - pr_info("%pg: error: unaligned partition for dax\n", bdev); > - return false; > - } > - > return true; > } > EXPORT_SYMBOL_GPL(generic_fsdax_supported); > -- > 2.30.2 >