From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9372CCA47B for ; Fri, 10 Jun 2022 18:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347566AbiFJSG6 (ORCPT ); Fri, 10 Jun 2022 14:06:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350243AbiFJSGy (ORCPT ); Fri, 10 Jun 2022 14:06:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0252B5523D for ; Fri, 10 Jun 2022 11:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654884406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PMsjmdghjftZcHJYxe23lhIe8tlheZvEV884DJ3XaMQ=; b=Bd6aDVEb5xw1xN3qEtGxg71rwM8RFdalfsSga1kMQwcvssl7Hi2Hxuat49JKWFhTlvS9BJ PvEcKmhFtqEn1jfWKqPx0fNsVbBVKU8TyPYs4saYgivGnFZuSsqZPma9ZWxQOm7TINx4GA 23ZEpFe4jLiW3mb9nu7UpTCdFWhCwfU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-RurBROcsP7ulDRyRjKQieg-1; Fri, 10 Jun 2022 14:06:40 -0400 X-MC-Unique: RurBROcsP7ulDRyRjKQieg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 055FD1C01B20; Fri, 10 Jun 2022 18:06:39 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A360018EA7; Fri, 10 Jun 2022 18:06:35 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <40676.1654807564@warthog.procyon.org.uk> To: Linus Torvalds Cc: dhowells@redhat.com, Jeff Layton , Kees Cook , Jonathan Corbet , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , Marc Dionne , Xiubo Li , Ilya Dryomov , Steve French , William Kucharski , "Matthew Wilcox (Oracle)" , Dave Chinner , "open list:DOCUMENTATION" , v9fs-developer@lists.sourceforge.net, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, CIFS , samba-technical@lists.samba.org, linux-fsdevel , linux-hardening@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH] netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <652127.1654884394.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 10 Jun 2022 19:06:34 +0100 Message-ID: <652128.1654884394@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org Linus Torvalds wrote: > Side note: I think this could have been done with an unnamed union as > = > struct my_inode { > union { > struct inode vfs_inode; > struct netfs_inode netfs_inode; > }; > [...] > = > instead, with the rule that 'netfs_inode' always starts with a 'struct i= node'. I'm slightly wary of that, lest struct netfs_inode gets randomised. I'm n= ot sure how likely that would be without netfs_inode getting explicitly marke= d. > But in a lot of cases you really could do so much better: you *have* a > "struct netfs_inode" to begin with, but you converted it to just > "struct inode *", and now you're converting it back. > = > Look at that AFS code, for example, where we have afs_vnode_cache() doin= g > = > return netfs_i_cookie(&vnode->netfs.inode); > = > and look how it *had* a netfs structure, and it was passing it to a > netfs function, but it explicitly passed the WRONG TYPE, so now we've > lost the type information and it is using that cast to fake it all > back. Yeah, I didn't look at those as they didn't cause warnings, but you're rig= ht - those should take struct netfs_inode pointers in some cases, rather than struct inode. Note that some functions, such as netfs_readpage() and netfs_readpages() d= o need to take struct inode pointers as I'm trying to get the VFS ops to jum= p into netfslib and get all the VM interface stuff out of the network filesystems - the idea being that the network filesystem will provide netf= slib primarily with two functions: do a read op and do a write op. I'll have a look at your patch in a bit. Thanks, David