From mboxrd@z Thu Jan 1 00:00:00 1970 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 66262354AE6 for ; Wed, 17 Dec 2025 17:46:06 +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=1765993568; cv=none; b=H60Yszj6Rinndc3AolbJa3FgJ2SgTptEoF/LL+H/39AYdYcb+3LL7fCC+ez0X6dLUNU8pQrLSHpOGOdAtYjxfo4s7bCCwpw0CjVAIxQkt1bn8WLaTXxc2kKAPWtlyQwi8qUoULj/bboi/tANfBSdjfxywHmn4kLQTbTl7XhWBJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765993568; c=relaxed/simple; bh=w+7TCzD6jrFmuYykyBWftPJu06x8kYZBA9ocidsd7v4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=B/Ht/FNKW+EMxep1zQAaNrgLRzWkWZjKLxgePq+8wGzJIlzyKt2Kg+na5TnrMIP4EnStuUCiZx8Kb4G/ypI8fiVcr1/EQjedpDhS8PZNxk9ZLzh0Ie0hsehOw6sv9240un9unIIvIX+LnetBKMoSFnFsI0W7LSx9hY20PUAaKRw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZBodz3Lf; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZBodz3Lf" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-29e0753e5d8so835ad.1 for ; Wed, 17 Dec 2025 09:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765993565; x=1766598365; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=k/0mi21u8KukH3RghJttpiMnNs4vxDW9KG6P0eqeKDA=; b=ZBodz3LfvJYIvzwc1ci/KBomEteGqLYtviBhQHMFe/4EmFQODFEwC/xLO3JmGGi0O8 y50k4NrhHLfs5pgtTYllqMlqDGRLR+ZqMnlUu/H+T99k//OsYwRyXslrS1Gfnuu/YJOX gyTq89prweewSQ4v+sLUrspAzHXIzYJr2l1M2mFGTrXarVi3SV4GubRvJHv7ZRQBpz32 QgCjmqTpcXhUYK9NAx/mQGQkN5aWX7RXS6flkjo8psE24g5FYq7VVxwYpV7f8MSf23Dn Err+kWF0q3Kv+WSFix1dSMc6cTCUOHYG1dSwWge+dBX7LNS+K4dK1CSwOkgZQXPOdabV FWSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765993565; x=1766598365; h=in-reply-to:content-disposition: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; bh=k/0mi21u8KukH3RghJttpiMnNs4vxDW9KG6P0eqeKDA=; b=unEVi6ck8iS5iDjZ84FGQ9up+pJ8HnQIOnLNkcVQu7LcvXj3TjE9hPpAxu1ORKKL2/ giS63FxPsVdkIzAR5FH7SxzuWmrLgNYkOhSW1JV53tjjH3Vg3fZiwhxNEgFieZGDP7Ih 4F+vpsVnDnORoAlkLwy4VLXb74W8KPjzzDKd4+NEYFkAuhsVvYlc3B4WnT0x8fdGv1tm zRLc6y67OvwlO6owHcZBHkuipMgzGVYG3VlDyEXlw5/DfKkhXYQOwoCoEstummXAHBy4 XFRdVJWmv7b17eH6ZYC00SgdF6CydlA1zgPqyKMwdvXmW9SJH8aRqLfF7H5c+bgVP46P GDpg== X-Forwarded-Encrypted: i=1; AJvYcCUGVFd5knYfueTr0d9FjFPnUtUOKmIJSCN9RrwincFdju5YTz9cmxG3sUntCrjnkK0+9Ph6uGbXHBoe/eM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6JlkeWG5JlGXh9x3LrqZvJgM9mwSgbXvLVjnO9zbPKhRGlzGd dE7ltrA6V1Q9djBWkLZnZQYdmul5fPeV46Fkpft1V/5W5JSGMZqfxyqRc7hGlbFIXg== X-Gm-Gg: AY/fxX4i9BxZUw8gELHvLMtB8SiEMDRlhhxzIbXKMNLjWGBryj+7C1xiDlk7t1tXSOL eBBzGIElAKAVuwHUtU5M4x92mqOLKHG+LlCK6MD4l7P24iAr/r+BmxEPYEBVin9esByKYZRadQH p93dHBDFfgg0/Qwtm+o6FgOlFHUgKjA4J+UCTxkQBOSaV74yCTpEMsOwDL+ucKAJfOOfFEGKYIo NggELn6aoRhVNCjikdbFc8hA+v5ZlcoY//pUx/+z209W8hbuWxs3+p0Myn49rF5Ft5D84T9yufe ssbpT6RXIPujmn2WXPAUtwjIywPp0ICjD09gXCZlZO01ntxlDIhRhj9eD0TV1dzzChoYT3LnbkC yzp0ggN4Ldb1x74AszBXTXfMxahehQWwztCct0egvJks3xAlhshe5qboHYZYSSRhvtIZwp7XOJV qHG44+zy+PtiZCsuz5xmB+QgwDRova1TRYPe+Taie2RCy/uykhZVmQn8w= X-Google-Smtp-Source: AGHT+IG3OYKh9CRi8LqFdH304dtk5qxdcCH2kwSFCEJJEMqeMcUssWHrkH4WGAt2skKXNggFtsmuBA== X-Received: by 2002:a17:902:d583:b0:297:fe6f:a26e with SMTP id d9443c01a7336-2a15f2bb3ddmr3357575ad.14.1765993565039; Wed, 17 Dec 2025 09:46:05 -0800 (PST) Received: from google.com (99.181.125.34.bc.googleusercontent.com. [34.125.181.99]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2ccdc6293sm948085ad.34.2025.12.17.09.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 09:46:04 -0800 (PST) Date: Wed, 17 Dec 2025 17:45:59 +0000 From: Sami Tolvanen To: Eric Biggers Cc: dm-devel@lists.linux.dev, Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Benjamin Marzinski , Eran Messeri , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/7] dm-verity: make dm_verity_fec_io::bufs variable-length Message-ID: <20251217174559.GB2944334@google.com> References: <20251216230614.51779-1-ebiggers@kernel.org> <20251216230614.51779-3-ebiggers@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20251216230614.51779-3-ebiggers@kernel.org> On Tue, Dec 16, 2025 at 03:06:09PM -0800, Eric Biggers wrote: > When correcting a data block, the FEC code performs optimally when it > has enough buffers to hold all the needed RS blocks. That number of > buffers is '1 << (v->data_dev_block_bits - DM_VERITY_FEC_BUF_RS_BITS)'. > > However, since v->data_dev_block_bits isn't a compile-time constant, the > code actually used PAGE_SHIFT instead. > > With the traditional PAGE_SIZE == data_block_size == 4096, this was > fine. However, when PAGE_SIZE > data_block_size, this wastes space. > E.g., with data_block_size == 4096 && PAGE_SIZE == 16384, struct > dm_verity_fec_io is 9240 bytes, when in fact only 3096 bytes are needed. > > Fix this by making dm_verity_fec_io::bufs a variable-length array. > > This makes the macros DM_VERITY_FEC_BUF_MAX and > fec_for_each_extra_buffer() no longer apply, so remove them. Also > remove the related macro fec_for_each_prealloc_buffer(), since > DM_VERITY_FEC_BUF_PREALLOC is fixed at 1 and was already assumed to be 1 > (considering that mempool_alloc() shouldn't be called in a loop). > [..] > static struct dm_verity_fec_io *fec_alloc_and_init_io(struct dm_verity *v) > { > + const unsigned int max_nbufs = fec_max_nbufs(v); > struct dm_verity_fec *f = v->fec; > struct dm_verity_fec_io *fio; > unsigned int n; > > fio = mempool_alloc(&f->fio_pool, GFP_NOIO); > fio->rs = mempool_alloc(&f->rs_pool, GFP_NOIO); > > - memset(fio->bufs, 0, sizeof(fio->bufs)); > - > - fec_for_each_prealloc_buffer(n) > - fio->bufs[n] = mempool_alloc(&f->prealloc_pool, GFP_NOIO); > + static_assert(DM_VERITY_FEC_BUF_PREALLOC == 1); > + fio->bufs[0] = mempool_alloc(&f->prealloc_pool, GFP_NOIO); Can we just remove DM_VERITY_FEC_BUF_PREALLOC completely instead? Sami