[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <212b02a8-f5f0-4433-a726-1639dda61790@linux.microsoft.com>
Date: Wed, 8 May 2024 15:30:14 -0700
From: Fan Wu <wufan@...ux.microsoft.com>
To: Mikulas Patocka <mpatocka@...hat.com>
Cc: corbet@....net, zohar@...ux.ibm.com, jmorris@...ei.org, serge@...lyn.com,
tytso@....edu, ebiggers@...nel.org, axboe@...nel.dk, agk@...hat.com,
snitzer@...nel.org, eparis@...hat.com, paul@...l-moore.com,
linux-doc@...r.kernel.org, linux-integrity@...r.kernel.org,
linux-security-module@...r.kernel.org, fsverity@...ts.linux.dev,
linux-block@...r.kernel.org, dm-devel@...ts.linux.dev,
audit@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v18 12/21] dm: add finalize hook to target_type
On 5/8/2024 10:17 AM, Mikulas Patocka wrote:
>
>
> On Fri, 3 May 2024, Fan Wu wrote:
>
>> This patch adds a target finalize hook.
>>
>> The hook is triggered just before activating an inactive table of a
>> mapped device. If it returns an error the __bind get cancelled.
>>
>> The dm-verity target will use this hook to attach the dm-verity's
>> roothash metadata to the block_device struct of the mapped device.
>>
>> Signed-off-by: Fan Wu <wufan@...ux.microsoft.com>
>
> Hi
>
> Why not use the preresume callback?
>
> Is there some reason why do we need a new callback instead of using the
> existing one?
>
> Mikulas
Thanks for the suggestion.
Mike suggested the new finalize() callback. I think the reason for not
using the preresume() callback is that there are multiple points that
can fail before activating an inactive table of a mapped device which
can potentially lead to inconsistent state.
In our specific case, we are trying to associate dm-verity's roothash
metadata with the block_device struct of the mapped device inside the
callback.
If we use the preresume() callback for the work and an error occurs
between the callback and the table activation, this leave the
block_device struct in an inconsistent state.
This is because now the block device contains the roothash metadata of
it's inactive table due to the preresume() callback, but the activation
failed so the mapped device is still using the old table.
The new finalize() callback guarantees that the callback happens just
before the table activation, thus avoiding the inconsistency.
-Fan
Powered by blists - more mailing lists