diff mbox

Btrfs: optimize check for stale device

Message ID 1444035437-9442-1-git-send-email-anand.jain@oracle.com (mailing list archive)
State Superseded
Headers show

Commit Message

Anand Jain Oct. 5, 2015, 8:57 a.m. UTC
optimize check for stale device to only be checked when there
is device added or changed. If there is no update to the
device, there is no need to call btrfs_free_stale_device().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Anand Jain Oct. 7, 2015, 8:59 a.m. UTC | #1
On 10/05/2015 04:57 PM, Anand Jain wrote:
> optimize check for stale device to only be checked when there
> is device added or changed. If there is no update to the
> device, there is no need to call btrfs_free_stale_device().
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>   fs/btrfs/volumes.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index b8b1171..ec1fcfa 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -620,7 +620,8 @@ static noinline int device_list_add(const char *path,
>   	 * if there is new btrfs on an already registered device,
>   	 * then remove the stale device entry.
>   	 */
> -	btrfs_free_stale_device(device);
> +	if (ret > 0)
> +		btrfs_free_stale_device(device);
>
>   	*fs_devices_ret = fs_devices;
>
>

  I have to withdraw this. The ret is 0 when there is new fsid on a
  previously known device that means we need to clear the stale. v.sorry.

Thanks, Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Oct. 7, 2015, 9:01 a.m. UTC | #2
On Mon, Oct 05, 2015 at 04:57:17PM +0800, Anand Jain wrote:
> optimize check for stale device to only be checked when there
> is device added or changed. If there is no update to the
> device, there is no need to call btrfs_free_stale_device().
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Ok for the change, same comment to the changelog (74 chars, capitals).
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Oct. 7, 2015, 9:08 a.m. UTC | #3
On Wed, Oct 07, 2015 at 04:59:35PM +0800, Anand Jain wrote:
> > @@ -620,7 +620,8 @@ static noinline int device_list_add(const char *path,
> >   	 * if there is new btrfs on an already registered device,
> >   	 * then remove the stale device entry.
> >   	 */
> > -	btrfs_free_stale_device(device);
> > +	if (ret > 0)
> > +		btrfs_free_stale_device(device);
> >
> >   	*fs_devices_ret = fs_devices;
> 
>   I have to withdraw this. The ret is 0 when there is new fsid on a
>   previously known device that means we need to clear the stale. v.sorry.

Ah, right.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b8b1171..ec1fcfa 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -620,7 +620,8 @@  static noinline int device_list_add(const char *path,
 	 * if there is new btrfs on an already registered device,
 	 * then remove the stale device entry.
 	 */
-	btrfs_free_stale_device(device);
+	if (ret > 0)
+		btrfs_free_stale_device(device);
 
 	*fs_devices_ret = fs_devices;