Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1238287lqh; Mon, 6 May 2024 01:01:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUer4RnKkBCAvyk4TlnEETKhvZD2ToNlh6Kg+If8Z3kE0nKKQXZIiqWY4jWeppBDqYP+da1hjOX79qJn5mYVWd30eLqKneBRvZkYe7X5w== X-Google-Smtp-Source: AGHT+IGjyYuQjiqFq+s1GGWus/Gi+8O9UPs/1yixJyBV4+K96FA7U4Ju8Cv3wewW5keo7HfiwDMK X-Received: by 2002:a05:620a:5d8c:b0:792:8ec4:74a0 with SMTP id xx12-20020a05620a5d8c00b007928ec474a0mr5326399qkn.41.1714982468347; Mon, 06 May 2024 01:01:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714982468; cv=pass; d=google.com; s=arc-20160816; b=RjPB/bN1KjESynJZsEXNfSoeBzv6mjQ/wj//fYXvGRjh6Vn06sQbNCKl7mvJt/bxXk 548lDkyAFgPtuFAKNrn1jymV0GJZNLPqGyYbZ1ENoEHYFc6An2TXTAPFFi2d2zsGbgx/ MSS88FoYVEtdqJcoZ6s/ue3MTjTfPljzJa3gj5zMQpFoQLL3j42fhv4IPHUzamvhU59v 06dYWylug3d6ZxyI8EGJUQw1OUwjNoF/QdDbd+jg/raiP0+XXUMkrzOHkN8seYxvkDNM jiyJzBMh+AomFuvkjtXPyEhcEdir8rCFuFUREDKYVF6gFb2jagA99B4YQBvloU8fhA4d xXyw== 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=0eIYrOQ3BkMXJCk6zuaDE2ECawMW63bMTlaOVOjCrZU=; fh=UKstJvjqAQ3P/Vkvglih02Z8FmmRnlaJbql9clnU9dw=; b=P43btmCVcFykXm7DRW/P02ul7G+n+B542G/MX/QtdEoyDManWUVCsk98v6g+BajgnZ ViQkq8nzSHkajWx0pW6cioUzJVqUUbVRJbu0IWGN4xQ9eINAziFWLBbSPKBSA/5X6Htt HS3nE94qZVMJ6zeWjkYwg8sFbFyglxYCFSPt1U3002k3r3AFGjHqTwVi4UXHR9RDnsbp mr+7dBZu0iiwWc9eMFUAN9ub5plTpCaSLH8D1rBmTfli9MlzMGxGAyn5ACdzu1+s18AN EbrKJA6ilAHtuipIQYQ6ObOwz4T8iJslrA+1NpSlbitg3zoLYkXhKCqYlKNlIXedqSj5 GynA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KgTsJZdP; 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-169452-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169452-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 t27-20020a05620a0b1b00b0079293c706d1si2734039qkg.543.2024.05.06.01.01.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 01:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169452-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=KgTsJZdP; 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-169452-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169452-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 19FA81C214B6 for ; Mon, 6 May 2024 08:01:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6B8F1411ED; Mon, 6 May 2024 07:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KgTsJZdP" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.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 9D8B2142E76 for ; Mon, 6 May 2024 07:59:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982349; cv=none; b=hKe77uPYgPf9BWUVunaViuRBXQwNWuQlNBO5dCpX+tXsY73qTJKqTOPOeUAN879GbWt98pC1OmnC1voRhsDPaWtnKVEup2j71bw35qSghXgdI64f1HEMgbfGJk6R+Sxh/tQ4Gfd7OQEowpw71T20Ac0g+Vw8bmQt4hzVui2/95k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982349; c=relaxed/simple; bh=fkmGnp5H4sYk5AcEucbfVYS4PjNz7ma3EYQ0ecKZnDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g1pIKuS8eKOcaZYezOUe+ZZ2B1BE84XvarMNMbIeeIaBy17mK4SHZW8NIdsUaQTa8TR2+lq4BdaPv+mvshGoTQXMDVqLiQAfOAK3QfkXYJ1qC9L5ZGOWjyLBDtatAUxvyMbQJguHXRBE2PlFScvRDGERJ/EzFQ/iVnaIFi3Y6ww= 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=KgTsJZdP; arc=none smtp.client-ip=209.85.214.181 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-pl1-f181.google.com with SMTP id d9443c01a7336-1ec4b2400b6so11067965ad.3 for ; Mon, 06 May 2024 00:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714982347; x=1715587147; 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=0eIYrOQ3BkMXJCk6zuaDE2ECawMW63bMTlaOVOjCrZU=; b=KgTsJZdPOGCHNeKMRY/ASsztQuJA1aHxZewpKIpaBMEVQZ1Hm6lxgvK24JJZrSxOIW L0pEPc6ulksi6lrBLU49vCe2e87GK9ZggRWa6c1S/Xqmnjzec9ZcqKHx5vFUa0/mgRoG 9rJN4wsRT/yU2pVjGYU//JDekkVQ2yNxVQLik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714982347; x=1715587147; 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=0eIYrOQ3BkMXJCk6zuaDE2ECawMW63bMTlaOVOjCrZU=; b=UBJnsAw4+HHzEIPO/bGjEw8K9i0fH3FFm3QAgEiUM0XwSzgjW9M6IuHeP0jlf1t6IF LXQH1MRRRj2/uk1+rqGtM/imRzZHZH8OGSrOADMkCgs0HY4ZeAeIY7ImwGh8Fq6wka3n xASMMHGixsNFWNOrDa/bdpGlOcfcpeFHmS25xyopE72cQmcjzUPpbvetQhAf95eK+hUJ e3tSE3KiqgKaF5LDMWVT9VVK0XbrtCQbePLNbHR0U8a532rKSwHpQ9JU1QGbN2A0xT6H hDgUmj90kcVSHOBft4ChQ4BUW2ASoKLeiizQk4m8k5YdYO2byT/Z2dApv8hg6gHSg4NK rl0A== X-Gm-Message-State: AOJu0YxO0eYGovIoys4ESMuKg0VGHUR3831VwK6tPV74XeewbKLj1+TV lDWvOng8aZmB3hr4vlo6VOU8/NVQHlOiYbRcIvgEsxnEGtZ0p/l0DUDGgP5qaQ== X-Received: by 2002:a17:902:ea06:b0:1ec:28e4:691f with SMTP id s6-20020a170902ea0600b001ec28e4691fmr10804968plg.63.1714982346998; Mon, 06 May 2024 00:59:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 00:59:06 -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 09/17] zram: check that backends array has at least one backend Date: Mon, 6 May 2024 16:58:22 +0900 Message-ID: <20240506075834.302472-10-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 Make sure that backends array has anything apart from the sentinel NULL value. We also select LZO_BACKEND if none backends were selected. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/Kconfig | 19 +++++++++++++------ drivers/block/zram/zcomp.c | 8 ++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 1e0e7e5910b8..6aea609b795c 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -14,12 +14,6 @@ config ZRAM See Documentation/admin-guide/blockdev/zram.rst for more information. -config ZRAM_BACKEND_LZO - bool "lzo and lzo-rle compression support" - depends on ZRAM - select LZO_COMPRESS - select LZO_DECOMPRESS - config ZRAM_BACKEND_LZ4 bool "lz4 compression support" depends on ZRAM @@ -50,6 +44,19 @@ config ZRAM_BACKEND_842 select 842_COMPRESS select 842_DECOMPRESS +config ZRAM_BACKEND_FORCE_LZO + depends on ZRAM + def_bool !ZRAM_BACKEND_LZ4 && !ZRAM_BACKEND_LZ4HC && \ + !ZRAM_BACKEND_ZSTD && !ZRAM_BACKEND_DEFLATE && \ + !ZRAM_BACKEND_842 + +config ZRAM_BACKEND_LZO + bool "lzo and lzo-rle compression support" if !ZRAM_BACKEND_FORCE_LZO + depends on ZRAM + default ZRAM_BACKEND_FORCE_LZO + select LZO_COMPRESS + select LZO_DECOMPRESS + choice prompt "Default zram compressor" default ZRAM_DEF_COMP_LZORLE diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c index 2a38126f4da3..d49791f724e9 100644 --- a/drivers/block/zram/zcomp.c +++ b/drivers/block/zram/zcomp.c @@ -209,6 +209,14 @@ struct zcomp *zcomp_create(const char *alg) struct zcomp *comp; int error; + /* + * The backends array has a sentinel NULL value, so the minimum + * size is 1. In order to be valid the array, apart from the + * sentinel NULL element, should have at least one compression + * backend selected. + */ + BUILD_BUG_ON(ARRAY_SIZE(backends) <= 1); + comp = kzalloc(sizeof(struct zcomp), GFP_KERNEL); if (!comp) return ERR_PTR(-ENOMEM); -- 2.45.0.rc1.225.g2a3ae87e7f-goog