Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1238525lqh; Mon, 6 May 2024 01:01:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4QclZ1ZS6KW/R5DbrgXYaVw5Qmqy+sF4mSY9sDLXEnkKW7owExa5dldXH+upX9rmr6AQ2v6yesg9M7UiHvk4IgRAjhVqgc8wxL2xZPQ== X-Google-Smtp-Source: AGHT+IF14OZQHmkK03wBrz8uQSpe2JrDLm7WsTA5g5Z1abokKJKOKS7hwkg30ecP+ZXykaJC1ne8 X-Received: by 2002:a05:6808:2212:b0:3c7:a5f:8d2 with SMTP id bd18-20020a056808221200b003c70a5f08d2mr13511333oib.45.1714982494996; Mon, 06 May 2024 01:01:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714982494; cv=pass; d=google.com; s=arc-20160816; b=NF3y1eufLuTeTC9W71dXq63q3Yz3G59MUUWSikSVrAZrl4IwS5XUI6D1D4qZEQxh2X xJ3jzalfQ5QEAaiMAgS9gVDapum2UTU+Pq52x0B4RUT6xSTJpE3msG+Bcn6osfomKCWB MQS2JEOBvEn8qhked/960Dx58osV/2w/yum1QU9LG8O3+Mc+12+2i4qGsuYeaTQkCMIM nSTLkTvuJy2NFzOa17FeFXrTQ8KcsVJ5wYfTb9SXLpeD1HnDmB8fn0I4/8qi1gOiI8Nr 1KyNGpLU1oq8VECcONTPo8UZQUM4QBDgp48NSwbEIHiogFlxVgKZ1QGvMxbFtFlnRzIA 5h0g== 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=UxYUAZ9UI6BUnFhkGi0Jto/DUN+zglZjqoVNRKTXH3pJQuWJXcmCRmeyrUSNlkjXB7 X4f3I1LZSSUJAW3eTJkB6/fMVChOCSXSWuHNCWLFgxVXB+tr84/enRaDJpizwsERo1x7 dRRqSvINWV65taNtGVZ8MTYq9b9i8/D5VQRmZ0gsSJZAtn8NlKBkvLFvG3hh902edFdW c5sEVlbuZ2fjwMR7PTAS7lP4hthqW26hjXw20IZN7qrymR4p5TBI7m2uDqLeIK1T/Ouz JMRRvjLkBew+SOIZMjApkhSOfhwuj5lfNfzyGA+4bCx7aI5ThuP5aAnmkCE8F0B33l7H uqGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=awEsttkZ; 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-169454-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169454-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 ge5-20020a05621427c500b006a0cc143370si8745282qvb.206.2024.05.06.01.01.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 01:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169454-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=awEsttkZ; 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-169454-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169454-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 B4E931C2147C for ; Mon, 6 May 2024 08:01:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6934143883; Mon, 6 May 2024 07:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="awEsttkZ" Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 D4B96143871 for ; Mon, 6 May 2024 07:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982354; cv=none; b=CJnoDmzBLi45wz0Rlm1Nd482JoS7/nfImzszuAYOXlsG4BSE4p9OL/m53xPTba1FqH5yBS4TeLuaLr1j58xtEI/yEtPzibhxZ9aJOkkG2UbtslR1dxOJuraJ0eGWvj/P/968Qh+hXlrEklroybEx78Fo2c592Ku/1caG/VQtaHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982354; c=relaxed/simple; bh=k8QWr7Ce151M14jHiuPdpQHPaGdK/slKGX2a8ui9kaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+IHgGO6Ob0O5yGu1NgULNlJgSdTkx0yZPESQqmVGPA/h6EzEsRxbIP88JqN3em/ywULgMg8/qhkouBiXnclC6DEQ+VeeVcM9avI8J/q2zOJg2fhTWF6nIYuqW2C4xBs/bOgPXuT4gBFUvA+jDOIpNdSU9MFdbwKkRkesokeJ/k= 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=awEsttkZ; arc=none smtp.client-ip=209.85.210.170 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-f170.google.com with SMTP id d2e1a72fcca58-6ed9fc77bbfso1119440b3a.1 for ; Mon, 06 May 2024 00:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714982352; x=1715587152; 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=awEsttkZoYVD4mYwcv21cz0wNIF0xRxm4gTzCc0eVulvJfhIu1DMhfxjOGwyaibI/y 8kQ4mYg2j2ttMlDSLrJRlDK6Txg5Er6dvndjOA20ozZfUoLofiEsxbxAspRnme/9PAOw g7Yj5gvyf159yaEVtbW1MCabr7vJSu1jSKAi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714982352; x=1715587152; 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=FtJO+d04zX7GCfhdhhYXIXxLMACZwfyIVX+n5LaNRyjMrpmKSuHVfHw9iWbMRxbdrp n08H/qOI44PSFTwfW0KXnuATRcavToMmZqfG5KarzaJjnUSoQCXsgyhiCKj3kU2miajI 07GBB1/EAoCBxKZ4rqW/7KkzAmzuuNbO+A32ZtIC11mU0UIIjyr4KQTOazvEhUB+DU8F qyxPiIxd2KT0TmNAXVaN9SZ80UQUmwpb3K37y1XS3IT7/uPdGDezohbay/ArYrSgDf3k S7cP1WYoSajv9/D8ukVF88enSUdgdfD/NDfxfKqhBupjkFmqpblbJDcfDbh0z1akJgAG LzNQ== X-Gm-Message-State: AOJu0Yz6hnMm8nSGgR4D7VTnUx/gB6yE00Q817Va+Fq3iuMRkX+f6h8H NEryx3UP+oEdQ9QDWEjfrbGgs1Pzv5EKApQTADOxReHAzw0KCRGn2EAwUeLJOg== X-Received: by 2002:a05:6a21:2d8c:b0:1ad:9413:d5bd with SMTP id ty12-20020a056a212d8c00b001ad9413d5bdmr11397267pzb.9.1714982351980; Mon, 06 May 2024 00:59:11 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:4e24:10c3:4b65:e126]) by smtp.gmail.com with ESMTPSA id h6-20020a170902f54600b001ec64b128dasm7633772plf.129.2024.05.06.00.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 00:59:11 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 11/17] zram: extend comp_algorithm attr write handling Date: Mon, 6 May 2024 16:58:24 +0900 Message-ID: <20240506075834.302472-12-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240506075834.302472-1-senozhatsky@chromium.org> References: <20240506075834.302472-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