Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2961270pxb; Tue, 13 Apr 2021 14:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvLgrQKvbkzgAa06LuWDcKbqBjFcnP1ocJpOIdN79qjpbsy6jstZRa5kA3c6iEaXSP6DXr X-Received: by 2002:a05:6402:1056:: with SMTP id e22mr22008574edu.279.1618350820111; Tue, 13 Apr 2021 14:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618350820; cv=none; d=google.com; s=arc-20160816; b=t/CJY2VTL6vCw0UpvDsrSDI0rSTfdQPHJXKC2YhoOMso+k++wOnSMF9FYHcuLlcFtc 2KrTfg7QDLkd4YHFEsBSGAIRlzTvZ8qG/O7OhCrQk6C+XqQZMQfbMH5IavAZilz8wmW0 W6YyJJce/e0/6ROBkdka+5nI+CUgmAu5/usiWfTjDzWd8RJ8rmZtuEAlns2f7GxS8bDI Rl6pc7/qx5m0tw6AJOuynbi2UV7cHDGEfXfjyWGgzxA8aQSKBwovz9bvnvm0tHYA0Ghy 9OFfFQQTAfHuSPKd7h9YxGUB6Hp8C03Gulf9cSlRSOPy7oXJVxJSIsW8wRX64xyt+NBK VzQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R2gmFdFspE+tF0exraA8LE3+lMa5ZYBq+Y6lFDBpWJk=; b=phfJ/pkm6c4O/IeIUPBVvWuI0WdNhxliDcFvq+lSq6myJVNIyeS8e7la+m+9RNCmI0 EcMx+7UnbtctWK3ranC3NZnASDhHEsoeqUQzXfhf6cSwt49oqi2rOYh2euWIX0qfob2Y kEClXDPWH2xh2DnkZFdiffDCO2D7ySLYODQgwqZJvSRG+X7nHwnnrQT4gB7GWpSYUK1B mCnL9eXf5dPCA+a2WXOgcHcA4EmbftI2/OI1R0Ky5zYz3aBpwC80ecAqNGC5eTPSoD1e zqWFm2+fyabaEd6xvEDsR/z0AogHB8hinxOFV1hnYQ/8n+dfkmhXMQYYae0ZE4D5IRO9 J4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="BeKxJ/3H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si10857975edv.345.2021.04.13.14.53.17; Tue, 13 Apr 2021 14:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="BeKxJ/3H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346917AbhDMQyO (ORCPT + 99 others); Tue, 13 Apr 2021 12:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232017AbhDMQyM (ORCPT ); Tue, 13 Apr 2021 12:54:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5437C061574; Tue, 13 Apr 2021 09:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=R2gmFdFspE+tF0exraA8LE3+lMa5ZYBq+Y6lFDBpWJk=; b=BeKxJ/3HQ3Iwt6gpSmW4wfxwRA g2hm1E3fLyZhQkV+C/W4Ymq6QmoN0ab+XNeBS2iCUtvec8H9PU0fY8Xg20xgfgR+Z1s7DEF/oitkm cv8gy2B0CRzsSqqRVZSqJPuE60FaYwLoh5xYTQvfAlIhORLlXUohfH53aw5bgxQlw3vPl5Ziusnaz 33Z31gOjkz1biB3DpKU03+iGYiDwX8jRxfkZks7KF1bgyF+5E8/1IP59t+wPz9lwwXrGZtGLUg1J1 f1SXuD8mh8SuStEmVKRLUZvXllCF5xD4D4jWCYSH/8tsfnCWX9fVvqpyLkitFIU0f8JkxXSLbPM6o GHpbYXXA==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lWMHp-0060VT-Uq; Tue, 13 Apr 2021 16:53:21 +0000 Date: Tue, 13 Apr 2021 17:53:13 +0100 From: Christoph Hellwig To: "Darrick J. Wong" Cc: Christoph Hellwig , "Gustavo A. R. Silva" , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v4][next] xfs: Replace one-element arrays with flexible-array members Message-ID: <20210413165313.GA1430582@infradead.org> References: <20210412135611.GA183224@embeddedor> <20210412152906.GA1075717@infradead.org> <20210412154808.GA1670408@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210412154808.GA1670408@magnolia> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 08:48:08AM -0700, Darrick J. Wong wrote: > A couple of revisions ago I specifically asked Gustavo to create these > 'silly' sizeof helpers to clean up... > > > > - (sizeof(struct xfs_efd_log_item) + > > > - (XFS_EFD_MAX_FAST_EXTENTS - 1) * > > > - sizeof(struct xfs_extent)), > > > - 0, 0, NULL); > > > + struct_size((struct xfs_efd_log_item *)0, > > > + efd_format.efd_extents, > > > + XFS_EFD_MAX_FAST_EXTENTS), > > ...these even uglier multiline statements. I was also going to ask for > these kmem cache users to get cleaned up. I'd much rather look at: > > xfs_efi_zone = kmem_cache_create("xfs_efi_item", > sizeof_xfs_efi(XFS_EFI_MAX_FAST_EXTENTS), 0); > if (!xfs_efi_zone) > goto the_drop_zone; > > even if it means another static inline. Which doesn't really work with struct_size or rather leads to a mess like the above as struct_size really wants a variable and not just a type. Making it really nasty for both allocations and creating slab caches. I tried to find a workaround for that, but that makes the compiler unhappy based its inlining heuristics. Anyway, a lot of the helpers are pretty silly as they duplicate stuff without cleaning up the underlying mess. I tried to sort much of this out here, still WIP: http://git.infradead.org/users/hch/xfs.git/shortlog/refs/heads/xfs-array-size