Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp334668lqo; Wed, 8 May 2024 00:45:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOczvRX/1cYPvwbHdNgbHatpkPNrLT7wiWB5OIJeWe8FD3ppaoxx6sVdAFn3ZOhW/m6NiScJrQ6Mrx8kr71xX3aJ5W+ib4nkxUuYpoew== X-Google-Smtp-Source: AGHT+IHkJDhj5EP8gEVZmrWou+42GZAmqWYOw74Wx+YWaBqkZMV14A35iIdE9856IyybQlv4cikQ X-Received: by 2002:a05:6214:1246:b0:6a0:6545:2306 with SMTP id 6a1803df08f44-6a1514e92e3mr21920556d6.28.1715154332035; Wed, 08 May 2024 00:45:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715154332; cv=pass; d=google.com; s=arc-20160816; b=JGDusRIitLXzttc0eJRcmVvyYce1rvcosoXtC11Yae7zJRq+u/NIuRwSUWpdWnLRXb CqYmQXfG0mGMbzQej3RCzSNkN6lCAQZTks2aTdwBEkxqsflJ2SavBo/lfLaZlzQN02rd j3zJj698WweleKeCcVCmSWpxWRCTvvMJp/krV1Mb1rY8DWR3s0kS7mPrmnuKFSWPCDX8 OfBnTsZWPmvf6qlBv4OrHbm6ixgC0/FTn3tkVABVN1b9v8VNA3PYpMfaDOjy3JtyBX73 vm2lSqfdcFA1VWomVE0szT1CQqZhYEW38EnNUyqL7hvQtKTy3xlE11DwZk+4JZ+0OdES 00Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hvvjJAe8l8tDTfecPvMLnwPB1eap8xtvETRDKvyj4SM=; fh=UKstJvjqAQ3P/Vkvglih02Z8FmmRnlaJbql9clnU9dw=; b=Gl7PRNEE/LHIjikXp25eZRbF1O9SdZFjPSAR54z6DBV4agt/hlMzrjGyZH2kvm0TC0 1Y5Y79KVUCa7pJUWSlzCvHj+1PJuP+sesZNDWpF3nynL9G/VYgsmmIfqiHshDNnIX5vF j9xBLO3bGW+EGJu69lyB1equHY9HJWEgoUiHA4gRZQcdLKpNv08yqRHKUw0LGhm/4rrF 4yZ8r+bzSUD/L0vmImpiIH2gAxSmQL+TSYxyEUZvTZnBKuRhz7HbpK2YeI4yZPTIIFIJ mSH4Bf4DeIkMT+tdf2vxiYa1k4Y26rfozPhQvixs4xVoH5hAtL/i/nxIzmfv3WCAx74M 8dlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NLynwZUY; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-172841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id hf15-20020a0562140e8f00b0069b77150c11si13279883qvb.169.2024.05.08.00.45.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:45:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NLynwZUY; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-172841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C02281C22374 for ; Wed, 8 May 2024 07:45:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B8226CDA9; Wed, 8 May 2024 07:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NLynwZUY" Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 09E9156B69 for ; Wed, 8 May 2024 07:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715154184; cv=none; b=BOUfmf0H2qfFgt1AKrKV23WADwZWS6QGPddQcdmO1BCs1QrqkMdwDd0k5Q6MYQ5O0Gy+2K0F+p65mvYTX8w2rUTpiOHouNOasD7tqw3kYKP4eIH2bcQdm6Mwdgkse98RGYPUAvyirl/NIfRojFgUe8LzRyraWzHoBgJsvTE3GA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715154184; c=relaxed/simple; bh=k8QWr7Ce151M14jHiuPdpQHPaGdK/slKGX2a8ui9kaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tHM2BwYzYrVZVfnpDnuh+z1JEi5EqBi4elJ3tlbhuhm/5Woq+Y0/uphYKYqd3O0LfpSueZ45RiAGp1qk8rOcjK5HUZ7Ub2Xzm6QM7POIVcnbgfzyjn6moTLZsIjRd3qsMzuQgJPffuBpu3ErjCDXf0Ep2pHkxox6MlYLlFZi86c= 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=NLynwZUY; arc=none smtp.client-ip=209.85.215.175 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 Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5c229dabbb6so2529975a12.0 for ; Wed, 08 May 2024 00:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715154182; x=1715758982; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hvvjJAe8l8tDTfecPvMLnwPB1eap8xtvETRDKvyj4SM=; b=NLynwZUYFJESBQ16y+8nyJagJoMLKS90eaX099lJBGiQygndJAxb6CBLLJi6k37smi CCOFZiBr4mtPnSAhxjVEai3Nw7zTYERJGWO40WGnyDn42p1sPqAh7Gc/1qn+NbXDglUF 2fOmf5dnGroFENk+KcEGzW7VVhW+K7RJyVBgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715154182; x=1715758982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hvvjJAe8l8tDTfecPvMLnwPB1eap8xtvETRDKvyj4SM=; b=WgLTDKDOID3Sq9nuklCsJFgGLec+GY3ms4H+csWnCFAoPzOGH5WP+POvHqf8CwLBvg E48g+xEOTXl9Dm1lUNWJY8YB6pWywTO5IPkV+5eB2QJFVU7tOsp4cx4TLWS1v6g/qQca jsPorSQlSar+XyiISIc8CNsHnzBpz6fmU/fPM2+AU6aWkZrFNUAc04bBp7eTUram7HYv wqnVm1WMT9GswXgmrsSleLFSsnDonlv+jaC7racFWQ7z2Q6rojreJT92m6mC2EC9RBfT BYIa4E55NFYqHe89L6Dqv2Q+NCEeLUzJdsGfbTzy9fSBdMSJmOeF61VI01IYSxKVk1hL UY2w== X-Gm-Message-State: AOJu0Yx92pSDBZD3aI/QMA87l/gpoNoBR3JXZ8bhU18BVOO1CS3uloHB eODCstp9TDTeXJLyZefUxh9TTUmVSU4PqNLksG9VZ5Phmo7GDFlonu2UkeJhbpME3/WHb9QgMfg = X-Received: by 2002:a17:90b:1046:b0:2a7:600e:ce0 with SMTP id 98e67ed59e1d1-2b616bfdb97mr1754458a91.42.1715154182204; Wed, 08 May 2024 00:43:02 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:ad4d:5f6c:6699:2da4]) by smtp.gmail.com with ESMTPSA id l5-20020a17090aec0500b002b328adaa40sm780011pjy.17.2024.05.08.00.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:43:01 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv3 11/19] zram: extend comp_algorithm attr write handling Date: Wed, 8 May 2024 16:42:04 +0900 Message-ID: <20240508074223.652784-12-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240508074223.652784-1-senozhatsky@chromium.org> References: <20240508074223.652784-1-senozhatsky@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Previously comp_algorithm device attr would accept only algorithm name param, however in order to enabled comp configuration we need to extend comp_algorithm_store() with param=value support. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 6c36cd349431..bd8433363cbe 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1028,9 +1028,33 @@ static ssize_t comp_algorithm_store(struct device *dev, size_t len) { struct zram *zram = dev_to_zram(dev); + char *args, *param, *val; + char *alg = NULL; int ret; - ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, buf); + args = skip_spaces(buf); + while (*args) { + args = next_arg(args, ¶m, &val); + + /* + * We need to support 'param' without value, which is an + * old format for this attr (algorithm name only). + */ + if (!val || !*val) { + alg = param; + continue; + } + + if (!strcmp(param, "algo")) { + alg = val; + continue; + } + } + + if (!alg) + return -EINVAL; + + ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, alg); return ret ? ret : len; } -- 2.45.0.rc1.225.g2a3ae87e7f-goog