X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libringbuffer%2Fshm.c;h=ea946ea3f5e2a6d2e46d3297ebe925135164272e;hb=ef85ac6076286f47870f7408d4a49b3d13e32468;hp=8ac321e3931906888f79dd9e2419a7dbca8225de;hpb=1e88ac269f04995e989f7fda1eb93e0c7f2ed600;p=lttng-ust.git diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index 8ac321e3..ea946ea3 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -39,9 +39,6 @@ * Ensure we have the required amount of space available by writing 0 * into the entire buffer. Not doing so can trigger SIGBUS when going * beyond the available shm space. - * - * Also ensure the file metadata is synced with the storage by using - * fsync(2). */ static int zero_file(int fd, size_t len) @@ -70,11 +67,6 @@ int zero_file(int fd, size_t len) } written += retlen; } - ret = fsync(fd); - if (ret) { - ret = (int) -errno; - goto error; - } ret = 0; error: free(zeropage); @@ -142,6 +134,15 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table, PERROR("ftruncate"); goto error_ftruncate; } + /* + * Also ensure the file metadata is synced with the storage by using + * fsync(2). + */ + ret = fsync(shmfd); + if (ret) { + PERROR("fsync"); + goto error_fsync; + } obj->shm_fd_ownership = 0; obj->shm_fd = shmfd; @@ -161,6 +162,7 @@ struct shm_object *_shm_object_table_alloc_shm(struct shm_object_table *table, return obj; error_mmap: +error_fsync: error_ftruncate: error_zero_file: error_fcntl: