[Ocfs2-tools-devel] [PATCH] scandisk: remove unnecessary scansysfs op

Joseph Qi joseph.qi at huawei.com
Mon Jun 27 23:15:45 PDT 2016


On 2016/6/22 13:01, Junxiao Bi wrote:
> For every block device in sysfs who is not a symbol link,
> scansysfs() will run two times on it, run once is enough
> and that can improve scandisk speed.
> 
> Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
Looks good to me.
Reviewed-by: Joseph Qi <joseph.qi at huawei.com>

> ---
>  libtools-internal/scandisk.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libtools-internal/scandisk.c b/libtools-internal/scandisk.c
> index 0ad21a2b5606..5209de272f5d 100644
> --- a/libtools-internal/scandisk.c
> +++ b/libtools-internal/scandisk.c
> @@ -763,15 +763,15 @@ static int scansysfs(struct devlisthead *devlisthead, const char *path, int leve
>  				    sysfs_is_disk(newpath);
>  			}
>  
> -			if (!stat(newpath, &sb) && !level)
> +			if (!stat(newpath, &sb) && !level) {
>  				if (S_ISDIR(sb.st_mode))
>  					if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
>  						return -1;
> -
> -			if (!lstat(newpath, &sb))
> +			} else if (!lstat(newpath, &sb)) {
>  				if (S_ISDIR(sb.st_mode))
>  					if (scansysfs(devlisthead, newpath, 1, has_holder) < 0)
>  						return -1;
> +			}
>  
>  		}
>  		free(namelist[n]);
> 





More information about the Ocfs2-tools-devel mailing list