summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0a92632)
Clean up the error handling in llapi_file_create_foreign() to always
set errno, and avoid printing a duplicate error message when run on
a non-Lustre filesystem.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I610748f5d07566fb81c2f0b6f59507e97e03158f
Reviewed-on: https://review.whamcloud.com/35093
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
int fd, rc;
if (foreign_lov == NULL) {
int fd, rc;
if (foreign_lov == NULL) {
- llapi_error(LLAPI_MSG_ERROR, -EINVAL,
+ rc = -EINVAL;
+ llapi_error(LLAPI_MSG_ERROR, rc,
"foreign LOV EA content must be provided");
"foreign LOV EA content must be provided");
}
len = strlen(foreign_lov);
if (len > XATTR_SIZE_MAX - offsetof(struct lov_foreign_md, lfm_value) ||
len <= 0) {
}
len = strlen(foreign_lov);
if (len > XATTR_SIZE_MAX - offsetof(struct lov_foreign_md, lfm_value) ||
len <= 0) {
- llapi_error(LLAPI_MSG_ERROR, -EINVAL,
+ rc = -EINVAL;
+ llapi_error(LLAPI_MSG_ERROR, rc,
"foreign LOV EA size %zu (must be 0 < len < %zu)",
len, XATTR_SIZE_MAX -
offsetof(struct lov_foreign_md, lfm_value));
"foreign LOV EA size %zu (must be 0 < len < %zu)",
len, XATTR_SIZE_MAX -
offsetof(struct lov_foreign_md, lfm_value));
}
lfm = malloc(len + offsetof(struct lov_foreign_md, lfm_value));
if (lfm == NULL) {
}
lfm = malloc(len + offsetof(struct lov_foreign_md, lfm_value));
if (lfm == NULL) {
- llapi_error(LLAPI_MSG_ERROR, -ENOMEM,
+ rc = -ENOMEM;
+ llapi_error(LLAPI_MSG_ERROR, rc,
"failed to allocate lov_foreign_md");
"failed to allocate lov_foreign_md");
}
fd = open(name, O_WRONLY|O_CREAT|O_LOV_DELAY_CREATE, mode);
if (fd == -1) {
}
fd = open(name, O_WRONLY|O_CREAT|O_LOV_DELAY_CREATE, mode);
if (fd == -1) {
- perror("open()");
- rc = -errno;
+ fd = -errno;
+ llapi_error(LLAPI_MSG_ERROR, fd, "open '%s' failed", name);
if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, lfm) != 0) {
char *errmsg = "stripe already set";
if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, lfm) != 0) {
char *errmsg = "stripe already set";
- char fsname[MAX_OBD_NAME + 1] = { 0 };
- if (errno != EEXIST && errno != EALREADY)
+ if (errno == ENOTTY)
+ errmsg = "not on a Lustre filesystem";
+ else if (errno == EEXIST || errno == EALREADY)
+ errmsg = "stripe already set";
+ else
errmsg = strerror(errno);
llapi_err_noerrno(LLAPI_MSG_ERROR,
"setstripe error for '%s': %s", name, errmsg);
errmsg = strerror(errno);
llapi_err_noerrno(LLAPI_MSG_ERROR,
"setstripe error for '%s': %s", name, errmsg);
- /* Make sure we are on a Lustre file system */
- if (rc == -ENOTTY && llapi_search_fsname(name, fsname))
- llapi_error(LLAPI_MSG_ERROR, rc,
- "'%s' is not on a Lustre filesystem",
- name);
-
+
+out_err:
+ errno = -rc;
+ return rc;
}
int llapi_file_create(const char *name, unsigned long long stripe_size,
}
int llapi_file_create(const char *name, unsigned long long stripe_size,