Upstream status pending on fd-tracker merge
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
DBG("Unlinking index at %s through a filesystem handle", path);
handle = fd_tracker_open_fs_handle(the_fd_tracker, path, flags, NULL);
if (!handle) {
DBG("Unlinking index at %s through a filesystem handle", path);
handle = fd_tracker_open_fs_handle(the_fd_tracker, path, flags, NULL);
if (!handle) {
- /* There is nothing to do. */
- DBG("File %s does not exist, ignoring unlink", path);
+ if (errno == ENOENT) {
+ DBG("File %s does not exist, ignoring unlink", path);
+ }
fs_handle = fd_tracker_open_fs_handle(the_fd_tracker, idx_file_path,
flags, &mode);
if (!fs_handle) {
fs_handle = fd_tracker_open_fs_handle(the_fd_tracker, idx_file_path,
flags, &mode);
if (!fs_handle) {
+ PERROR("Failed to open index file at %s", idx_file_path);
goto error;
}
index_file->handle = fs_handle;
fd = fs_handle_get_fd(fs_handle);
if (fd < 0) {
goto error;
}
index_file->handle = fs_handle;
fd = fs_handle_get_fd(fs_handle);
if (fd < 0) {
+ PERROR("Failed to get fd of index file at %s", idx_file_path);
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
+ PERROR("Failed to get fd from handle");
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
+ PERROR("Failed to get fd of handle %p", index_file->handle);
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
fd = fs_handle_get_fd(index_file->handle);
if (fd < 0) {
+ PERROR("Failed to get fd of handle %p", index_file->handle);
ret = open_from_properties(path,
&handle->properties);
if (ret < 0) {
ret = open_from_properties(path,
&handle->properties);
if (ret < 0) {
PERROR("Failed to restore filesystem handle to %s, open() failed",
path);
PERROR("Failed to restore filesystem handle to %s, open() failed",
path);
+/*
+ * If return NULL check errno for error.
+ */
struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
const char *path, int flags, mode_t *mode)
{
struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
const char *path, int flags, mode_t *mode)
{
struct fs_handle *handle = NULL;
struct stat fd_stat;
struct open_properties properties = {
struct fs_handle *handle = NULL;
struct stat fd_stat;
struct open_properties properties = {
if (tracker->count.suspendable.active > 0) {
ret = fd_tracker_suspend_handles(tracker, 1);
if (ret) {
if (tracker->count.suspendable.active > 0) {
ret = fd_tracker_suspend_handles(tracker, 1);
if (ret) {
+ ERR("Suspend handled failed");
+ ret = EMFILE;
*/
WARN("Cannot open file system handle, too many unsuspendable file descriptors are opened (%u)",
tracker->count.unsuspendable);
*/
WARN("Cannot open file system handle, too many unsuspendable file descriptors are opened (%u)",
tracker->count.unsuspendable);
goto end;
}
}
handle = zmalloc(sizeof(*handle));
if (!handle) {
goto end;
}
}
handle = zmalloc(sizeof(*handle));
if (!handle) {
goto end;
}
handle->tracker = tracker;
goto end;
}
handle->tracker = tracker;
ret = pthread_mutex_init(&handle->lock, NULL);
if (ret) {
PERROR("Failed to initialize handle mutex while creating fs handle");
ret = pthread_mutex_init(&handle->lock, NULL);
if (ret) {
PERROR("Failed to initialize handle mutex while creating fs handle");
goto error_mutex_init;
}
handle->fd = open_from_properties(path, &properties);
if (handle->fd < 0) {
goto error_mutex_init;
}
handle->fd = open_from_properties(path, &properties);
if (handle->fd < 0) {
- PERROR("Failed to open fs handle to %s, open() returned", path);
+ /* ret contains -errno on error. */
+ ret = -ret;
handle->inode = lttng_inode_registry_get_inode(tracker->inode_registry,
handle->fd, path);
if (!handle->inode) {
handle->inode = lttng_inode_registry_get_inode(tracker->inode_registry,
handle->fd, path);
if (!handle->inode) {
ERR("Failed to get lttng_inode corresponding to file %s",
path);
goto error;
ERR("Failed to get lttng_inode corresponding to file %s",
path);
goto error;
if (fstat(handle->fd, &fd_stat)) {
PERROR("Failed to retrieve file descriptor inode while creating fs handle, fstat() returned");
if (fstat(handle->fd, &fd_stat)) {
PERROR("Failed to retrieve file descriptor inode while creating fs handle, fstat() returned");
goto error;
}
handle->ino = fd_stat.st_ino;
goto error;
}
handle->ino = fd_stat.st_ino;
fd_tracker_track(tracker, handle);
end:
pthread_mutex_unlock(&tracker->lock);
fd_tracker_track(tracker, handle);
end:
pthread_mutex_unlock(&tracker->lock);
return handle;
error:
if (handle->inode) {
return handle;
error:
if (handle->inode) {