Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5920285iob; Tue, 10 May 2022 06:45:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw+ftP5Aw9RfbymJxYXOmaJrPxR8gXiODoMFfpAIk/Tn23rrC4wDXqTF/qFztmQsWpXCCQ X-Received: by 2002:a05:6402:2753:b0:423:3895:7031 with SMTP id z19-20020a056402275300b0042338957031mr23492604edd.170.1652190326107; Tue, 10 May 2022 06:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652190326; cv=none; d=google.com; s=arc-20160816; b=QVZqOtXwR316OPjdikAxohsi5bC0Zkgw5xQrG8Du0PnAVZMItCMyC6+3RYvI+fEfZL 5Gz3NMc/st+BEEUXXoMP8R8UN0agWa48+JzGgvlfPMCttNWiCCaOfnALulW2t2RrbSfq GZuV5+M/G8aWH7citxuIbjXd4zYiyS8B6y8Bnix4MYrsiVu9wVNRE8cHitQqz/qX+QmW g5ZivqOmGC5KqizwZYORotVnnRf1xWPPWCi6dsDCmtH5SzeX0iiDVy/brjGAmNoNoffy nivnrZ9ztk5tqxow5FU4eNhCvS2Yn/50fdb6DWwLkm4SObm9HRLaU3yFRz6qB85ysqMN JAdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=D5QpDLvjaL/3sbIJjxhXvjRruga3nx8tizHPxU55AHk=; b=CM4FQXlplLOec4EfCgjyiJVP2MNEmei3rXkeQHeAuWuk8rTHP1NCdU4N2wNyCOOKuz tLYxt7ySDxatL5MpbV4RhKoORMAn4+IYsKB/L7QmVE0KOi6VN51jm++KyZzmFn4ixQ89 YrJBYO/+U/2fIACbgev7+ygoc3yK72TJnzlJ/ZZcobzQyn42oZmHcMl/NE7rqgeb1aam S3iB9LGqRTk0ICYERGF6ZtD0EPH+/PLTl+jaWkw4B6EcWXhp4x8TdMp4UDuB5hg82CnG nSve/6dPXZ1imWP9WV9KAGn3x1ECZXb3SqmGzSi0iJsJ5fVSPNGm8vpjXHmGDMjU8wsC sMjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixQltLsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot11-20020a170906cccb00b006df76385e6csi15865900ejb.780.2022.05.10.06.45.02; Tue, 10 May 2022 06:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixQltLsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240790AbiEJLRv (ORCPT + 99 others); Tue, 10 May 2022 07:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240778AbiEJLRn (ORCPT ); Tue, 10 May 2022 07:17:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EC8782A83F1 for ; Tue, 10 May 2022 04:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652181226; 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: in-reply-to:in-reply-to:references:references; bh=D5QpDLvjaL/3sbIJjxhXvjRruga3nx8tizHPxU55AHk=; b=ixQltLsdZZmVu/paZGHocU3fq8Is5QE3+LMx8kuG5136bWfyOfK09jU4MGbs8LbXYOxBWB w9Zseyogv6OoAUvsfmC+0UUQu0xFit0fuykPaPwTe/RpErsacj6OGbSiElUJwf/LiqPI25 J5r7pFe4SqbdDNBqQ8mmH78oiE/zw0I= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-cMhZcyPwMlS2jAsJZrmERA-1; Tue, 10 May 2022 07:13:44 -0400 X-MC-Unique: cMhZcyPwMlS2jAsJZrmERA-1 Received: by mail-wm1-f69.google.com with SMTP id z23-20020a05600c221700b003942fd37764so1117847wml.8 for ; Tue, 10 May 2022 04:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D5QpDLvjaL/3sbIJjxhXvjRruga3nx8tizHPxU55AHk=; b=3utz9gl86pzZg5/vLUqcJjp74gpdyyou4VcvjiTWMqXWwFvccI/kb0Iy4tzxcIFyVX 8Jx5RsuXr35aFb2nYS1wWiPsHsQ67A+zD8I5RWimMflZI3QGU0fnFo1aoSwFYLp0bxQ7 Ef/ItheZy80dG/MFhS7zFQQxz24rbM1CY9j3UC/3tqXNoTDj6YZoloNSIM1eHCkcuS17 Wsd8xQC3y5W+WZtmZiRh5UoSovkuaJUU/PR1OLiUM5vXkpUm5UX2KNeqBuALKnUJiv9n KwNntmKeWOpFvlgO61TIi2nyxYfTrL5AVakuZkO4e+BnmtK8XqwQX2N0HFc0n9lAWYWa nAQQ== X-Gm-Message-State: AOAM530bd2PW0aiTsWlb7/V9gswpWCYoqgJdHrHGM4wYyTUiVirJTtxw VncecFgM02++RRx/9+0sYnQwUYgQ+wQWuZMVbu9GMcMqXIy+/CxGjq5M63+9aDXjoby4mfVJoIV BsJ9jQ2CMeBPq/Z0twxdXTHLdUVPEvVT1xdQAEMuZ X-Received: by 2002:a05:600c:501e:b0:394:8b0a:3ec9 with SMTP id n30-20020a05600c501e00b003948b0a3ec9mr11945149wmr.0.1652181223538; Tue, 10 May 2022 04:13:43 -0700 (PDT) X-Received: by 2002:a05:600c:501e:b0:394:8b0a:3ec9 with SMTP id n30-20020a05600c501e00b003948b0a3ec9mr11945136wmr.0.1652181223377; Tue, 10 May 2022 04:13:43 -0700 (PDT) MIME-Version: 1.0 References: <20220508100630.2642320-1-keescook@chromium.org> In-Reply-To: From: Andreas Gruenbacher Date: Tue, 10 May 2022 13:13:31 +0200 Message-ID: Subject: Re: [PATCH] gfs2: Use container_of() for gfs2_glock(aspace) To: Kees Cook , Christoph Hellwig Cc: Bob Peterson , kernel test robot , Bill Wendling , cluster-devel , Nathan Chancellor , Nick Desaulniers , Tom Rix , Steven Whitehouse , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kees and Christoph, thanks for the patch and review. On Tue, May 10, 2022 at 9:29 AM Christoph Hellwig wrote: > > +/* gfs2_glock_get(), "glock" must be first. */ > > +struct glock_aspace { > > + struct gfs2_glock glock; > > + struct address_space mapping; > > +}; > > Why does glock need to be first? The whole point of using container_of > is that we don't have to make that assumption. Just needs to be cleaned up in gfs2_glock_get() and gfs2_glock_dealloc() as well. I'll do that when applying the patch. > > static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl) > > { > > if (gl->gl_ops->go_flags & GLOF_ASPACE) > > - return (struct address_space *)(gl + 1); > > + return &(container_of(gl, struct glock_aspace, glock)->mapping); > > Do we even need the braces here? Will use a local variable here, as suggested below. > > struct inode *inode = mapping->host; > > if (mapping->a_ops == &gfs2_meta_aops) > > - return (((struct gfs2_glock *)mapping) - 1)->gl_name.ln_sbd; > > + return container_of(mapping, struct glock_aspace, mapping)->glock.gl_name.ln_sbd; > > A local variable would be really nice for the reader here to decompose > this a bit: > > struct glock_aspace *a = > container_of(mapping, struct glock_aspace, mapping); > > return a->glock.gl_name.ln_sbd; Yes. Thanks, Andreas