Clean-up: apply clang-format to the newly added fd-tracker
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Nov 2019 21:33:22 +0000 (16:33 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 Dec 2019 21:29:31 +0000 (16:29 -0500)
The fd-tracker code was just merged but clang-format found some
changes to apply. Since there is no need to backport to this code
yet, clean it up as much as possible now.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia0bec41e0531c9f5d611d742e96a984de3f06784

src/common/fd-tracker/fd-tracker.c
src/common/fd-tracker/fd-tracker.h
src/common/fd-tracker/inode.c
src/common/fd-tracker/inode.h
src/common/fd-tracker/utils-epoll.c
src/common/fd-tracker/utils-poll.c
src/common/fd-tracker/utils.c
src/common/fd-tracker/utils.h

index 555ff4a780a8166c47b7a21efb8ab6cf5d416a57..65cbba99c0579378a2f89192f2cf2096c267f7b8 100644 (file)
 #include <urcu/list.h>
 #include <urcu/rculfhash.h>
 
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <fcntl.h>
-#include <stdbool.h>
-#include <pthread.h>
 #include <inttypes.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
-#include "common/macros.h"
-#include "common/error.h"
 #include "common/defaults.h"
-#include "common/hashtable/utils.h"
+#include "common/error.h"
 #include "common/hashtable/hashtable.h"
+#include "common/hashtable/utils.h"
+#include "common/macros.h"
 
 #include "fd-tracker.h"
 #include "inode.h"
 
 /* Tracker lock must be taken by the user. */
-#define TRACKED_COUNT(tracker)                 \
-       (tracker->count.suspendable.active +   \
-       tracker->count.suspendable.suspended + \
-       tracker->count.unsuspendable)
+#define TRACKED_COUNT(tracker)                                 \
+       (tracker->count.suspendable.active +                   \
+                       tracker->count.suspendable.suspended + \
+                       tracker->count.unsuspendable)
 
 /* Tracker lock must be taken by the user. */
-#define ACTIVE_COUNT(tracker)                  \
-       (tracker->count.suspendable.active +   \
-       tracker->count.unsuspendable)
+#define ACTIVE_COUNT(tracker) \
+       (tracker->count.suspendable.active + tracker->count.unsuspendable)
 
 /* Tracker lock must be taken by the user. */
-#define SUSPENDED_COUNT(tracker)               \
-       (tracker->count.suspendable.suspended)
+#define SUSPENDED_COUNT(tracker) (tracker->count.suspendable.suspended)
 
 /* Tracker lock must be taken by the user. */
-#define SUSPENDABLE_COUNT(tracker)             \
-       (tracker->count.suspendable.active +   \
-       tracker->count.suspendable.suspended)
+#define SUSPENDABLE_COUNT(tracker)           \
+       (tracker->count.suspendable.active + \
+                       tracker->count.suspendable.suspended)
 
 /* Tracker lock must be taken by the user. */
-#define UNSUSPENDABLE_COUNT(tracker)           \
-       (tracker->count.unsuspendable)
+#define UNSUSPENDABLE_COUNT(tracker) (tracker->count.unsuspendable)
 
 struct fd_tracker {
        pthread_mutex_t lock;
        struct {
-               struct {
+               struct {
                        unsigned int active;
                        unsigned int suspended;
                } suspendable;
@@ -144,47 +141,44 @@ static struct {
 
 static int match_fd(struct cds_lfht_node *node, const void *key);
 static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry);
-static struct unsuspendable_fd *unsuspendable_fd_create(const char *name,
-               int fd);
-static int open_from_properties(const char *path,
-               struct open_properties *properties);
+static struct unsuspendable_fd *unsuspendable_fd_create(
+               const char *name, int fd);
+static int open_from_properties(
+               const char *path, struct open_properties *properties);
 
 static void fs_handle_log(struct fs_handle *handle);
 static int fs_handle_suspend(struct fs_handle *handle);
 static int fs_handle_restore(struct fs_handle *handle);
 
-static void fd_tracker_track(struct fd_tracker *tracker,
-               struct fs_handle *handle);
-static void fd_tracker_untrack(struct fd_tracker *tracker,
-               struct fs_handle *handle);
-static int fd_tracker_suspend_handles(struct fd_tracker *tracker,
-               unsigned int count);
-static int fd_tracker_restore_handle(struct fd_tracker *tracker,
-               struct fs_handle *handle);
+static void fd_tracker_track(
+               struct fd_tracker *tracker, struct fs_handle *handle);
+static void fd_tracker_untrack(
+               struct fd_tracker *tracker, struct fs_handle *handle);
+static int fd_tracker_suspend_handles(
+               struct fd_tracker *tracker, unsigned int count);
+static int fd_tracker_restore_handle(
+               struct fd_tracker *tracker, struct fs_handle *handle);
 
 /* Match function of the tracker's unsuspendable_fds hash table. */
-static
-int match_fd(struct cds_lfht_node *node, const void *key)
+static int match_fd(struct cds_lfht_node *node, const void *key)
 {
-       struct unsuspendable_fd *entry =
-               caa_container_of(node, struct unsuspendable_fd, tracker_node);
+       struct unsuspendable_fd *entry = caa_container_of(
+                       node, struct unsuspendable_fd, tracker_node);
 
-       return hash_match_key_ulong((void *) (unsigned long) entry->fd,
-                       (void *) key);
+       return hash_match_key_ulong(
+                       (void *) (unsigned long) entry->fd, (void *) key);
 }
 
-static
-void delete_unsuspendable_fd(struct rcu_head *head)
+static void delete_unsuspendable_fd(struct rcu_head *head)
 {
-       struct unsuspendable_fd *fd = caa_container_of(head,
-                       struct unsuspendable_fd, rcu_head);
+       struct unsuspendable_fd *fd = caa_container_of(
+                       head, struct unsuspendable_fd, rcu_head);
 
        free(fd->name);
        free(fd);
 }
 
-static
-void unsuspendable_fd_destroy(struct unsuspendable_fd *entry)
+static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry)
 {
        if (!entry) {
                return;
@@ -192,11 +186,10 @@ void unsuspendable_fd_destroy(struct unsuspendable_fd *entry)
        call_rcu(&entry->rcu_head, delete_unsuspendable_fd);
 }
 
-static
-struct unsuspendable_fd *unsuspendable_fd_create(const char *name, int fd)
+static struct unsuspendable_fd *unsuspendable_fd_create(
+               const char *name, int fd)
 {
-       struct unsuspendable_fd *entry =
-                       zmalloc(sizeof(*entry));
+       struct unsuspendable_fd *entry = zmalloc(sizeof(*entry));
 
        if (!entry) {
                goto error;
@@ -215,8 +208,7 @@ error:
        return NULL;
 }
 
-static
-void fs_handle_log(struct fs_handle *handle)
+static void fs_handle_log(struct fs_handle *handle)
 {
        const char *path;
 
@@ -224,9 +216,7 @@ void fs_handle_log(struct fs_handle *handle)
        path = lttng_inode_get_path(handle->inode);
 
        if (handle->fd >= 0) {
-               DBG_NO_LOC("    %s [active, fd %d%s]",
-                               path,
-                               handle->fd,
+               DBG_NO_LOC("    %s [active, fd %d%s]", path, handle->fd,
                                handle->in_use ? ", in use" : "");
        } else {
                DBG_NO_LOC("    %s [suspended]", path);
@@ -235,8 +225,7 @@ void fs_handle_log(struct fs_handle *handle)
 }
 
 /* Tracker lock must be held by the caller. */
-static
-int fs_handle_suspend(struct fs_handle *handle)
+static int fs_handle_suspend(struct fs_handle *handle)
 {
        int ret = 0;
        struct stat fs_stat;
@@ -253,7 +242,7 @@ int fs_handle_suspend(struct fs_handle *handle)
 
        ret = stat(path, &fs_stat);
        if (ret) {
-               PERROR("Filesystem handle to %s cannot be suspended as stat() failed",
+               PERROR("Filesystem handle to %s cannot be suspended as stat() failed",
                                path);
                ret = -errno;
                goto end;
@@ -267,7 +256,7 @@ int fs_handle_suspend(struct fs_handle *handle)
                goto end;
        }
 
-        handle->offset = lseek(handle->fd, 0, SEEK_CUR);
+       handle->offset = lseek(handle->fd, 0, SEEK_CUR);
        if (handle->offset == -1) {
                WARN("Filesystem handle to %s cannot be suspended as lseek() failed to sample its current position",
                                path);
@@ -277,7 +266,7 @@ int fs_handle_suspend(struct fs_handle *handle)
 
        ret = close(handle->fd);
        if (ret) {
-               PERROR("Filesystem handle to %s cannot be suspended as close() failed",
+               PERROR("Filesystem handle to %s cannot be suspended as close() failed",
                                path);
                ret = -errno;
                goto end;
@@ -294,18 +283,16 @@ end:
 }
 
 /* Caller must hold the tracker and handle's locks. */
-static
-int fs_handle_restore(struct fs_handle *handle)
+static int fs_handle_restore(struct fs_handle *handle)
 {
        int ret, fd = -1;
        const char *path = lttng_inode_get_path(handle->inode);
 
        assert(handle->fd == -1);
        assert(path);
-       ret = open_from_properties(path,
-                       &handle->properties);
+       ret = open_from_properties(path, &handle->properties);
        if (ret < 0) {
-               PERROR("Failed to restore filesystem handle to %s, open() failed",
+               PERROR("Failed to restore filesystem handle to %s, open() failed",
                                path);
                ret = -errno;
                goto end;
@@ -314,7 +301,7 @@ int fs_handle_restore(struct fs_handle *handle)
 
        ret = lseek(fd, handle->offset, SEEK_SET);
        if (ret < 0) {
-               PERROR("Failed to restore filesystem handle to %s, lseek() failed",
+               PERROR("Failed to restore filesystem handle to %s, lseek() failed",
                                path);
                ret = -errno;
                goto end;
@@ -331,8 +318,8 @@ end:
        return ret;
 }
 
-static
-int open_from_properties(const char *path, struct open_properties *properties)
+static int open_from_properties(
+               const char *path, struct open_properties *properties)
 {
        int ret;
 
@@ -343,8 +330,7 @@ int open_from_properties(const char *path, struct open_properties *properties)
         * thus it is ignored here.
         */
        if ((properties->flags & O_CREAT) && properties->mode.is_set) {
-               ret = open(path, properties->flags,
-                               properties->mode.value);
+               ret = open(path, properties->flags, properties->mode.value);
        } else {
                ret = open(path, properties->flags);
        }
@@ -425,11 +411,11 @@ void fd_tracker_log(struct fd_tracker *tracker)
        DBG_NO_LOC("    capacity:        %u", tracker->capacity);
 
        DBG_NO_LOC("  Tracked suspendable file descriptors");
-       cds_list_for_each_entry(handle, &tracker->active_handles,
-                       handles_list_node) {
+       cds_list_for_each_entry (
+                       handle, &tracker->active_handles, handles_list_node) {
                fs_handle_log(handle);
        }
-       cds_list_for_each_entry(handle, &tracker->suspended_handles,
+       cds_list_for_each_entry (handle, &tracker->suspended_handles,
                        handles_list_node) {
                fs_handle_log(handle);
        }
@@ -439,9 +425,10 @@ void fd_tracker_log(struct fd_tracker *tracker)
 
        DBG_NO_LOC("  Tracked unsuspendable file descriptors");
        rcu_read_lock();
-       cds_lfht_for_each_entry(tracker->unsuspendable_fds, &iter,
+       cds_lfht_for_each_entry (tracker->unsuspendable_fds, &iter,
                        unsuspendable_fd, tracker_node) {
-               DBG_NO_LOC("    %s [active, fd %d]", unsuspendable_fd->name ? : "Unnamed",
+               DBG_NO_LOC("    %s [active, fd %d]",
+                               unsuspendable_fd->name ?: "Unnamed",
                                unsuspendable_fd->fd);
        }
        rcu_read_unlock();
@@ -484,7 +471,9 @@ end:
 }
 
 struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
-               const char *path, int flags, mode_t *mode)
+               const char *path,
+               int flags,
+               mode_t *mode)
 {
        int ret;
        struct fs_handle *handle = NULL;
@@ -534,11 +523,10 @@ struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
 
        handle->properties = properties;
 
-       handle->inode = lttng_inode_registry_get_inode(tracker->inode_registry,
-                       handle->fd, path);
+       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);
+               ERR("Failed to get lttng_inode corresponding to file %s", path);
                goto error;
        }
 
@@ -564,14 +552,13 @@ error_mutex_init:
 }
 
 /* Caller must hold the tracker's lock. */
-static
-int fd_tracker_suspend_handles(struct fd_tracker *tracker,
-               unsigned int count)
+static int fd_tracker_suspend_handles(
+               struct fd_tracker *tracker, unsigned int count)
 {
        unsigned int left_to_close = count;
        struct fs_handle *handle, *tmp;
 
-       cds_list_for_each_entry_safe(handle, tmp, &tracker->active_handles,
+       cds_list_for_each_entry_safe (handle, tmp, &tracker->active_handles,
                        handles_list_node) {
                int ret;
 
@@ -590,8 +577,11 @@ int fd_tracker_suspend_handles(struct fd_tracker *tracker,
 }
 
 int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
-               int *out_fds, const char **names, unsigned int fd_count,
-               fd_open_cb open, void *user_data)
+               int *out_fds,
+               const char **names,
+               unsigned int fd_count,
+               fd_open_cb open,
+               void *user_data)
 {
        int ret, user_ret, i, fds_to_suspend;
        unsigned int active_fds;
@@ -602,10 +592,12 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
        pthread_mutex_lock(&tracker->lock);
 
        active_fds = ACTIVE_COUNT(tracker);
-       fds_to_suspend = (int) active_fds + (int) fd_count - (int) tracker->capacity;
+       fds_to_suspend = (int) active_fds + (int) fd_count -
+                       (int) tracker->capacity;
        if (fds_to_suspend > 0) {
                if (fds_to_suspend <= tracker->count.suspendable.active) {
-                       ret = fd_tracker_suspend_handles(tracker, fds_to_suspend);
+                       ret = fd_tracker_suspend_handles(
+                                       tracker, fds_to_suspend);
                        if (ret) {
                                goto end;
                        }
@@ -633,9 +625,8 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
         * of unsuspendable fds.
         */
        for (i = 0; i < fd_count; i++) {
-               struct unsuspendable_fd *entry =
-                               unsuspendable_fd_create(names ? names[i] : NULL,
-                                               out_fds[i]);
+               struct unsuspendable_fd *entry = unsuspendable_fd_create(
+                               names ? names[i] : NULL, out_fds[i]);
 
                if (!entry) {
                        ret = -1;
@@ -649,12 +640,11 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
                struct cds_lfht_node *node;
                struct unsuspendable_fd *entry = entries[i];
 
-               node = cds_lfht_add_unique(
-                               tracker->unsuspendable_fds,
-                               hash_key_ulong((void *) (unsigned long) out_fds[i],
+               node = cds_lfht_add_unique(tracker->unsuspendable_fds,
+                               hash_key_ulong((void *) (unsigned long)
+                                                               out_fds[i],
                                                seed.value),
-                               match_fd,
-                               (void *) (unsigned long) out_fds[i],
+                               match_fd, (void *) (unsigned long) out_fds[i],
                                &entry->tracker_node);
 
                if (node != &entry->tracker_node) {
@@ -678,7 +668,9 @@ end_free_entries:
 }
 
 int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
-               int *fds_in, unsigned int fd_count, fd_close_cb close,
+               int *fds_in,
+               unsigned int fd_count,
+               fd_close_cb close,
                void *user_data)
 {
        int i, ret, user_ret;
@@ -709,8 +701,7 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
                cds_lfht_lookup(tracker->unsuspendable_fds,
                                hash_key_ulong((void *) (unsigned long) fds[i],
                                                seed.value),
-                               match_fd,
-                               (void *) (unsigned long) fds[i],
+                               match_fd, (void *) (unsigned long) fds[i],
                                &iter);
                node = cds_lfht_iter_get_node(&iter);
                if (!node) {
@@ -720,9 +711,8 @@ int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
                        ret = -EINVAL;
                        goto end;
                }
-               entry = caa_container_of(node,
-                               struct unsuspendable_fd,
-                               tracker_node);
+               entry = caa_container_of(
+                               node, struct unsuspendable_fd, tracker_node);
 
                cds_lfht_del(tracker->unsuspendable_fds, node);
                unsuspendable_fd_destroy(entry);
@@ -738,8 +728,8 @@ end:
 }
 
 /* Caller must have taken the tracker's and handle's locks. */
-static
-void fd_tracker_track(struct fd_tracker *tracker, struct fs_handle *handle)
+static void fd_tracker_track(
+               struct fd_tracker *tracker, struct fs_handle *handle)
 {
        if (handle->fd >= 0) {
                tracker->count.suspendable.active++;
@@ -753,8 +743,8 @@ void fd_tracker_track(struct fd_tracker *tracker, struct fs_handle *handle)
 }
 
 /* Caller must have taken the tracker's and handle's locks. */
-static
-void fd_tracker_untrack(struct fd_tracker *tracker, struct fs_handle *handle)
+static void fd_tracker_untrack(
+               struct fd_tracker *tracker, struct fs_handle *handle)
 {
        if (handle->fd >= 0) {
                tracker->count.suspendable.active--;
@@ -765,9 +755,8 @@ void fd_tracker_untrack(struct fd_tracker *tracker, struct fs_handle *handle)
 }
 
 /* Caller must have taken the tracker's and handle's locks. */
-static
-int fd_tracker_restore_handle(struct fd_tracker *tracker,
-               struct fs_handle *handle)
+static int fd_tracker_restore_handle(
+               struct fd_tracker *tracker, struct fs_handle *handle)
 {
        int ret;
 
index b8082c9a7697f51eb9b2c7d30e3ef94610f6d450..d321181ae9f2a3a9f40189944b3bfaae6cfcbde1 100644 (file)
@@ -81,7 +81,9 @@ int fd_tracker_destroy(struct fd_tracker *tracker);
  * open.
  */
 struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
-               const char *path, int flags, mode_t *mode);
+               const char *path,
+               int flags,
+               mode_t *mode);
 
 /*
  * Open a tracked unsuspendable file descriptor.
@@ -106,8 +108,11 @@ struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
  *             accomodate the request for a new unsuspendable entry.
  */
 int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
-               int *out_fds, const char **names, unsigned int fd_count,
-               fd_open_cb open, void *data);
+               int *out_fds,
+               const char **names,
+               unsigned int fd_count,
+               fd_open_cb open,
+               void *data);
 
 /*
  * Close a tracked unsuspendable file descriptor.
@@ -125,7 +130,9 @@ int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
  * allows the user to know which file descriptors are no longer being tracked.
  */
 int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
-               int *fds, unsigned int fd_count, fd_close_cb close,
+               int *fds,
+               unsigned int fd_count,
+               fd_close_cb close,
                void *data);
 
 /*
index f02f0a812d67d516df48c7702b72f42f1be35ddb..2eab2d61546a1f53c00a1bfa9679f961fe34cfd0 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <sys/types.h>
+#include <common/defaults.h>
+#include <common/error.h>
+#include <common/hashtable/utils.h>
+#include <common/macros.h>
+#include <inttypes.h>
+#include <lttng/constant.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <inttypes.h>
 #include <urcu.h>
-#include <urcu/ref.h>
 #include <urcu/rculfhash.h>
-#include <common/hashtable/utils.h>
-#include <common/macros.h>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <lttng/constant.h>
+#include <urcu/ref.h>
 
 #include "inode.h"
 
@@ -57,40 +57,36 @@ static struct {
        bool initialized;
        unsigned long value;
 } seed = {
-       .lock = PTHREAD_MUTEX_INITIALIZER,
+               .lock = PTHREAD_MUTEX_INITIALIZER,
 };
 
-static
-unsigned long lttng_inode_id_hash(struct inode_id *id)
+static unsigned long lttng_inode_id_hash(struct inode_id *id)
 {
        uint64_t device = id->device, inode_no = id->inode;
 
-        return hash_key_u64(&device, seed.value) ^
-                       hash_key_u64(&inode_no, seed.value);
+       return hash_key_u64(&device, seed.value) ^
+              hash_key_u64(&inode_no, seed.value);
 }
 
-static
-int lttng_inode_match(struct cds_lfht_node *node, const void *key)
+static int lttng_inode_match(struct cds_lfht_node *node, const void *key)
 {
        const struct inode_id *id = key;
-       struct lttng_inode *inode = caa_container_of(node, struct lttng_inode,
-                       registry_node);
+       struct lttng_inode *inode = caa_container_of(
+                       node, struct lttng_inode, registry_node);
 
        return inode->id.device == id->device && inode->id.inode == id->inode;
 }
 
-static
-void lttng_inode_delete(struct rcu_head *head)
+static void lttng_inode_delete(struct rcu_head *head)
 {
-       struct lttng_inode *inode = caa_container_of(head,
-                       struct lttng_inode, rcu_head);
+       struct lttng_inode *inode =
+                       caa_container_of(head, struct lttng_inode, rcu_head);
 
        free(inode->path);
        free(inode);
 }
 
-static
-void lttng_inode_destroy(struct lttng_inode *inode)
+static void lttng_inode_destroy(struct lttng_inode *inode)
 {
        if (!inode) {
                return;
@@ -109,14 +105,12 @@ void lttng_inode_destroy(struct lttng_inode *inode)
        call_rcu(&inode->rcu_head, lttng_inode_delete);
 }
 
-static
-void lttng_inode_release(struct urcu_ref *ref)
+static void lttng_inode_release(struct urcu_ref *ref)
 {
-        lttng_inode_destroy(caa_container_of(ref, struct lttng_inode, ref));
+       lttng_inode_destroy(caa_container_of(ref, struct lttng_inode, ref));
 }
 
-static
-void lttng_inode_get(struct lttng_inode *inode)
+static void lttng_inode_get(struct lttng_inode *inode)
 {
        urcu_ref_get(&inode->ref);
 }
@@ -131,8 +125,8 @@ const char *lttng_inode_get_path(const struct lttng_inode *inode)
        return inode->path;
 }
 
-int lttng_inode_rename(struct lttng_inode *inode, const char *new_path,
-       bool overwrite)
+int lttng_inode_rename(
+               struct lttng_inode *inode, const char *new_path, bool overwrite)
 {
        int ret = 0;
        char *new_path_copy = NULL;
@@ -205,7 +199,8 @@ int lttng_inode_defer_unlink(struct lttng_inode *inode)
                int p_ret;
 
                if (i != 0) {
-                       p_ret = snprintf(suffix, sizeof(suffix), "-deleted-%" PRIu16, i);
+                       p_ret = snprintf(suffix, sizeof(suffix),
+                                       "-deleted-%" PRIu16, i);
 
                        if (p_ret < 0) {
                                PERROR("Failed to form suffix to rename file %s",
@@ -238,9 +233,9 @@ end:
        return ret;
 }
 
-static
-struct lttng_inode *lttng_inode_create(const struct inode_id *id,
-               const char *path, struct cds_lfht *ht)
+static struct lttng_inode *lttng_inode_create(const struct inode_id *id,
+               const char *path,
+               struct cds_lfht *ht)
 {
        struct lttng_inode *inode = zmalloc(sizeof(*inode));
 
@@ -304,8 +299,7 @@ void lttng_inode_registry_destroy(struct lttng_inode_registry *registry)
 }
 
 struct lttng_inode *lttng_inode_registry_get_inode(
-               struct lttng_inode_registry *registry,
-               int fd, const char *path)
+               struct lttng_inode_registry *registry, int fd, const char *path)
 {
        int ret;
        struct stat statbuf;
@@ -324,14 +318,12 @@ struct lttng_inode *lttng_inode_registry_get_inode(
        id.inode = statbuf.st_ino;
 
        rcu_read_lock();
-       cds_lfht_lookup(registry->inodes,
-                       lttng_inode_id_hash(&id),
-                       lttng_inode_match,
-                       &id,
-                       &iter);
+       cds_lfht_lookup(registry->inodes, lttng_inode_id_hash(&id),
+                       lttng_inode_match, &id, &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (node) {
-               inode = caa_container_of(node, struct lttng_inode, registry_node);
+               inode = caa_container_of(
+                               node, struct lttng_inode, registry_node);
                /* Renames should happen through the fs-handle interface. */
                assert(!strcmp(path, inode->path));
                lttng_inode_get(inode);
@@ -340,10 +332,8 @@ struct lttng_inode *lttng_inode_registry_get_inode(
 
        inode = lttng_inode_create(&id, path, registry->inodes);
        node = cds_lfht_add_unique(registry->inodes,
-                       lttng_inode_id_hash(&inode->id),
-                       lttng_inode_match,
-                       &inode->id,
-                       &inode->registry_node);
+                       lttng_inode_id_hash(&inode->id), lttng_inode_match,
+                       &inode->id, &inode->registry_node);
        assert(node == &inode->registry_node);
 end_unlock:
        rcu_read_unlock();
index 6c2406dc61a91f744284cec3edc9ed1170325fc1..41e947011f2a0c189658ebf8da106c4facde718a 100644 (file)
@@ -27,13 +27,15 @@ struct lttng_inode_registry;
 struct lttng_inode_registry *lttng_inode_registry_create(void);
 
 struct lttng_inode *lttng_inode_registry_get_inode(
-               struct lttng_inode_registry *registry, int fd,
+               struct lttng_inode_registry *registry,
+               int fd,
                const char *path);
 
 void lttng_inode_registry_destroy(struct lttng_inode_registry *registry);
 
 const char *lttng_inode_get_path(const struct lttng_inode *inode);
-int lttng_inode_rename(struct lttng_inode *inode, const char *new_path,
+int lttng_inode_rename(struct lttng_inode *inode,
+               const char *new_path,
                bool overwrite);
 int lttng_inode_defer_unlink(struct lttng_inode *inode);
 void lttng_inode_put(struct lttng_inode *inode);
index 3b387789ce25a43acce823e953728170d0baa081..3937ea8456e73c544ec900ad4edba2c8e9834338 100644 (file)
@@ -25,8 +25,7 @@ struct create_args {
        int flags;
 };
 
-static
-int open_epoll(void *data, int *out_fd)
+static int open_epoll(void *data, int *out_fd)
 {
        int ret;
        struct create_args *args = data;
@@ -41,8 +40,7 @@ end:
        return ret;
 }
 
-static
-int close_epoll(void *data, int *in_fd)
+static int close_epoll(void *data, int *in_fd)
 {
        /* Will close the epfd. */
        lttng_poll_clean((struct lttng_poll_event *) data);
@@ -53,8 +51,11 @@ int close_epoll(void *data, int *in_fd)
  * The epoll variant of the poll compat layer creates an unsuspendable fd which
  * must be tracked.
  */
-int fd_tracker_util_poll_create(struct fd_tracker *tracker, const char *name,
-               struct lttng_poll_event *events, int size, int flags)
+int fd_tracker_util_poll_create(struct fd_tracker *tracker,
+               const char *name,
+               struct lttng_poll_event *events,
+               int size,
+               int flags)
 {
        int out_fd;
        struct create_args create_args = {
@@ -63,13 +64,13 @@ int fd_tracker_util_poll_create(struct fd_tracker *tracker, const char *name,
                .flags = flags,
        };
 
-       return fd_tracker_open_unsuspendable_fd(tracker, &out_fd, &name, 1,
-                       open_epoll, &create_args);
+       return fd_tracker_open_unsuspendable_fd(
+                       tracker, &out_fd, &name, 1, open_epoll, &create_args);
 }
 
-int fd_tracker_util_poll_clean(struct fd_tracker *tracker,
-               struct lttng_poll_event *events)
+int fd_tracker_util_poll_clean(
+               struct fd_tracker *tracker, struct lttng_poll_event *events)
 {
-       return fd_tracker_close_unsuspendable_fd(tracker, &events->epfd, 1,
-                       close_epoll, events);
+       return fd_tracker_close_unsuspendable_fd(
+                       tracker, &events->epfd, 1, close_epoll, events);
 }
index b56936a0f54a7c4df614d4dc13aaa693cfd787d1..ebe15ede657db4b12fa21bb616df16af606e5de5 100644 (file)
  * The epoll variant of the poll compat layer creates an unsuspendable fd which
  * must be tracked.
  */
-int fd_tracker_util_poll_create(struct fd_tracker *tracker, const char *name,
-               struct lttng_poll_event *events, int size, int flags)
+int fd_tracker_util_poll_create(struct fd_tracker *tracker,
+               const char *name,
+               struct lttng_poll_event *events,
+               int size,
+               int flags)
 {
        return lttng_poll_create(events, size, flags);
 }
 
-int fd_tracker_util_poll_clean(struct fd_tracker *tracker,
-               struct lttng_poll_event *events)
+int fd_tracker_util_poll_clean(
+               struct fd_tracker *tracker, struct lttng_poll_event *events)
 {
        lttng_poll_clean(events);
        return 0;
index 21ca6752deb3875aa656d6dd2bab605172364672..b3df040c2088b22fce9d5cd10b3b05f8dfc02634 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <common/fd-tracker/utils.h>
 #include <common/utils.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 
-static
-int open_pipe_cloexec(void *data, int *fds)
+static int open_pipe_cloexec(void *data, int *fds)
 {
        return utils_create_pipe_cloexec(fds);
 }
 
-static
-int close_pipe(void *data, int *pipe)
+static int close_pipe(void *data, int *pipe)
 {
        utils_close_pipe(pipe);
        pipe[0] = pipe[1] = -1;
@@ -40,8 +38,8 @@ int fd_tracker_util_close_fd(void *unused, int *fd)
        return close(*fd);
 }
 
-int fd_tracker_util_pipe_open_cloexec(struct fd_tracker *tracker,
-               const char *name, int *pipe)
+int fd_tracker_util_pipe_open_cloexec(
+               struct fd_tracker *tracker, const char *name, int *pipe)
 {
        int ret;
        const char *name_prefix;
@@ -57,7 +55,7 @@ int fd_tracker_util_pipe_open_cloexec(struct fd_tracker *tracker,
                goto end;
        }
 
-        ret = fd_tracker_open_unsuspendable_fd(tracker, pipe,
+       ret = fd_tracker_open_unsuspendable_fd(tracker, pipe,
                        (const char **) names, 2, open_pipe_cloexec, NULL);
        free(names[0]);
        free(names[1]);
@@ -67,6 +65,6 @@ end:
 
 int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe)
 {
-        return fd_tracker_close_unsuspendable_fd(tracker,
-                       pipe, 2, close_pipe, NULL);
+       return fd_tracker_close_unsuspendable_fd(
+                       tracker, pipe, 2, close_pipe, NULL);
 }
index e250f4af02212a0fd804c4c3880255e42c36da68..1a7aad9f6074217f1c3030164ffc6e3b428f05ec 100644 (file)
@@ -31,16 +31,19 @@ int fd_tracker_util_close_fd(void *, int *fd);
 /*
  * Create a pipe and track its underlying fds.
  */
-int fd_tracker_util_pipe_open_cloexec(struct fd_tracker *tracker,
-               const char *name, int *pipe);
+int fd_tracker_util_pipe_open_cloexec(
+               struct fd_tracker *tracker, const char *name, int *pipe);
 int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe);
 
 /*
  * Create a poll event and track its underlying fd, if applicable.
  */
-int fd_tracker_util_poll_create(struct fd_tracker *tracker, const char *name,
-               struct lttng_poll_event *events, int size, int flags);
-int fd_tracker_util_poll_clean(struct fd_tracker *tracker,
-               struct lttng_poll_event *events);
+int fd_tracker_util_poll_create(struct fd_tracker *tracker,
+               const char *name,
+               struct lttng_poll_event *events,
+               int size,
+               int flags);
+int fd_tracker_util_poll_clean(
+               struct fd_tracker *tracker, struct lttng_poll_event *events);
 
 #endif /* FD_TRACKER_UTILS_H */
This page took 0.038936 seconds and 4 git commands to generate.