From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 E6AE140DFC5 for ; Tue, 16 Jun 2026 08:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781600067; cv=none; b=bKrx4fw8zbKq/NxNjrsYZgHJfc9i+hDlCxZz4qrdcgKTyTK5XWzdZJ2m7n5dgHy69GW1uYDw2uQ3tpOe5vIRsO3+MEeefhqAsEoT7GaseFsHn2bD+TeLq08OUQFnBF2fLJyMIEO8Pw5TWuFr48/Qc6BNo5mvkx1IK+vv4clZiYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781600067; c=relaxed/simple; bh=9r+RJLp6fhfyf2tAt4+Bflg63dsgtafgTE0cw+Gs7sc=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SDjEMdMLwHsVLvOxeazz2lMs7HEHrMC3u8U6/aho4Beg5hh2cYvUpjtURn8nFHie5qF3JBMX/ENUgxvr7M1vIwJNvgPnKyiIvDksLB7oacWd5vvalS6F2WuCsxhepvOwDAK8/vMFJv5TpryE1hVmYsSYOhzOaM6NN1Dyz/2Cz4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gTcmlKWf; arc=none smtp.client-ip=74.125.82.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gTcmlKWf" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1397e093f90so4598690c88.1 for ; Tue, 16 Jun 2026 01:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781600065; x=1782204865; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=pyIsPkd+pxheUlrd2cqTqR5lUJlcL53tZ2xMuuCyndo=; b=gTcmlKWfqWqmEgsOfQ31ztcCJ2jA9tVP5EZJDVDq9O4RjRifsbou8PkubfFVqtwnjI szHw87NJOpFeo7gfMCqSupdOK2XVOxZjTM+0srnIQt3Dff+QcN9Xaj9BW2nQbSzik/jv l74ZuDihGeJrNqKKcTT65KhDd1ZJ9oecqhkUFMTH6e6XgFycSYOSbv/iduBl9rNbBr30 ngqqN5D8jha5hV6D6o9StCnI1Q+jy6925aJvDJdFb6+HSB368crRaECy/aBBc1BkynOd 30hdGBQgyAMP84buRHqu+Y2HOhkQFSNF24m3M+pSPe85xCiTLt5HeoEH55XAd1+i6X1f zbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781600065; x=1782204865; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pyIsPkd+pxheUlrd2cqTqR5lUJlcL53tZ2xMuuCyndo=; b=H2RRmG0mPcp7mPCXGF1tpzgjdHHbdQqEojf4Fh9Y6VlOb1eUjV7CyxkLXfrw9l/u+Q AvWobsdgN0c1AciQX8iMKLVbspA3GFzqK1NtEHjc4wv9csg67hmrxu6OLNHuEPU7q93g 0DtCVFW0AIBPT73tjJlOcLMwm3MAWuoemoNBiLVe0OwJkN6yYnET/THJ23+3NbTFGg61 iU3yf+8wpLf03zrX+rmqf13FwRLQX0tXBe4XNTlori2VXVBR9Eqbb1NgtdFHnSV7SRE5 MEUpYfebgFnQJwvWRzAWwBZa2z/0ZEHbVJSM7Ksx8SkClJfbZMP/5BF+fx/p2a1IJy2o SDFg== X-Forwarded-Encrypted: i=1; AFNElJ/bemoisazAXEs+y01u4SnjSG7g3c7mLUle72PtmXLY9x+SJSih10iK+Lm8L2G9QESB4jpnWzHt5R5T5ZI=@vger.kernel.org X-Gm-Message-State: AOJu0YzVMHHHX3w4BsamC96RvTvUPKnGoKWOR3H+4plVXcMSuWiejKGG 3b75cb5og7O4MQilzcrk7aOUOiTDD3I+qBd0eq6M6cVt1rbjWdJJMV7e X-Gm-Gg: Acq92OHD2cOUN864ib4msUYVWu4gatNWwCmcSk7DyB3Hla6aGWSM34VGfpYOmomXoXj fJnj8Q6E+ghW7QkUH7OFWUXpBKWCA+6zOpn/7UTUN+gTpV7S4OvVUeaycl5nAKpniQVi+SQlzqw xgHQQwbDzdgdKYNM+bSzGUYk/sYMMqDhF39JrorBXHQBR47IDjohC9lgvpDT6ePB/oArzVF3LSh N8QuNL59yONUpLmsc9xU8Q0r6T4+YxtFOcflwk5FNkmQSa6GjAiKOB33qzhiJ20MXo+H9q5FAAz KSEaTLf272xZNHguB0x14tIvD5lZp7x7/Ewg6O9t01u48soblcij/A1YEQeF38oY2GlnVWSVllb iSXMqvahKSHUITDL/GCtJoX0REiavIyf5fTa3n2eMUuwHGkdizQGabt1+KXyoMIJRW/NdeQAhvm kF7TqxGM1DaR9rURxZdNhlQ+EKo3phLe0pjUlwT9AWd+08e6I2azHmU3uRIyquuG/hugJ5/GjOl QOCPNs= X-Received: by 2002:a05:7022:3d11:b0:12d:cbce:5fb7 with SMTP id a92af1059eb24-13985e95cebmr1267878c88.6.1781600064926; Tue, 16 Jun 2026 01:54:24 -0700 (PDT) Received: from AnisaLaptop.localdomain (c-73-170-217-179.hsd1.ca.comcast.net. [73.170.217.179]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1384b96d6c4sm13284720c88.9.2026.06.16.01.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 01:54:24 -0700 (PDT) From: Anisa Su X-Google-Original-From: Anisa Su Date: Tue, 16 Jun 2026 01:54:23 -0700 To: Dave Jiang Cc: Anisa Su , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Dan Williams , Jonathan Cameron , Davidlohr Bueso , Vishal Verma , Ira Weiny , Alison Schofield , John Groves , Gregory Price , Ira Weiny Subject: Re: [PATCH v10 25/31] dax/bus: Reject resize on DC dax devices and enforce 0-size creation Message-ID: References: <9c73377182f19e86e2cc939ddf0184d5d85581f9.1779528761.git.anisa.su@samsung.com> <8de1e66c-14a2-4933-9c34-be1d1335a36c@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8de1e66c-14a2-4933-9c34-be1d1335a36c@intel.com> On Fri, May 29, 2026 at 10:16:10AM -0700, Dave Jiang wrote: > > > On 5/23/26 2:43 AM, Anisa Su wrote: > > A DC dax device's size is determined by the extents that back it, not by > > the user. DCD extents are all-or-nothing, so partial shrink is just as > > illegal as growing. Enforce that on the size and creation paths: > > > > * size_store: any non-zero resize on a DC region returns -EOPNOTSUPP. > > The sole exception is size=0, which daxctl destroy-device writes to > > return every claimed extent to the region's available pool before > > the device's name is written to the region's 'delete' attribute. > > * __devm_create_dev_dax: a DC dax device must be created at size 0. > > Non-zero data->size on a DC region returns -EINVAL with a clear > > message. > > > > The resize machinery (dev_dax_shrink, adjust_ok, dev_dax_resize_static, > > dev_dax_resize) learns to walk the right parent — dax_region->res for > > static regions, the dax_resource->res for DC regions claimed via > > uuid_store — so shrink-to-0 correctly releases each extent's child > > resource rather than the region's. > > > > Based on an original patch by Navneet Singh. > > > > Signed-off-by: Ira Weiny > > Signed-off-by: Anisa Su > > Reviewed-by: Dave Jiang > > Just a nit below. > > > > > > --- > > Changes: > > [anisa: split out from the original "Surface dc_extents" commit; > > DC-aware resize policy only.] > > --- > > drivers/dax/bus.c | 46 +++++++++++++++++++++++++++++++++++----------- > > 1 file changed, 35 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c > > index 1d6f82920be6..c030eb103ad0 100644 > > --- a/drivers/dax/bus.c > > +++ b/drivers/dax/bus.c > > @@ -1136,7 +1136,8 @@ static int dev_dax_shrink(struct dev_dax *dev_dax, resource_size_t size) > > int i; > > > > for (i = dev_dax->nr_range - 1; i >= 0; i--) { > > - struct range *range = &dev_dax->ranges[i].range; > > + struct dev_dax_range *dev_range = &dev_dax->ranges[i]; > > + struct range *range = &dev_range->range; > > struct dax_mapping *mapping = dev_dax->ranges[i].mapping; > > struct resource *adjust = NULL, *res; > > resource_size_t shrink; > > @@ -1152,6 +1153,10 @@ static int dev_dax_shrink(struct dev_dax *dev_dax, resource_size_t size) > > continue; > > } > > > > + /* > > + * Partial shrink: forbidden on DC regions, so dev_range > > + * here must belong to a static device. > > + */ > > for_each_dax_region_resource(dax_region, res) > > if (strcmp(res->name, dev_name(dev)) == 0 > > && res->start == range->start) { > > @@ -1195,19 +1200,21 @@ static bool adjust_ok(struct dev_dax *dev_dax, struct resource *res) > > } > > > > /** > > - * dev_dax_resize_static - Expand the device into the unused portion of the > > - * region. This may involve adjusting the end of an existing resource, or > > - * allocating a new resource. > > + * __dev_dax_resize - Expand the device into the unused portion of the region. > > + * This may involve adjusting the end of an existing resource, or allocating a > > + * new resource. > > * > > * @parent: parent resource to allocate this range in > > * @dev_dax: DAX device to be expanded > > * @to_alloc: amount of space to alloc; must be <= space available in @parent > > + * @dax_resource: if dc; the parent resource > > * > > * Return the amount of space allocated or -ERRNO on failure > > */ > > -static ssize_t dev_dax_resize_static(struct resource *parent, > > - struct dev_dax *dev_dax, > > - resource_size_t to_alloc) > > +static ssize_t __dev_dax_resize(struct resource *parent, > > + struct dev_dax *dev_dax, > > + resource_size_t to_alloc, > > + struct dax_resource *dax_resource) > > { > > struct resource *res, *first; > > int rc; > > @@ -1215,7 +1222,8 @@ static ssize_t dev_dax_resize_static(struct resource *parent, > > first = parent->child; > > if (!first) { > > rc = alloc_dev_dax_range(parent, dev_dax, > > - parent->start, to_alloc, NULL); > > + parent->start, to_alloc, > > + dax_resource); > > if (rc) > > return rc; > > return to_alloc; > > @@ -1229,7 +1237,8 @@ static ssize_t dev_dax_resize_static(struct resource *parent, > > if (res == first && res->start > parent->start) { > > alloc = min(res->start - parent->start, to_alloc); > > rc = alloc_dev_dax_range(parent, dev_dax, > > - parent->start, alloc, NULL); > > + parent->start, alloc, > > + dax_resource); > > if (rc) > > return rc; > > return alloc; > > @@ -1253,7 +1262,8 @@ static ssize_t dev_dax_resize_static(struct resource *parent, > > return rc; > > return alloc; > > } > > - rc = alloc_dev_dax_range(parent, dev_dax, res->end + 1, alloc, NULL); > > + rc = alloc_dev_dax_range(parent, dev_dax, res->end + 1, alloc, > > + dax_resource); > > if (rc) > > return rc; > > return alloc; > > @@ -1264,6 +1274,13 @@ static ssize_t dev_dax_resize_static(struct resource *parent, > > return 0; > > } > > > > +static ssize_t dev_dax_resize_static(struct dax_region *dax_region, > > + struct dev_dax *dev_dax, > > + resource_size_t to_alloc) > > +{ > > + return __dev_dax_resize(&dax_region->res, dev_dax, to_alloc, NULL); > > +} > > + > > static ssize_t dev_dax_resize(struct dax_region *dax_region, > > struct dev_dax *dev_dax, resource_size_t size) > > { > > @@ -1277,6 +1294,8 @@ static ssize_t dev_dax_resize(struct dax_region *dax_region, > > return -EBUSY; > > if (size == dev_size) > > return 0; > > + if (size != 0 && is_dynamic(dax_region)) > > + return -EOPNOTSUPP; > > if (size > dev_size && size - dev_size > avail) > > return -ENOSPC; > > if (size < dev_size) > > @@ -1288,7 +1307,7 @@ static ssize_t dev_dax_resize(struct dax_region *dax_region, > > return -ENXIO; > > > > retry: > > - alloc = dev_dax_resize_static(&dax_region->res, dev_dax, to_alloc); > > + alloc = dev_dax_resize_static(dax_region, dev_dax, to_alloc); > > if (alloc <= 0) > > return alloc; > > to_alloc -= alloc; > > @@ -1674,6 +1693,11 @@ static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data) > > struct device *dev; > > int rc; > > > > + if (is_dynamic(dax_region) && data->size) { > > + dev_err(parent, "DC DAX region devices must be created initially with 0 size"); > > Needs \n > Fixed! Thanks, Anisa > > + return ERR_PTR(-EINVAL); > > + } > > + > > dev_dax = kzalloc_obj(*dev_dax); > > if (!dev_dax) > > return ERR_PTR(-ENOMEM); >