Re: [PATCH 2/3] mm, swap: distinguish a malformed swap entry from a dying device
From: David Hildenbrand (Arm)
Date: Wed Aug 12 2026 - 07:19:50 EST
On 8/12/26 13:02, Pedro Falcato wrote:
> On Wed, Aug 12, 2026 at 03:48:56AM -0700, Breno Leitao wrote:
>> Hello David,
>>
>> On Tue, Aug 11, 2026 at 05:36:31PM +0200, David Hildenbrand (Arm) wrote:
>>>
>>> Is -EINVAL really the logical right return value? Running into bad swap entries
>>> sounds more serious to me than "-EINVAL" :)
>>
>> Good point, maybe we need a strong drug here, what about -EIO?
>>
>> I picked -EINVAL because it is what the swap code already returns for
>> this exact condition.
>>
>>
>> * Returns -EINVAL if the swap entry is invalid, which might
>> * occur if a page table entry has got corrupted.
>> */
>> int swap_dup_entry_direct(swp_entry_t entry)
>> {
>> si = swap_entry_to_info(entry);
>> if (WARN_ON_ONCE(!si)) {
>> pr_err("%s%08lx\n", Bad_file, entry.val);
>> return -EINVAL;
>>
>> But, I do agree -EINVAL is too soft given the situation we are in.
>>
>> I will return -EIO in the next version, if I don't hear any concern.
>
> Perhaps -EUCLEAN would be a more fitting error. It's generally what
> filesystems use, at least (EFSCORRUPTED = EUCLEAN).
Not a big fan of EUCLEAN for the use case here. The details don't really matter,
but EINVAL just looked rather odd.
--
Cheers,
David