[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] btrfs: Avoid a rescan for a device which was already not fou
From: |
Goffredo Baroncelli |
Subject: |
[PATCH 4/9] btrfs: Avoid a rescan for a device which was already not found. |
Date: |
Wed, 18 Jul 2018 20:59:17 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
Resend because I forgot to put grub-devel in cc
-------------------------------------------------------------
On 07/12/2018 04:02 PM, Daniel Kiper wrote:
> On Tue, Jun 19, 2018 at 08:22:19PM +0200, Goffredo Baroncelli wrote:
>> Forward because this patch still doesn't reach the mailing list
>
> Could you fix that somehow? It is confusing.
I don't know which could be the problem. The only idea which I have, is that
the patch #4 is the only one which was never changed; gmail prevent two equal
emails to reach the inbox two times. I suspect that these two thing are related
>
>> --------------------------------------
>>
>> If a device is not found, record this failure by storing NULL in
>> data->devices_attached[]. This way we avoid unnecessary devices rescan,
>> and speedup the reads in case of a degraded array.
>>
>> Signed-off-by: Goffredo Baroncelli <address@hidden>
>> ---
>> grub-core/fs/btrfs.c | 19 +++++++++----------
>> 1 file changed, 9 insertions(+), 10 deletions(-)
>>
>> diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
>> index 8d07e2d72..70bcb0fdc 100644
>> --- a/grub-core/fs/btrfs.c
>> +++ b/grub-core/fs/btrfs.c
>> @@ -588,7 +588,7 @@ find_device_iter (const char *name, void *data)
>> }
>>
>> static grub_device_t
>> -find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan)
>> +find_device (struct grub_btrfs_data *data, grub_uint64_t id)
>> {
>> struct find_device_ctx ctx = {
>> .data = data,
>> @@ -600,12 +600,9 @@ find_device (struct grub_btrfs_data *data,
>> grub_uint64_t id, int do_rescan)
>> for (i = 0; i < data->n_devices_attached; i++)
>> if (id == data->devices_attached[i].id)
>> return data->devices_attached[i].dev;
>> - if (do_rescan)
>> - grub_device_iterate (find_device_iter, &ctx);
>> - if (!ctx.dev_found)
>> - {
>> - return NULL;
>> - }
>> +
>> + grub_device_iterate (find_device_iter, &ctx);
>> +
[...]
>
> The commit message or code is wrong. NULL is never stored into
> data->devices_attached[]. Am I missing something?
The original code searches a device (using 'id' as key) in the array
data->devices_attached[]; if the device is found, the device info are
returned.
Otherwise find_device() searches the device using grub_device_iterate().
If ctx.dev_found is NULL, the device is not found and the function returns NULL.
Otherwise find_device() stores the pair "ctx.dev_found" and "id"
in data->devices_attached[] array for further searches.
Finally find_device() returns the value found.
My patch removes the check: if the device is not found, find_devices() stores
the pair "NULL" and "id". So data->devices_attached[] array acts as cache both
for the "founded" and "not founded" devices.
>
> Daniel
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5