Re: [PATCH] nvme: Allocate memory for xa_store in advance in nvme_get_effects_log

Keisuke Nishimura
2024-12-16T13:13:10Z

Hello,

On 12/12/2024 07:27, Christoph Hellwig wrote:
> On Mon, Dec 02, 2024 at 01:42:40PM +0100, Keisuke Nishimura wrote:
>> + ret = xa_reserve(&ctrl->cels, csi, GFP_KERNEL);
>> + if (ret) {
>> + kfree(cel);
>> + return ret;
>> + }
>> +
>> ret = nvme_get_log(ctrl, 0x00, NVME_LOG_CMD_EFFECTS, 0, csi,
>> cel, sizeof(*cel), 0);
>
> There isn't really any point in doing a xa_reserve here vs simply
> handling the xa_store error a bit below.
>

Thank you for your reply.

Without this xa_reserve(), if xa_store() fails, we cannot store cel after
calling nvme_get_log() which can have side effects. My intention is to ensure
xa_store() succeeds first and, if not, return early before invoking nvme_get_log().

But I am not very familiar with this code. If it is okay to check after the
nvme_get_log(), I will send the patch soon.

best,
Keisuke