int llapi_heat_set(int fd, __u64 flags);
int llapi_layout_sanity(struct llapi_layout *layout, bool incomplete, bool flr);
-int llapi_layout_sanity_fsname_check(struct llapi_layout *layout,
- const char *pathname,
- bool incomplete,
- bool flr);
void llapi_layout_sanity_perror(int error);
int llapi_layout_dom_size(struct llapi_layout *layout, uint64_t *size);
ASSERTF(layout != NULL, "errno = %d", errno);
fd = llapi_layout_file_create(template, 0, 0640, layout);
- ASSERTF(fd == -1 && errno == ENOENT,
+ ASSERTF(fd == -1 && errno == ENOTTY,
"fd = %d, errno = %d, template = %s", fd, errno, template);
llapi_layout_free(layout);
}
$LFS setstripe -c 2 -p $INVALID_POOL $POOL_DIR 2>/dev/null
[[ $? -ne 0 ]] || error "setstripe to invalid pool did not fail."
- # If the pool name does not exist, the command should fail
- $LFS setstripe -c 2 -p $NON_EXISTANT_POOL $POOL_DIR 2>/dev/null
- [[ $? -ne 0 ]] || error "setstripe to non-existant pool did not fail."
-
# lfs setstripe should work as before if a pool name is not specified.
$LFS setstripe -c -1 $POOL_DIR
[[ $? -eq 0 ]] || error "$LFS setstripe -c -1 $POOL_DIR failed."
$LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool}X" &&
error "setstripe succedeed"
- # setstripe with the same pool name minus 1 letter
- $LFS setstripe -c 1 $DIR/$tdir/testfile1 --pool "${pool%?}" &&
- error "setstripe succedeed"
-
rm -f $DIR/$tdir/testfile1
destroy_pool_int $FSNAME.$pool
rc = -errno;
goto free_layout;
}
- rc = llapi_layout_sanity_fsname_check(layout, fname, false, true);
+ rc = llapi_layout_sanity(layout, false, true);
if (rc < 0) {
llapi_layout_sanity_perror(errno);
goto free_layout;
return -ENODATA;
}
- rc = llapi_layout_sanity_fsname_check(layout, fname,
- false, true);
+ rc = llapi_layout_sanity(layout, false, true);
llapi_layout_free(layout);
}
}
- rc = llapi_layout_sanity_fsname_check(list->m_layout, fname,
- false, true);
+ rc = llapi_layout_sanity(list->m_layout, false, true);
if (rc) {
llapi_layout_sanity_perror(rc);
return rc;
return -EINVAL;
}
- rc = llapi_layout_sanity_fsname_check(layout, fname, false, true);
+ rc = llapi_layout_sanity(layout, false, true);
if (rc) {
llapi_layout_sanity_perror(rc);
goto free_layout;
return 0;
}
-/* XXX: llapi_xxx() functions return negative values upon failure */
-
-int llapi_layout_search_ost(__u32 ost, const char *pname, char *fsname)
-{
- char ostname[MAX_OBD_NAME + 64];
- const char *pool_name = pname;
- int rc = 0;
-
- /**
- * The current policy is that the pool does not have to exist at the
- * setstripe time, see sanity-pfl/-flr tests.
- * If this logic will change, re-enable it.
- *
- * if (pname && strlen(pname) == 0)
- */
- pool_name = NULL;
-
- snprintf(ostname, sizeof(ostname), "%s-OST%04x_UUID",
- fsname, ost);
- rc = llapi_search_ost(fsname, pool_name, ostname);
- if (rc <= 0) {
- if (rc == 0)
- rc = -ENODEV;
-
- llapi_error(LLAPI_MSG_ERROR, rc,
- "%s: cannot find OST %s in %s", __func__, ostname,
- pool_name != NULL ? "pool" : "system");
- return rc;
- }
-
- return 0;
-}
-
/**
* Verify the setstripe parameters before using.
* This is a pair method for comp_args_to_layout()/llapi_layout_sanity_cb()
* < 0, error code on failre
*/
static int llapi_stripe_param_verify(const struct llapi_stripe_param *param,
- const char **pool_name,
- char *fsname)
+ const char **pool_name)
{
int count;
static int page_size;
/* Make sure we have a good pool */
if (*pool_name != NULL) {
- if (!llapi_pool_name_is_valid(pool_name, fsname)) {
+ if (!llapi_pool_name_is_valid(pool_name)) {
rc = -EINVAL;
llapi_error(LLAPI_MSG_ERROR, rc,
- "Pool '%s' is not on filesystem '%s'",
- *pool_name, fsname);
+ "Invalid Poolname '%s'", *pool_name);
goto out;
}
-
- /* Make sure the pool exists and is non-empty */
- rc = llapi_search_ost(fsname, *pool_name, NULL);
- if (rc < 1) {
- char *err = rc == 0 ? "has no OSTs" : "does not exist";
-
- rc = -EINVAL;
- llapi_error(LLAPI_MSG_ERROR, rc, "pool '%s.%s' %s",
- fsname, *pool_name, err);
- goto out;
- }
- rc = 0;
}
- /* sanity check of target list */
- if (param->lsp_is_specific) {
- bool found = false;
- int i;
-
- for (i = 0; i < count; i++) {
- rc = llapi_layout_search_ost(param->lsp_osts[i],
- *pool_name, fsname);
- if (rc)
- goto out;
-
- /* Make sure stripe offset is in OST list. */
- if (param->lsp_osts[i] == param->lsp_stripe_offset)
- found = true;
- }
- if (!found) {
- rc = -EINVAL;
- llapi_error(LLAPI_MSG_ERROR, rc,
- "%s: stripe offset '%d' is not in the target list",
- __func__, param->lsp_stripe_offset);
- goto out;
- }
- } else if (param->lsp_stripe_offset != -1) {
- rc = llapi_layout_search_ost(param->lsp_stripe_offset,
- *pool_name, fsname);
- if (rc)
- goto out;
- }
out:
errno = -rc;
return rc;
int llapi_file_open_param(const char *name, int flags, mode_t mode,
const struct llapi_stripe_param *param)
{
- char fsname[MAX_OBD_NAME + 1] = { 0 };
struct lov_user_md *lum = NULL;
const char *pool_name = param->lsp_pool;
size_t lum_size;
int fd, rc;
- /* Make sure we are on a Lustre file system */
- rc = llapi_search_fsname(name, fsname);
- if (rc) {
- llapi_error(LLAPI_MSG_ERROR, rc,
- "'%s' is not on a Lustre filesystem",
- name);
- return rc;
- }
-
/* Check if the stripe pattern is sane. */
- rc = llapi_stripe_param_verify(param, &pool_name, fsname);
+ rc = llapi_stripe_param_verify(param, &pool_name);
if (rc != 0)
return rc;
if (comp == NULL)
return -1;
- if (!llapi_pool_name_is_valid(&pool_name, NULL)) {
+ if (!llapi_pool_name_is_valid(&pool_name)) {
errno = EINVAL;
return -1;
}
}
if (layout) {
- rc = llapi_layout_sanity_fsname_check(
- (struct llapi_layout *)layout, path, false,
+ rc = llapi_layout_sanity((struct llapi_layout *)layout, false,
!!(layout->llot_mirror_count > 1));
if (rc) {
llapi_layout_sanity_perror(rc);
goto out;
}
- rc = llapi_layout_sanity_fsname_check(existing_layout, path,
- false, false);
+ rc = llapi_layout_sanity(existing_layout, false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
goto out;
}
- rc = llapi_layout_sanity_fsname_check(existing_layout, path,
- false, false);
+ rc = llapi_layout_sanity(existing_layout, false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
goto out;
}
- rc = llapi_layout_sanity_fsname_check(existing_layout, path,
- false, false);
+ rc = llapi_layout_sanity(existing_layout, false, false);
if (rc) {
tmp_errno = errno;
llapi_layout_sanity_perror(rc);
LSE_START_GT_END,
LSE_ALIGN_END,
LSE_ALIGN_EXT,
- LSE_UNKNOWN_OST,
LSE_LAST,
};
"The component end must be aligned by the stripe size",
[LSE_ALIGN_EXT] =
"The extension size must be aligned by the stripe size",
- [LSE_UNKNOWN_OST] =
- "An unknown OST idx is specified",
};
struct llapi_layout_sanity_args {
- char lsa_fsname[MAX_OBD_NAME + 1];
bool lsa_incomplete;
bool lsa_flr;
bool lsa_ondisk;
goto out_err;
}
- if (args->lsa_fsname[0] != '\0') {
- int i, rc = 0;
-
- if (comp->llc_pattern & LLAPI_LAYOUT_SPECIFIC) {
- assert(comp->llc_stripe_count <=
- comp->llc_objects_count);
-
- for (i = 0; i < comp->llc_stripe_count && rc == 0; i++){
- if (comp->llc_objects[i].l_ost_idx ==
- LLAPI_LAYOUT_IDX_MAX) {
- args->lsa_rc = -1;
- goto out_err;
- }
- rc = llapi_layout_search_ost(
- comp->llc_objects[i].l_ost_idx,
- comp->llc_pool_name, args->lsa_fsname);
- }
- } else if (comp->llc_stripe_offset != LLAPI_LAYOUT_DEFAULT) {
- rc = llapi_layout_search_ost(
- comp->llc_stripe_offset,
- comp->llc_pool_name, args->lsa_fsname);
- }
- if (rc) {
- args->lsa_rc = LSE_UNKNOWN_OST;
- goto out_err;
- }
- }
-
return LLAPI_LAYOUT_ITER_CONT;
out_err:
* \retval 0, success, positive: various errors, see
* llapi_layout_sanity_perror, -1, failure
*/
-static int __llapi_layout_sanity(struct llapi_layout *layout,
- const char *fname,
- bool incomplete,
- bool flr)
+int llapi_layout_sanity(struct llapi_layout *layout,
+ bool incomplete,
+ bool flr)
{
- struct llapi_layout_sanity_args args = { { 0 } };
+ struct llapi_layout_sanity_args args = { 0 };
struct llapi_layout_comp *curr;
int rc = 0;
if (!curr)
return 0;
- /* Make sure we are on a Lustre file system */
- if (fname) {
- rc = llapi_search_fsname(fname, args.lsa_fsname);
- if (rc) {
- llapi_error(LLAPI_MSG_ERROR, rc,
- "'%s' is not on a Lustre filesystem",
- fname);
- return rc;
- }
- }
-
/* Set up args */
args.lsa_rc = 0;
args.lsa_flr = flr;
return rc;
}
-int llapi_layout_sanity(struct llapi_layout *layout,
- bool incomplete,
- bool flr)
-{
- return __llapi_layout_sanity(layout, NULL, incomplete, flr);
-}
-
-int llapi_layout_sanity_fsname_check(struct llapi_layout *layout,
- const char *pathname,
- bool incomplete,
- bool flr)
-{
- return __llapi_layout_sanity(layout, pathname, incomplete, flr);
-}
-
int llapi_layout_dom_size(struct llapi_layout *layout, uint64_t *size)
{
uint64_t pattern, start;
return index >= -1 && index <= LOV_V1_INSANE_STRIPE_COUNT;
}
-static inline bool llapi_pool_name_is_valid(const char **pool_name,
- const char *fsname)
+static inline bool llapi_pool_name_is_valid(const char **pool_name)
{
const char *ptr;
if (*pool_name == NULL)
return false;
- /**
- * in case user gives the full pool name <fsname>.<poolname>,
- * strip the fsname
- */
+ /* Strip off any 'fsname.' portion. */
ptr = strchr(*pool_name, '.');
- if (ptr != NULL) {
- if (fsname != NULL) {
- int fslen = strlen(fsname);
-
- if (fslen != ptr - *pool_name ||
- strncmp(*pool_name, fsname, fslen) != 0)
- return false;
- }
+ if (ptr != NULL)
*pool_name = ptr + 1;
- }
if (strlen(*pool_name) > LOV_MAXPOOLNAME)
return false;
return true;
}
-
-int llapi_layout_search_ost(__u32 ost, const char *pname, char *fsname);
-
/* Compatibility macro for legacy llapi functions that use "offset"
* terminology instead of the preferred "index". */
#define llapi_stripe_offset_is_valid(os) llapi_stripe_index_is_valid(os)