Re: [PATCH 06/14] audit: Factor out chunk replacement code

Paul Moore
2018-11-12T15:16:08Z

On Fri, Nov 9, 2018 at 9:45 AM Paul Moore <paul@paul-moore.com> wrote:
> On Wed, Nov 7, 2018 at 4:55 AM Jan Kara <jack@suse.cz> wrote:
> > On Tue 06-11-18 08:58:36, Paul Moore wrote:
> > > On Thu, Oct 18, 2018 at 3:27 PM Richard Guy Briggs <rgb@redhat.com> wrote:
> > > > On 2018-10-17 12:14, Jan Kara wrote:
> > > > > Chunk replacement code is very similar for the cases where we grow or
> > > > > shrink chunk. Factor the code out into a common helper function.
> > > >
> > > > Noting just the switch from list_replace_init() to list_splice_init().
> > >
> > > Yeah, I wasn't expecting to see that, maybe it will make sense as I
> > > work through the rest of the patchset.
> > >
> > > Jan, can you explain the reason behind the change? I'm a little
> > > nervous that this is simply hiding a problem (e.g. the list_empty()
> > > check in splice).
> >
> > The reason is very simple: replace_chunk() gets called from tag_chunk()
> > *after* we have possibly done:
> >
> > if (!tree->root) {
> > tree->root = chunk;
> > list_add(&tree->same_root, &chunk->trees);
> > }
> >
> > So new->trees is possibly non-empty and we need to preserve its contents.
> > That's why we need list_splice() and not plain list_replace().
>
> After revisiting this a couple of time this week, I found my problem -
> I had reversed list_splice_init() in my mind and was worried that if
> the old->trees list was not empty we would end up not adding
> new->trees. Sorry about the noise.
>
> I've updated the audit/working-fsnotify_fixes with the latest patches,
> including the revised 12/14 sent as an attachment, and I'm going to
> test it over the weekend. If the kernel is still standing on Monday
> morning I'll merge it into audit/next.
>
> Thanks again.

My test machine was still standing this morning so I went ahead and
merged all of the patches into audit/next - Thanks Jan.

--
paul moore