Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fPv7Q-0000F0-K6 for mharc-grub-devel@gnu.org; Mon, 04 Jun 2018 15:26:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPv7N-0000Ee-Ng for grub-devel@gnu.org; Mon, 04 Jun 2018 15:26:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPv7K-0002h5-Hh for grub-devel@gnu.org; Mon, 04 Jun 2018 15:26:13 -0400 Received: from smtp-32-i6.italiaonline.it ([213.209.14.32]:48471 helo=libero.it) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPv7K-0002gE-90 for grub-devel@gnu.org; Mon, 04 Jun 2018 15:26:10 -0400 Received: from venice.bhome ([94.38.17.26]) by smtp-32.iol.local with SMTP id Pv7GfbDDqEpCFPv7GfCG3D; Mon, 04 Jun 2018 21:26:08 +0200 x-libjamoibt: 1601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inwind.it; s=s2014; t=1528140368; bh=brzaqbrtA9jPX5pY/KtsZoSRxdyG2SojnlsmTouhGhM=; h=Subject:Reply-To:References:To:From:Date:In-Reply-To; b=kaiiuKb3WigGFufRLzZLZncMT1Advlm+2za3vSFyOqISmxmGa2ywsx8JbQrDdyg8K KkATPOVAjhWYwJmMi/XxYfL/P900oP3LmY/M5Bwm1wYw+bK5ChsPux/JvOvqYcSO+b Oq58MgM8kxdPzoJnOz89V3PB2NElnMxyKjkAwhK2d1k5/rM6arULbTvSMHR9z5mANu OM5TEYPZHo031O1FM9W6Y0wBsol4ms6We8TAyNr4pohLA5hjij47wNBXfHtJsDjXyM nezDkNwI23VQAcDhpdkuN9JCkhBSN8gkNjDp7yM5YpixlyGwuERKDpM5ZF3O+Z7J8r 5Rz8tYGwcxsPw== X-CNFS-Analysis: v=2.2 cv=Mooi0ySe c=1 sm=1 tr=0 a=cK+OJL3rvEoxrkt0Byq3rg==:117 a=cK+OJL3rvEoxrkt0Byq3rg==:17 a=N659UExz7-8A:10 a=pGLkceISAAAA:8 a=mDV3o1hIAAAA:8 a=yetbio8ITPr8J_6SmAQA:9 a=pILNOxqGKmIA:10 a=_FVE-zBwftR9WsbkzFJk:22 Subject: Fwd: [PATCH 4/9] btrfs: Avoid a rescan for a device which was already not found. Reply-To: kreijack@inwind.it References: <20180603185348.1780-5-kreijack@inwind.it> To: The development of GNU GRUB From: Goffredo Baroncelli X-Forwarded-Message-Id: <20180603185348.1780-5-kreijack@inwind.it> Message-ID: <92c08492-23ce-2498-ee1d-ebde021a8534@inwind.it> Date: Mon, 4 Jun 2018 21:26:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180603185348.1780-5-kreijack@inwind.it> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfGqxGoAlAa8mB1YpoVOnXMGlxqguPTmePQKi0OGQzgkjzA33e/tzIP574PaVfFE+62YzMrlXRIZVOY8Xux03SNEXvZ1fVj42Gyt6GOeYrGVs0MJA/5tx 37uvRCa6AICRKrYV/sZSSw/3MEY5hQizp7JG5NPKgIH8+0kjHeSxXHZL X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 213.209.14.32 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jun 2018 19:26:14 -0000 Resend this patch because I am not sure that all received it. BR G.Baroncelli -------- Forwarded Message -------- Subject: [PATCH 4/9] btrfs: Avoid a rescan for a device which was already not found. Date: Sun, 3 Jun 2018 20:53:43 +0200 From: Goffredo Baroncelli To: grub-devel@gnu.org CC: Goffredo Baroncelli 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 --- 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 9b3a22772..b64b692f8 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); + data->n_devices_attached++; if (data->n_devices_attached > data->n_devices_allocated) { @@ -617,7 +614,8 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id, int do_rescan) * sizeof (data->devices_attached[0])); if (!data->devices_attached) { - grub_device_close (ctx.dev_found); + if (ctx.dev_found) + grub_device_close (ctx.dev_found); data->devices_attached = tmp; return NULL; } @@ -896,7 +894,7 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, " for laddr 0x%" PRIxGRUB_UINT64_T "\n", paddr, addr); - dev = find_device (data, stripe->device_id, j); + dev = find_device (data, stripe->device_id); if (!dev) { grub_dprintf ("btrfs", @@ -973,7 +971,8 @@ grub_btrfs_unmount (struct grub_btrfs_data *data) unsigned i; /* The device 0 is closed one layer upper. */ for (i = 1; i < data->n_devices_attached; i++) - grub_device_close (data->devices_attached[i].dev); + if (data->devices_attached[i].dev) + grub_device_close (data->devices_attached[i].dev); grub_free (data->devices_attached); grub_free (data->extent); grub_free (data); -- 2.17.1