Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp851346ybb; Wed, 25 Mar 2020 10:49:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuAKsBPyrvgJKnFPDgN0vysZjuVR7SnM5K7tMzQCu3OtssKLzH6//gpFgJNfZHtNIuhwt/M X-Received: by 2002:a9d:6310:: with SMTP id q16mr3072965otk.147.1585158584407; Wed, 25 Mar 2020 10:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585158584; cv=none; d=google.com; s=arc-20160816; b=bqyAkZP8sb34OZH6zoTxZtxmk/wqcyL4oe5U4wPqRYq0aS6R8ohl+ahL3bPNxO1d3w AEYmFavIAToblu/3/wYgUfKiZvbbJwEYIUsZiQyyeUIZSVH8/PxPbrdAMbFO3KhVIfce Yi8d7E9v/nlGnUdzci49c9E010jvC6m7TS0xa41uvR2qP+gcvztYLLpviJC4BCCixXWG sAtJGilK90i0qS3B2OkbzYZ4gl6I3M9YrrrGG1jIt0lwljazCKX5pGjkXK/zvI6y9Dgd 2mbnbCJjORE4BL25K47p+A3E9t9wqUGT8fcjGcU0Kj5Uxbm/TRcEmWbhQaaKDCEhAgRw Yg+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UQLg73f4A6IdCvlkz6AAgidHZXBVbjJUTIhnj9QMJq0=; b=y8VVcQTkfSwGY5gV24zqxWBlQV38JsXuLZctf13jUJ+xFqsdHyVOAyVw/gY5wB/w/y 9t7mu/wfrKKWxSARs986T8cvmEZQO2nXQS4pqKZvRb08NwQT1dW9dZB5ThgbJI0pN9zZ VgmpKlEvuLAllTEQLRlA87rvV81fdob1DlG3HwE7iVQxQmh29w7SpxQX7IHgJkTCJQJn jfjOQwiWm6ZLIPVY2xozxk+DMEsGgrmKz9bLdoRtF0hXUmmFtYFbcxe0Y8uVtcE2rj0B NLskX6anHNl5o6tcb3bctWVLKyC1zn6toiG9Q1cjvBIccwj39dopOoONAFFt9fv0w81N DT5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=CArd9H+n; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r24si5494915otp.264.2020.03.25.10.49.31; Wed, 25 Mar 2020 10:49:44 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=CArd9H+n; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbgCYRtM (ORCPT + 99 others); Wed, 25 Mar 2020 13:49:12 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:45998 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727253AbgCYRtM (ORCPT ); Wed, 25 Mar 2020 13:49:12 -0400 Received: by mail-ed1-f68.google.com with SMTP id u59so3579843edc.12 for ; Wed, 25 Mar 2020 10:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UQLg73f4A6IdCvlkz6AAgidHZXBVbjJUTIhnj9QMJq0=; b=CArd9H+nUYQo86GgTO34kcf8M/qaGTtxoUap7Zv3rckjuMdaZYN1F6JjgfnWPrmmQD STLiZXfm9tTL4tzLvCBpRJ7We2yFE5YuaVYOVylxRmNv+lJGiiAUSyUkCZ2JU2MdAdtK /mehUtAxrA6Npr8A1L1muHfUvFvs2COnFJy1ZnrkPpjoNS8yFICdQt3s0xwQfjnwCpbU iX04wAD3h9RPqTOKiG6KbgGQ4OF9ezvrMsfHGyNb7m92ahBGPMbYr0/XbX7m2hj1Pebn xuQdsVlIEt+LULaBWLDhOZkiim1Sh7F259hWZF0OdyJeF8VkU9WQLChRU/rMYvagJ8Gg Gcpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UQLg73f4A6IdCvlkz6AAgidHZXBVbjJUTIhnj9QMJq0=; b=MiP7dDLeGBBV+7L81+zxo0JZxHe2plp9sUUliX90/yKlEfLAdPEX4xuq15ksN+wduq yJeOfvXBJ4G131rTIPHejZ82GznFvbifR30giYbjFpiqgXRrf9JExNBQjg0Rp2cLsRj3 CE8UV5kmLztv8O8hW1GYJbFGT1ukVWJYHObijbDk0+A5y0f2mNgvf1+N8EI6vnFGL0Cy aJzWux3kqe8X/4FngKlCpR7PaUgV83NNbrOOgO9zlbuusIZa7o1miWtJtc/EjR9ZK+Ti UoDb96J//XZYlQ6leygGz4/uh7zKGTLAdbE4noBX63jXE4uTMER1wph7uLl77veHv8oj 2XcA== X-Gm-Message-State: ANhLgQ1TW+Qy8HKpA09W/GHbuB2dS12o0UcqFg4+1jUfZhDDxYytF8MX Z2gSXpcidYhcCegp4RORJkVCK1I4lSDWe6VbNOIgQQ== X-Received: by 2002:aa7:c609:: with SMTP id h9mr4043188edq.93.1585158550697; Wed, 25 Mar 2020 10:49:10 -0700 (PDT) MIME-Version: 1.0 References: <158500767138.2088294.17131646259803932461.stgit@dwillia2-desk3.amr.corp.intel.com> <158500773552.2088294.8756587190550753100.stgit@dwillia2-desk3.amr.corp.intel.com> <9a6ff83f-095c-0689-d6d1-693a6e9c07e6@oracle.com> In-Reply-To: From: Dan Williams Date: Wed, 25 Mar 2020 10:48:58 -0700 Message-ID: Subject: Re: [PATCH 11/12] device-dax: Add dis-contiguous resource support To: Joao Martins Cc: Linux MM , Dave Hansen , Christoph Hellwig , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 3:35 AM Joao Martins wrote: > > On 3/24/20 4:12 PM, Joao Martins wrote: > > On 3/23/20 11:55 PM, Dan Williams wrote: > >> static ssize_t dev_dax_resize(struct dax_region *dax_region, > >> struct dev_dax *dev_dax, resource_size_t size) > >> { > >> resource_size_t avail = dax_region_avail_size(dax_region), to_alloc; > >> - resource_size_t dev_size = range_len(&dev_dax->range); > >> + resource_size_t dev_size = dev_dax_size(dev_dax); > >> struct resource *region_res = &dax_region->res; > >> struct device *dev = &dev_dax->dev; > >> - const char *name = dev_name(dev); > >> struct resource *res, *first; > >> + resource_size_t alloc = 0; > >> + int rc; > >> > >> if (dev->driver) > >> return -EBUSY; > >> @@ -684,38 +766,47 @@ static ssize_t dev_dax_resize(struct dax_region *dax_region, > >> * allocating a new resource. > >> */ > >> first = region_res->child; > >> - if (!first) > >> - return __alloc_dev_dax_range(dev_dax, dax_region->res.start, > >> - to_alloc); > > > > You probably want to retain the condition above? > > > > Otherwise it removes the ability to create new devices or resizing it , once we > > have zero-ed the last one. > > > > A quick unit test that I had stashed here to help explain what I mean: > > cd /sys/bus/dax/devices > # dax0.0 is the only dax device in the corresponding dax_region > echo dax0.0 > dax0.0/driver/unbind > echo 0 > dax0.0/size > # Shouldn't fail but returns -ENOSPC despite having > # the full region available > cat $(readlink -f dax0.0/../dax_region/available_size) > dax0.0/size Thanks! Will incorporate that test before resending the series.