From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 273FC282F1B for ; Tue, 28 Jul 2026 01:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785201591; cv=none; b=aAQmyL09ggM/6c3YT9jzpgv8AKHCiusrDjBotahoKmEMmDdcN9JR/WRftoAHAFlZT5JBY4RFkn7rN9Lvq/DYCK5U6c+Ddw8JdMXuLusabrypa7Gz0VP+G+SdNgV8DOOtBhsjUkm726S0wzTn/8Bov/w5Z37J7Ph00DbSRHO0giI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785201591; c=relaxed/simple; bh=kFHJTUVvEE/uP8i2yFWYp1IcFU3L7GkLV7gw8MZJixY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=icWuQ2+V0vRPl+0G+xufDWCeqpVwbBsZDbno7UBdSkfJjv+o8vk/y2iperYSUEQkDzgzQphaE7rUuMdoRJuFw+ONGuD/Ksvzxj9ZtIIU5UulgjplEKZTHNn8myecdW3HCtLWajjyGBz2sMrm/95v8Cj4U2jh+pF832Sl6V2NNz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=hzujmP4E; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hzujmP4E" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2cc7ef7ec27so42118035ad.1 for ; Mon, 27 Jul 2026 18:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1785201589; x=1785806389; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=9EtjCXe6kHul7yZNnrYvGTEf90lw7uffdRpbms4sKAo=; b=hzujmP4ETQGq75XfiXCOyokfLrts72svnRvhUPiTMysIbeO3w5AEz/V7TzL/BsKK2W 9Ce+dWEBDOZdZsF5uypUGi37tV6bet51eIIbVeRizxRFeVu0uuG5AukbWj89dYd6fwxI 1byB15fCvsXplp/F3NjfaSm1UGz4M8ABKAPpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785201589; x=1785806389; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=9EtjCXe6kHul7yZNnrYvGTEf90lw7uffdRpbms4sKAo=; b=iLVl8h+9KqL5xunHZs8np2zUP7TeVJQ0TxrUJuaIlEsFcu75hvYBmuw58yuRiDbVDj yD9vGBxpaDjYzmof7ZCTK9HNQ9EbdpFOXMCjtLNlRs1B4remKSRlv6zAYaGD3WNojWVV 8j1BCgOCcRhFfIW9vPLitZF1eDdcPEVTLwETYWTq8C6gtUWckJIqFyn7Mh8zSaBQCHyZ w23b89CkkEHaW7He+cuaoHIhDAAl8ci1DL3EGwv0c/8a7zobAT8AYvejVoOFx0d+iD4j MbNBpOYJPQehP4R0LrfP+yQ3myJFSrn88PxhFMwRLq3AuLkTW4H56j6qoBxG27uWyZkx z3cQ== X-Forwarded-Encrypted: i=1; AHgh+RpDLVGnpUk32UxWzVwYgzE+0Yn5I3o/cegOUnZSIghFgSFC3EWZRWoLfQtPzsF/QewA6qxstffPYYIrg78=@vger.kernel.org X-Gm-Message-State: AOJu0Yz01iUcUbicm0hQ0jR0OGaZI5ei/z2Whl0Oewnc1IyhmEMTA/yA M+HUpRRqGlqt56cUPOpUP1Ju71wDleXeo9I7fBPtE6H6jnvTthI+zQviuzV9OswJdw== X-Gm-Gg: AR+sD13FUgDHANr+oHSoZ2MfeieqxG658BMCpV2SJfuaLwdKTvPbP7dS5S7FqBeuOMd 2Rl+n+YxNAB6xHnFWSy0MGnN+nhA1kLisqlR3Nj4oYljmhmglbJtri8YhxTtcfpp746PUHBDwjj ckuPI+2+DOhBx1jVd0pfQYTYD28OPnxeEB/n9neQULP911cxJpQVwcIUeIx7z5dupKvqv7e6ibI YClI+oXoE6eq7NKB1VP9OENNHCTi3xwtEHv6cYfLr7jErJsho1T7B6Rap95ijC8zQVrhVAfqeZ1 gATk+FlcDOIfcJ/4kjrMr6Hc4t1qgKkaYZ6cNHnDSsz4aIETN2ww1zSGqPsXPvUp+3tICDcxbEZ MgPI207kJOC5BqtUGL5WXh/enSf60mYFOTsMX/AJzSt2sAJuqsMhpWd+KKSXsoFPmzOsSLFDmb/ idnsPEJY7e2QGwnb/3f18wpwky5ZRtVxn5NDs7fbwlq6Si1YWTOHmv X-Received: by 2002:a17:903:388d:b0:2c9:e69f:8b0f with SMTP id d9443c01a7336-2d015d01806mr2748285ad.17.1785201589498; Mon, 27 Jul 2026 18:19:49 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:f891:e0e8:e2c3:fb20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cfde81dcb3sm42696255ad.82.2026.07.27.18.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 18:19:48 -0700 (PDT) Date: Tue, 28 Jul 2026 10:19:44 +0900 From: Sergey Senozhatsky To: haoqin huang Cc: Sergey Senozhatsky , minchan@kernel.org, axboe@kernel.dk, terrelln@fb.com, dsterba@suse.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, rongwei.wrw@gmail.com, Haoqin Huang , Rongwei Wang Subject: Re: [PATCH 2/3] zram: add per-backend capability flags and validate parameters early Message-ID: References: <20260627070216.13511-1-haoqinhuang7@gmail.com> <20260627070216.13511-2-haoqinhuang7@gmail.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: On (26/07/28 00:50), haoqin huang wrote: > On Fri, Jul 24, 2026 at 1:28 PM Sergey Senozhatsky > wrote: > > > > On (26/06/27 15:02), Haoqin Huang wrote: > > > Writing dict or level parameters for algorithms that don't support > > > them was silently accepted but had no effect. Out-of-range levels > > > were silently clamped by the underlying library. Dict read failures > > > always lost the real error from kernel_read_file_from_path(). > > > > > > Add caps, level_min and level_max to zcomp_ops and validate > > > user-supplied parameters in algorithm_params_store() before storing, > > > giving immediate error feedback. Also fix comp_params_store() to > > > read the new dict into a temporary buffer before resetting old > > > parameters, making the update atomic. > > > > I probably would prefer not to add this. Again, zram setup is almost > > always automated, you figure out what you need to put into your init > > script once and you never touch it again. > > > > That's a fair point. The sysfs validation is admittedly defensive. > > My thinking was just that without any feedback, a misconfiguration can > be hard to notice. For instance: > > algo=lzo dict=/data/dict -> setup_params() silently discards it > algo=deflate dict=/data/dict -> same, silently ignored > algo=zstd level=999 -> silently clamped to 22 by the library > > All of these succeed without a peep -- not a crash, but also no > indication that anything was wrong. We were thinking about moving from zcomp to crypto API acomp. So I'm not sure if we want to invest a lot of time into zcomp. If you want to have it then I'd ask to split caps and kernel_read_file_from_path() zero i_size check into separate patches. We also probably want some pr_err() on failed validation, because just returning -EINVAL doesn't explain the error and doesn't help the (supposedly) clueless user who attempts to configure zram by throwing random numbers at it. > > The 0 i_size for CD-dict is something that simply should not happen. > > If you insist on handling that then we can replace "sz < 0" with "sz <= 0", > > but that 0 len dictionary case is something purely theoretical. > > That's fine, I'll use sz <= 0 in v2. > > Anyway, let me split the original patch so the non-controversial part > stands on its own: > > [2/3] zram: make dict update in comp_params_store() atomic > > Move comp_params_reset() after kernel_read_file_from_path(), so an > I/O error doesn't leave the old dict freed with nothing to replace > it. Also preserve the actual error code. > > [3/3] zram: add per-backend caps and validate parameters early > > Optional -- happy to drop if you still feel it's unnecessary. Sounds good.