local dir=$DIR/$tdir/dir
local temp=$DIR/$tdir/template
# We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
- local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
+ local large_count=$((LOV_MAX_STRIPE_COUNT / 2))
rm -rf $DIR/$tdir
test_mkdir $DIR/$tdir
# 3. PFL dir + overstriping
# set stripe for source dir
test_mkdir $dir
- $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
- error "setstripe $dir failed"
+ $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir || {
+ $LFS df -v $dir
+ $LFS df -i $dir
+ getfattr -d -m - -e hex $dir
+ error "setstripe -E2m -C $large_count -E-1 $dir failed"
+ }
test_mkdir $dir.copy
echo "3. PFL dir"
local temp=$3
local msg_prefix=$4
- echo "getstripe --yaml $src"
- $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
- echo "setstripe --yaml=$temp $dst"
- $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
-
- echo "compare"
- local layout1=$(get_layout_param $src)
- local layout2=$(get_layout_param $dst)
+ echo "$msg_prefix: getstripe --yaml $src"
+ $LFS getstripe --yaml $src > $temp ||
+ error "$msg_prefix: getstripe $src failed"
+ echo "$msg_prefix: setstripe --yaml=$temp $dst"
+ $LFS setstripe --yaml=$temp $dst || {
+ $LFS df -v $dst
+ $LFS df -i $dst
+ sed -e "s/^/$msg_prefix-yaml: /" $temp
+ getfattr -d -m - -e hex $src
+ getfattr -d -m - -e hex $dst
+ error "$msg_prefix: setstripe '$dst' failed"
+ }
+
+ echo "$msg_prefix: compare"
+ local layout_src=$(get_layout_param $src)
+ local layout_dst=$(get_layout_param $dst)
# compare their layout info
- [ "$layout1" == "$layout2" ] ||
- error "$msg_prefix $src/$dst layouts are not equal"
+ [ "$layout_src" == "$layout_dst" ] || {
+ sed -e "s/^/$msg_prefix-src: /" <<< $layout_src
+ sed -e "s/^/$msg_prefix-dst: /" <<< $layout_dst
+ error "$msg_prefix: $src/$dst layouts are not equal"
+ }
}
is_project_quota_supported() {
fd = llapi_layout_file_open(fname, open_flags, open_mode, layout);
if (fd < 0)
- fprintf(stderr, "%s: %s '%s': %s\n", progname,
- S_ISDIR(st.st_mode) ?
+ llapi_error(LLAPI_MSG_ERROR, errno, "%s: %s '%s'\n",
+ progname, S_ISDIR(st.st_mode) ?
"cannot set default composite layout for" :
- "cannot create composite file",
- fname, strerror(errno));
+ "cannot create composite file", fname);
return fd;
}
int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
const struct llapi_layout *layout)
{
- int fd;
- int rc;
- int tmp;
- struct lov_user_md *lum;
+ struct lov_user_md *lum = NULL;
size_t lum_size;
char fsname[MAX_OBD_NAME + 1] = { 0 };
struct llapi_layout_comp *comp;
+ int fd;
+ int rc;
comp = __llapi_layout_cur_comp(layout);
}
}
- /* Object creation must be postponed until after layout attributes
- * have been applied. */
- if (layout != NULL && (open_flags & O_CREAT))
- open_flags |= O_LOV_DELAY_CREATE;
+ if (layout) {
+ lum = llapi_layout_to_lum(layout);
+ if (!lum) {
+ fd = -1;
+ goto out_errno;
+ }
+
+ /* Object creation must be postponed until after layout
+ * attributes have been applied.
+ */
+ if (open_flags & O_CREAT)
+ open_flags |= O_LOV_DELAY_CREATE;
+ }
fd = open(path, open_flags, mode);
if (layout == NULL || fd < 0)
- return fd;
-
- lum = llapi_layout_to_lum(layout);
-
- if (lum == NULL) {
- tmp = errno;
- close(fd);
- errno = tmp;
- return -1;
- }
+ goto out_free;
if (lum->lmm_magic == LOV_USER_MAGIC_COMP_V1)
lum_size = ((struct lov_comp_md_v1 *)lum)->lcm_size;
rc = fsetxattr(fd, XATTR_LUSTRE_LOV, lum, lum_size, 0);
if (rc < 0) {
- tmp = errno;
+ int tmp = errno;
+
+ /* caller usually prints error, but doesn't know xattr size */
+ if (errno == ENOSPC)
+ llapi_error(LLAPI_MSG_ERROR, errno,
+ "error setting %zd-byte layout on '%s'\n",
+ lum_size, path);
close(fd);
errno = tmp;
fd = -1;
}
+out_free:
free(lum);
- errno = errno == EOPNOTSUPP ? ENOTTY : errno;
+out_errno:
+ if (errno == EOPNOTSUPP)
+ errno = ENOTTY;
return fd;
}