int tmp;
struct lov_user_md *lum;
size_t lum_size;
+ char fsname[MAX_OBD_NAME + 1] = { 0 };
if (path == NULL ||
(layout != NULL && layout->llot_magic != LLAPI_LAYOUT_MAGIC)) {
}
if (layout) {
- rc = llapi_layout_sanity((struct llapi_layout *)layout, false,
- !!(layout->llot_mirror_count > 1));
+ /* Make sure we are on a Lustre file system */
+ rc = llapi_search_fsname(path, fsname);
+ if (rc) {
+ errno = ENOTTY;
+ return -1;
+ }
+ rc = llapi_layout_v2_sanity((struct llapi_layout *)layout,
+ false,
+ !!(layout->llot_mirror_count > 1),
+ fsname);
if (rc) {
llapi_layout_sanity_perror(rc);
return -1;
int rc, fd = -1, lum_size, tmp_errno = 0;
struct llapi_layout *existing_layout = NULL;
struct lov_user_md *lum = NULL;
+ char fsname[MAX_OBD_NAME + 1] = { 0 };
if (path == NULL || layout == NULL ||
layout->llot_magic != LLAPI_LAYOUT_MAGIC) {
goto out;
}
- rc = llapi_layout_sanity(existing_layout, false, false);
+ rc = llapi_search_fsname(path, fsname);
+ if (rc) {
+ tmp_errno = -rc;
+ rc = -1;
+ goto out;
+ }
+
+ rc = llapi_layout_v2_sanity(existing_layout, false, false, fsname);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
struct llapi_layout *layout = NULL;
struct llapi_layout_comp *comp;
struct lov_user_md *lum = NULL;
+ char fsname[MAX_OBD_NAME + 1] = { 0 };
if (path == NULL) {
errno = EINVAL;
goto out;
}
- rc = llapi_layout_sanity(existing_layout, false, false);
+ rc = llapi_search_fsname(path, fsname);
+ if (rc) {
+ tmp_errno = -rc;
+ rc = -1;
+ goto out;
+ }
+
+ rc = llapi_layout_v2_sanity(existing_layout, false, false, fsname);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
bool lsa_flr;
bool lsa_ondisk;
int lsa_rc;
+ char *fsname;
};
/* The component flags can be set by users at creation/modification time. */
#define LCME_USER_COMP_FLAGS (LCME_FL_PREF_RW | LCME_FL_NOSYNC | \
LCME_FL_EXTENSION)
+/* Inline function to verify the pool name */
+static inline int verify_pool_name(char *fsname, struct llapi_layout *layout)
+{
+ struct llapi_layout_comp *comp;
+
+ if (!fsname || fsname[0] == '\0')
+ return 0;
+
+ comp = __llapi_layout_cur_comp(layout);
+ if (!comp)
+ return 0;
+ if (comp->llc_pool_name[0] == '\0')
+ return 0;
+ /* check if the pool name exist */
+ if (llapi_search_ost(fsname, comp->llc_pool_name, NULL) < 0)
+ return -1;
+ return 0;
+}
+
/**
* When modified, adjust llapi_stripe_param_verify() if needed as well.
*/
goto out_err;
}
+ if (verify_pool_name(args->fsname, layout) != 0) {
+ args->lsa_rc = -1;
+ goto out_err;
+ }
+
if (comp->llc_list.prev != &layout->llot_comp_list)
prev = list_last_entry(&comp->llc_list, typeof(*prev),
llc_list);
* \retval 0, success, positive: various errors, see
* llapi_layout_sanity_perror, -1, failure
*/
+
int llapi_layout_sanity(struct llapi_layout *layout,
- bool incomplete,
- bool flr)
+ bool incomplete, bool flr)
+{
+ return llapi_layout_v2_sanity(layout, incomplete, flr, NULL);
+}
+
+/* This function has been introduced to do pool name checking
+ * on top of llapi_layout_sanity, the file name passed in this
+ * function is used later to verify if pool exist. The older version
+ * of the sanity function is passing NULL for the filename
+ * Input arguments ---
+ * \param[in] layout component layout list.
+ * \param[in] fname file the layout to be checked for
+ * \param[in] incomplete if layout is complete or not - some checks can
+ * only be done on complete layouts.
+ * \param[in] flr set when this is called from FLR mirror create
+ * \param[in] fsname filesystem name is used to check pool name, if
+ * NULL no pool name check is performed
+ *
+ * \retval 0, success, positive: various errors, see
+ */
+
+int llapi_layout_v2_sanity(struct llapi_layout *layout,
+ bool incomplete, bool flr, char *fsname)
{
struct llapi_layout_sanity_args args = { 0 };
struct llapi_layout_comp *curr;
args.lsa_rc = 0;
args.lsa_flr = flr;
args.lsa_incomplete = incomplete;
+ args.fsname = fsname;
/* When we modify an existing layout, this tells us if it's FLR */
if (mirror_id_of(curr->llc_id) > 0)