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

Jan Kara
2018-11-07T09:55:12Z

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().

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR