All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Kees Cook <keescook@chromium.org>, Christoph Hellwig <hch@infradead.org>
Cc: Bob Peterson <rpeterso@redhat.com>,
	kernel test robot <lkp@intel.com>,
	Bill Wendling <morbo@google.com>,
	cluster-devel <cluster-devel@redhat.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	Steven Whitehouse <swhiteho@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gfs2: Use container_of() for gfs2_glock(aspace)
Date: Tue, 10 May 2022 13:13:31 +0200	[thread overview]
Message-ID: <CAHc6FU5VfS9yNe0yH_sfOt04rvii6T_NMq7kp+32HZa5XQDtEA@mail.gmail.com> (raw)
In-Reply-To: <YnoQmuPgK9c5V8ZC@infradead.org>

Kees and Christoph,

thanks for the patch and review.

On Tue, May 10, 2022 at 9:29 AM Christoph Hellwig <hch@infradead.org> 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


WARNING: multiple messages have this Message-ID (diff)
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2: Use container_of() for gfs2_glock(aspace)
Date: Tue, 10 May 2022 13:13:31 +0200	[thread overview]
Message-ID: <CAHc6FU5VfS9yNe0yH_sfOt04rvii6T_NMq7kp+32HZa5XQDtEA@mail.gmail.com> (raw)
In-Reply-To: <YnoQmuPgK9c5V8ZC@infradead.org>

Kees and Christoph,

thanks for the patch and review.

On Tue, May 10, 2022 at 9:29 AM Christoph Hellwig <hch@infradead.org> 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


  reply	other threads:[~2022-05-10 11:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 10:06 [PATCH] gfs2: Use container_of() for gfs2_glock(aspace) Kees Cook
2022-05-08 10:06 ` [Cluster-devel] " Kees Cook
2022-05-10  7:13 ` Christoph Hellwig
2022-05-10  7:13   ` [Cluster-devel] " Christoph Hellwig
2022-05-10 11:13   ` Andreas Gruenbacher [this message]
2022-05-10 11:13     ` Andreas Gruenbacher
2022-05-10 15:51     ` Kees Cook
2022-05-10 15:51       ` [Cluster-devel] " Kees Cook
2022-05-10 16:16       ` Andreas Gruenbacher
2022-05-10 16:16         ` [Cluster-devel] " Andreas Gruenbacher
2022-05-10 17:55         ` Kees Cook
2022-05-10 17:55           ` [Cluster-devel] " Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHc6FU5VfS9yNe0yH_sfOt04rvii6T_NMq7kp+32HZa5XQDtEA@mail.gmail.com \
    --to=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=rpeterso@redhat.com \
    --cc=swhiteho@redhat.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.