Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1655361lqm; Fri, 3 May 2024 02:21:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXy8fU4t+t0gziXupaERgZv4DI3/4dJxgxeO89eD+lfqqWSoYljuomW7uBW/a9x1S4uJgwhMFJUrFtIbxjn0WusxH2En4x2R+3xf8KEiQ== X-Google-Smtp-Source: AGHT+IEB+x8V6AAaX5sZHK1q8FE9j1StM+zoE2dtNUb1WFfKCOmS+dpVCAtnyRMFsU45FOFMv4Vv X-Received: by 2002:a25:af4a:0:b0:de0:e383:3c17 with SMTP id c10-20020a25af4a000000b00de0e3833c17mr2235677ybj.34.1714728087565; Fri, 03 May 2024 02:21:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714728087; cv=pass; d=google.com; s=arc-20160816; b=rYVAsO4qQgaq4bW3OAmY4T+Tn8tZ9vhO8OPRxfa4y46wQ/l/XFDx2H3bo+Wxjaib22 yZX031BdQA4R3piy9AKa8sMA9rs9p9pqu7yyb7mOW3foLWOnc0RtQTXzcyY9a1DtfVNG 0vgqg1xIPy/H+1ihVbTM0C4hD1QcevCv/eX5Gp4M+G4Gn8Psb+rYkgmYibCDhXz0+3M5 gBcJzJrzzbFqAA52LeuK3bGvlcjJnemtqEi4Jkd8/Ai+b4QqP6hc+jOA2hS+htDlqlM3 WJgcIaLecgNA8ANF7vCBWoEUStZOKqE948VmdEMcZVUBN82z1uiXc6FUJcJJ2z995xJH Ijrw== 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=LyUT/WjmwJO38sOevWPcOf1U89bclZRxz8AvO3qt5XF4ujAg721+Wd1QwLs4WU5xHn mXN+q2veDEulDEtXf2OaN4qJvE1vEtgQzrN3wGsamT14+4BivEUKwKSJmFATv89yD00Z 1mURcshVvFIoyhCjRsOqVQ/uZmmwPZP9soAXhwlCsgku5AbP1zSN+3kZ8JO1XJih8hhR rWvB1XAsDzvThWuiMMshxOG8YzPWgbHZXXX0NYHSQZ0DRqLp7M3dssZwMkVYtUl74eUk J4RfJTfuo8JSBo9AOfQql2DGNinO2mHN5UA9eu95qRyDi+SZVp6+DIPPkXDO2o+GMhHw VXVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FguGQgNS; 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-167450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167450-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. [147.75.199.223]) by mx.google.com with ESMTPS id eh22-20020a05622a579600b00439da178278si2594076qtb.741.2024.05.03.02.21.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FguGQgNS; 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-167450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167450-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 4C80A1C21A68 for ; Fri, 3 May 2024 09:21:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C234153581; Fri, 3 May 2024 09:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FguGQgNS" Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 BD88515351E for ; Fri, 3 May 2024 09:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727941; cv=none; b=nFBnr2ywL6zMkkJcxqUVLx7WwHVb/UigFJ0sGVL17EpK4eelvecpqPDaqRlV+HIv0Z5/7F9B4tGjTwvxNh/wqd9d79HSKGQ2raYT1SWCf8BRH/6E0kCKW67WH+AxLib27ZzFJ8tuKUxVg77DBNP8J9lmhyjrzmOdNEPcK7ebquI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727941; c=relaxed/simple; bh=k8QWr7Ce151M14jHiuPdpQHPaGdK/slKGX2a8ui9kaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VhnHHpJFYLr0jRdoiCp8NPcvry1csXF9VL4uw4Y1kCFjAopkfh1OUqu4x5UddLrtXpTFIukuhu6rrUUkefPm8cZUpyG1zQ4y0HLlcCoiAxhL50aOhnh30XRX0els7B8LxEUjPRwNA2eWMMrrgguKdJOL9Co+XpdY7Iwou04d7EM= 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=FguGQgNS; arc=none smtp.client-ip=209.85.210.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-pf1-f175.google.com with SMTP id d2e1a72fcca58-6edb76d83d0so7800493b3a.0 for ; Fri, 03 May 2024 02:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714727939; x=1715332739; 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=FguGQgNSAtCarhd36ZQr7a1hEp+HWlA/2Oijdb2XB/XFtCmYVeije1y//w+op7UCEq uqW/haLV9rHs9Y19iM72DI3EPoai0qBvikOJpHDN7QjFSD6hRxAvqaQvky3QVY9rGUsA 9Hn4/meQRgKsFJp9G0to/nYGva34XuIHRgCWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714727939; x=1715332739; 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=HLgxCEbEaxapLq2PDeK3SXfKeN7N2X13PEZKME81T6UQBleSHX3p6G0X6vm/+QKjdt EAn9q1VtNn7kmNLe062erZGvnoBQ3w/i9nlnFZRGO4DbG0CgoCVa3lae3OkG7Inn75Fx ecTPChmw0Wh2s6y42mzGVx1UFuamXhq4jCXCWC6l4Zc5C4Oz7p4448nleESp7ytIKQpj bsj7GS20UNlRSe6+F1yQyCDSF0lSiM8PqsfXxEiuSBiOVwaK+iK7FvcASrUvowMWdORg c0DZ62v/NcR6mTvkuoH8kCetu9iZV9NJXyAKSzeHHcRMCSr9ohtaHJrcnV4bRjc7iDt4 8ZKQ== X-Gm-Message-State: AOJu0YzMV4j3HNiRodLV4oKzBNXrD4bJ3WIMmDGAlonmGved3PvbeOMw jSA+LiERfWPHWlhvZ5n7/JaP11koh7F6GtfYwHjp9XM2PedcoIOJlh7unFdBZH8k2BSBtAUwFG8 = X-Received: by 2002:a05:6a00:140f:b0:6ed:4288:650a with SMTP id l15-20020a056a00140f00b006ed4288650amr1850681pfu.19.1714727939079; Fri, 03 May 2024 02:18:59 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:dc60:24a3:e365:f27c]) by smtp.gmail.com with ESMTPSA id j6-20020aa78d06000000b006ecec1f4b08sm2621938pfe.118.2024.05.03.02.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:18:58 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH 10/14] zram: extend comp_algorithm attr write handling Date: Fri, 3 May 2024 18:17:35 +0900 Message-ID: <20240503091823.3616962-11-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240503091823.3616962-1-senozhatsky@chromium.org> References: <20240503091823.3616962-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