Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2534270lqo; Mon, 20 May 2024 08:39:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQE2pV+etxjRkPVZb2olyMYtEbYJ/MynRqPatDIz77KQa1UrdDuYKHTtWecghAJ0djUoGu5p4FpE3eodrbxmZjg5vDW5ExcUqH6fjF0w== X-Google-Smtp-Source: AGHT+IE0xt6xIgDPxsIvy09rg8YY/ldBnWEee6zT/EY609rYU5/WpEylt+Bm0gpmuAN8UYSNX5iw X-Received: by 2002:a05:6358:c015:b0:17b:f721:4565 with SMTP id e5c5f4694b2df-193bb517de3mr2964783155d.9.1716219572478; Mon, 20 May 2024 08:39:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716219572; cv=pass; d=google.com; s=arc-20160816; b=XY+VkFsjCnMOxn0/UekHgPs8BRA47WIBlmzQD9zbuCczzoK5VY64B0MV8mMCV+05TK X+OZ12/BcabS9jn50hyyiX2iCeMBEPy+Wn4bG+0wJciyJd6LeWlX+1VXlULUVlSMDWxR GYTBart48mQQSMTbGGbXRKfjvaKO11e3A0VJUNPz3cLSSWdgBbQeYIk7ObI/N1Qz997w WOLlNqQFteYNbAqjJcqsPFi6WW5NFXM7b8LRtUeyYx/N0K9gSQ14gj2/sVjvnUUCrSYs jJSFfdl1TYvzk18jlbSR3MFYp/sNEWcC8iMqABfdC3nOZ3CPif4UNO4/eiHBRmv2WXpy jvaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=NBcJrLEWNBl1O8nscyyQswrK8131ixxbt9bv821Iwzo=; fh=mkCVYa3JZlSy74HQ9FMXL09u68uruyi+PRcZr1HR5Dk=; b=rZmtRhtiP1BFR6B6RSZ4MV9/UUFQEPVEKAhje15L2Dhwgw1W+xrLgOE0tEGYbh70fm ac0gzkDVwEXtxAqDppL3s93ZBL41JFyaAnsAnVVZ2VJu+ZFTiz4EwKvk3faMbiMi9XzK DQQ556QBYo3mRFqlvwfJ1rwxORcWCj9gzoJD3ET4xcuEP9sOjk9zOsG8IwMrlol0VS0Q 6CzBge4vVZdPvYoyKo78Pk/LbY5W2T585BXC01SfbajdzqPiUzo+aSlip+6lF5DvDlPx 036tlbWy3GIH7quNPm4V6XBye0lNEOZnI2wVFGcv/4fE48orISJerKS3967CgbwAn/Qm 3UUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-ext4+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-65bc5dd2a8fsi7705915a12.153.2024.05.20.08.39.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 08:39:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-ext4+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CF92AB21180 for ; Mon, 20 May 2024 15:39:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C4A4137759; Mon, 20 May 2024 15:39:19 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 824B4FC01 for ; Mon, 20 May 2024 15:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716219559; cv=none; b=JIo9rbLsdgXhSgBPuLiwTv26t+WGFr8T6ltj5oHmtIZ0730xzYkkk72a9IZTPwyrMiB7Ocv/zd4d6hqt4SeBotYH71JeAJqQ9Cuij17obMkoGm01w4f81XDoPIFWt7Gp3jJcJ/ZtyKhalwG+stog0DjcUHNpsx22SAC7PN+K5y0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716219559; c=relaxed/simple; bh=0ifuD6C1Ultrufai42ZbuWkP4Y2UGqM45yev2rRHqMc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=txsL/SaYH3zg5vh4nVoBPpE6MQtHLbItLL3UT9ui6fzHjGZOcjhEGyWZ2yTVtUD5LUByDjEmSFcRE/zb+5khr11dNEGWtwh6nwCeLoVMvn8UsmKLN1Lkf6UxusWInMkq1vA5RqN/+2/rZQh+bnnuPas+E+Ck2AqT6tM3RcgdJTQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3c9c41cdd32so1435785b6e.0 for ; Mon, 20 May 2024 08:39:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716219556; x=1716824356; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NBcJrLEWNBl1O8nscyyQswrK8131ixxbt9bv821Iwzo=; b=mVGDg06xJsKd/s30whPZGml1X9bBTQt4qE4xWvDGK84bmPCG5pujUVDOYhVQ/ZCIhp 1P16TtWYBQVQg8YeI4aw/RssRA+j6jG6SOSvZR+4mWn6xdalOz+oqFpXAeLgp6IUkESn jr8PYjuK7pdqWzWR3otVClzSTeUdwPKVkQYw0iY3GpHARWdpHl56bhHuLc7aTAkG00Qd 43p5m5uh2TMxOErdwooTJF94mOw5wFat5AAsciVfPjRXOKj7WnsFKCvJijEhFVYZBx4H uN0m3h0UDmSfFLNRf8p7J+vxAyKadOI1cHpLcpcVs6FhnCEUbZ7KjCr4/Xwp9b9ntRIy JlSw== X-Forwarded-Encrypted: i=1; AJvYcCXPpWsICSdpSQlZ8kwSc+l8gmeReiFNgRrMsS3zHUHWvBQznoXiL/9R2ZdQbG+5r9Zsi5+y7PwrjTsvFW007pQ2vZ9HG0svFuSnOA== X-Gm-Message-State: AOJu0Ywh6P6BPtf5//Kwte92idVghow4meyBiCm40Ug5ZWnyxa6nbtwR 6z/i/CyGoDu+6b8PFku2vyKb+i10HyCljCLJTervp2GZh7uEr6f8GuTEWkRfaN1TZr4fAvqhFlR 4b/U= X-Received: by 2002:a05:6808:144b:b0:3c9:d067:1de9 with SMTP id 5614622812f47-3c9d0671e8cmr10179395b6e.34.1716219556593; Mon, 20 May 2024 08:39:16 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-792bf2fca1dsm1194750485a.92.2024.05.20.08.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 08:39:15 -0700 (PDT) Date: Mon, 20 May 2024 11:39:14 -0400 From: Mike Snitzer To: Christoph Hellwig Cc: Theodore Ts'o , dm-devel@lists.linux.dev, fstests@vger.kernel.org, linux-ext4@vger.kernel.org, regressions@lists.linux.dev, linux-block@vger.kernel.org Subject: Re: dm: use queue_limits_set Message-ID: References: <20240518022646.GA450709@mit.edu> <20240520150653.GA32461@lst.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240520150653.GA32461@lst.de> On Mon, May 20, 2024 at 05:06:53PM +0200, Christoph Hellwig wrote: > On Sun, May 19, 2024 at 01:42:00AM -0400, Mike Snitzer wrote: > > > This being one potential fix from code inspection I've done to this > > > point, please see if it resolves your fstests failures (but I haven't > > > actually looked at those fstests yet _and_ I still need to review > > > commits d690cb8ae14bd and 4f563a64732da further -- will do on Monday, > > > sorry for the trouble): > > > > I looked early, this is needed (max_user_discard_sectors makes discard > > limits stacking suck more than it already did -- imho 4f563a64732da is > > worthy of revert. > > Can you explain why? This actually makes the original addition of the > user-space controlled max discard limit work. No I'm a bit doubful > that allowing this control was a good idea, but that ship unfortunately > has sailed. That's fair. My criticism was more about having to fix up DM targets to cope with the new normal of max_discard_sectors being set as a function of max_hw_discard_sectors and max_user_discard_sectors. With stacked devices in particular it is _very_ hard for the user to know their exerting control over a max discard limit is correct. > Short of that, dm-cache-target.c and possibly other > > DM targets will need fixes too -- I'll go over it all Monday): > > > > diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c > > index 4793ad2aa1f7..c196f39579af 100644 > > --- a/drivers/md/dm-thin.c > > +++ b/drivers/md/dm-thin.c > > @@ -4099,8 +4099,10 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits) > > > > if (pt->adjusted_pf.discard_enabled) { > > disable_discard_passdown_if_not_supported(pt); > > - if (!pt->adjusted_pf.discard_passdown) > > - limits->max_discard_sectors = 0; > > + if (!pt->adjusted_pf.discard_passdown) { > > + limits->max_hw_discard_sectors = 0; > > + limits->max_user_discard_sectors = 0; > > + } > > I think the main problem here is that dm targets adjust > max_discard_sectors diretly instead of adjusting max_hw_discard_sectors. > Im other words we need to switch all places dm targets set > max_discard_sectors to use max_hw_discard_sectors instead. They should > not touch max_user_discard_sectors ever. Yeah, but my concern is that if a user sets a value that is too low it'll break targets like DM thinp (which Ted reported). So forcibly setting both to indirectly set the required max_discard_sectors seems necessary. > This is probably my fault, I actually found this right at the time > of the original revert of switching dm to the limits API, and then > let it slip as the patch was reverted. That fact that you readded > the commit somehow went past my attention window. It's fine, all we can do now is work through how best to fix it. Open to suggestions. But this next hunk, which you trimmed in your reply, _seems_ needed to actually fix the issue Ted reported -- given the current validate method in blk-settings.c (resharing here to just continue this thread in a natural way): diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 4793ad2aa1f7..c196f39579af 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -4497,7 +4499,8 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) if (pool->pf.discard_enabled) { limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; - limits->max_discard_sectors = pool->sectors_per_block * BIO_PRISON_MAX_RANGE; + limits->max_hw_discard_sectors = limits->max_user_discard_sectors = + pool->sectors_per_block * BIO_PRISON_MAX_RANGE; } }