+ * (Re-)allocate llot_objects[] to \a num_stripes stripes.
+ *
+ * Copy over existing llot_objects[], if any, to the new llot_objects[].
+ *
+ * \param[in] layout existing layout to be modified
+ * \param[in] num_stripes number of stripes in new layout
+ *
+ * \retval 0 if the objects are re-allocated successfully
+ * \retval -1 on error with errno set
+ */
+static int __llapi_layout_objects_realloc(struct llapi_layout *layout,
+ unsigned int new_stripes)
+{
+ struct lov_user_ost_data_v1 *new_objects;
+ unsigned int i;
+
+ if (new_stripes > LOV_MAX_STRIPE_COUNT) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (new_stripes == 0 && layout->llot_objects_count == 0)
+ return 0;
+
+ if (new_stripes != 0 && new_stripes <= layout->llot_objects_count)
+ return 0;
+
+ new_objects = realloc(layout->llot_objects,
+ sizeof(*new_objects) * new_stripes);
+ if (new_objects == NULL && new_stripes != 0) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ for (i = layout->llot_objects_count; i < new_stripes; i++)
+ new_objects[i].l_ost_idx = LLAPI_LAYOUT_IDX_MAX;
+
+ if (new_stripes == 0)
+ layout->llot_objects = NULL;
+ else
+ layout->llot_objects = new_objects;
+ layout->llot_objects_count = new_stripes;
+
+ return 0;
+}
+
+/**