if (file_offset & ~PAGE_MASK)
unaligned = true;
- if (count & ~PAGE_MASK)
+ if ((file_offset + count < i_size_read(inode)) && (count & ~PAGE_MASK))
unaligned = true;
/* Check that all user buffers are aligned as well */
LASSERT(io != NULL);
CDEBUG(D_VFSTRACE,
- "VFS Op:inode="DFID"(%p), size=%zd (max %lu), offset=%lld=%llx, pages %zd (max %lu)%s%s%s%s\n",
+ "VFS Op:inode="DFID"(%p), size=%zd (max %lu), offset=%lld=%#llx, pages %zd (max %lu)%s%s%s%s\n",
PFID(ll_inode2fid(inode)), inode, count, MAX_DIO_SIZE,
file_offset, file_offset,
(count >> PAGE_SHIFT) + !!(count & ~PAGE_MASK),
rc = ftruncate(fd_dst, pos);
if (rc < 0) {
rc = -errno;
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "fail to ftruncate dst file to %ld", pos);
free(buf);
return rc;
}
/* hole at the end of file, truncate up to it */
if (!data_size) {
rc = ftruncate(fd_dst, data_off);
- if (rc < 0)
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "fail to ftruncate dst file to %ld",
+ data_off);
goto out;
+ }
}
pos = data_off & ~(page_size - 1);
data_end = data_off + data_size;
if (check_file) {
rc = check_file(fd_src);
- if (rc < 0)
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error checking src file");
goto out;
+ }
}
rsize = pread(fd_src, buf, to_read, pos);
read_bytes += rsize;
if (rsize < 0) {
rc = -errno;
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error reading src bytes %ld-%ld",
+ pos, to_read);
goto out;
}
/* EOF */
written = pwrite(fd_dst, buf, to_write, pos);
if (written < 0) {
rc = -errno;
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error writing dst bytes %ld-%ld",
+ pos, to_write);
goto out;
}
pos += written;
if (rc < 0) {
if (stats_interval_sec)
- fprintf(stderr,
- "error %s: delay for bandwidth control failed: %s\n",
- progname,
- strerror(-rc));
+ llapi_error(LLAPI_MSG_WARN, rc,
+ "delay for bandwidth control failed");
rc = 0;
}
}
}
rc = fsync(fd_dst);
- if (rc < 0)
+ if (rc < 0) {
rc = -errno;
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "failed to fsync dst file");
+ }
out:
/* Try to avoid page cache pollution after migration. */
(void)posix_fadvise(fd_src, 0, 0, POSIX_FADV_DONTNEED);
start, end, stats_interval_sec,
bandwidth_bytes_sec);
if (rc < 0)
- fprintf(stderr, "%s: '%s' llapi_mirror_resync_many: %s.\n",
- progname, fname, strerror(-rc));
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "fail to mirror resync '%s'\n", fname);
rc2 = migrate_set_timestamps(fd, &stbuf);
if (rc2 < 0) {
if (pos & (page_size - 1)) {
rc = llapi_mirror_truncate(fd, mirror_id, pos);
- if (rc < 0)
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "fail to trucate mirror %u of file '%s' to %ld",
+ mirror_id, fname, pos);
goto free_buf;
+ }
}
ioc.lil_mode = LL_LEASE_UNLCK;
if (bytes_read < 0) {
result = -errno;
+ llapi_error(LLAPI_MSG_WARN, result,
+ "fail to pread %ld-%ld of mirror %u",
+ pos, count, id);
break;
}
bytes_written = pwrite(fd, buf, count, pos);
if (bytes_written < 0) {
result = -errno;
+ llapi_error(LLAPI_MSG_WARN, result,
+ "fail to pwrite %ld-%ld of mirror %u",
+ pos, count, id);
break;
}
return rc;
rc = ftruncate(fd, length);
- if (rc < 0)
+ if (rc < 0) {
rc = -errno;
+ llapi_error(LLAPI_MSG_WARN, rc,
+ "fail to ftruncate mirror %u to %ld", id, length);
+ }
(void) llapi_mirror_clear(fd);
} else if (bytes_read < 0) {
result = bytes_read;
nr = 0;
+ llapi_error(LLAPI_MSG_ERROR, result,
+ "error reading bytes %ld-%ld of mirror %u",
+ pos, to_read, src);
break;
}
break;
} else if (bytes_read < 0) {
result = bytes_read;
+ llapi_error(LLAPI_MSG_ERROR, result,
+ "error reading bytes %ld-%ld of mirror %u",
+ pos, to_read, src);
break;
}
pos);
if (bytes_written < 0) {
result = bytes_written;
+ llapi_error(LLAPI_MSG_ERROR, result,
+ "error writing bytes %ld-%ld of mirror %u",
+ pos, to_write, dst);
break;
}
if (result > 0 && pos & (page_size - 1)) {
rc = llapi_mirror_truncate(fd, dst, pos);
- if (rc < 0)
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, result,
+ "error truncating mirror %u to %ld",
+ dst, pos);
result = rc;
+ }
}
return result;