Whamcloud - gitweb
b=22235 llapi_uuid_match() prints bogus error message on upgraded filesystem
authorDmitry Zogin <dmitry.zogin@sun.com>
Mon, 5 Apr 2010 18:49:44 +0000 (11:49 -0700)
committerRobert Read <robert.read@oracle.com>
Mon, 5 Apr 2010 18:49:44 +0000 (11:49 -0700)
 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

lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c

index 9ab8bc9..335c45e 100644 (file)
@@ -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;
         }
index c1f91bc..6d98f6b 100644 (file)
@@ -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;
         }
index d2fda85..7a4901b 100644 (file)
@@ -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);