From: Dmitry Zogin Date: Mon, 5 Apr 2010 18:49:44 +0000 (-0700) Subject: b=22235 llapi_uuid_match() prints bogus error message on upgraded filesystem X-Git-Tag: 1.10.0.40~17 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=77adc7502148359adc472af645fa9a0706ec282e b=22235 llapi_uuid_match() prints bogus error message on upgraded filesystem Change lov_iocontrol(), lmv_iocontrol() and mdc_iocontrol() functions to copy UUID string into a buffer before calling *_statfs() functions, so that UUID is always set when returning to the caller i=andreas.dilger i=nathan.rutman --- diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 9ab8bc9..335c45e 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -748,15 +748,19 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (!mdc_obd) RETURN(-EINVAL); + /* copy UUID */ + if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd), + min((int) data->ioc_plen2, + (int) sizeof(struct obd_uuid)))) + RETURN(-EFAULT); + rc = obd_statfs(mdc_obd, &stat_buf, cfs_time_current_64() - CFS_HZ, 0); if (rc) RETURN(rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, - data->ioc_plen1)) - RETURN(-EFAULT); - if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd), - data->ioc_plen2)) + min((int) data->ioc_plen1, + (int) sizeof(stat_buf)))) RETURN(-EFAULT); break; } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index c1f91bc..6d98f6b 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2001,17 +2001,20 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (!osc_obd) RETURN(-EINVAL); + /* copy UUID */ + if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), + min((int) data->ioc_plen2, + (int) sizeof(struct obd_uuid)))) + RETURN(-EFAULT); + /* got statfs data */ rc = obd_statfs(osc_obd, &stat_buf, cfs_time_current_64() - CFS_HZ, 0); if (rc) RETURN(rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, - data->ioc_plen1)) - RETURN(-EFAULT); - /* copy UUID */ - if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), - data->ioc_plen2)) + min((int) data->ioc_plen1, + (int) sizeof(stat_buf)))) RETURN(-EFAULT); break; } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index d2fda85..7a4901b 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1394,16 +1394,20 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (*((__u32 *) data->ioc_inlbuf2) != 0) GOTO(out, rc = -ENODEV); + /* copy UUID */ + if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd), + min((int) data->ioc_plen2, + (int) sizeof(struct obd_uuid)))) + GOTO(out, rc = -EFAULT); + rc = mdc_statfs(obd, &stat_buf, cfs_time_current_64() - CFS_HZ, 0); if (rc != 0) GOTO(out, rc); if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf, - data->ioc_plen1)) - GOTO(out, rc = -EFAULT); - if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd), - data->ioc_plen2)) + min((int) data->ioc_plen1, + (int) sizeof(stat_buf)))) GOTO(out, rc = -EFAULT); GOTO(out, rc = 0);