X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=libringbuffer%2Fshm.c;fp=libringbuffer%2Fshm.c;h=8ac321e3931906888f79dd9e2419a7dbca8225de;hb=429dadf0e28fe24be158ddb76d09f5f2308b6467;hp=c4c651e4b925543e373e9b016398636be4c03293;hpb=d742d2aadf357e5256a0d06196dbffcbf80294b2;p=lttng-ust.git diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index c4c651e4..8ac321e3 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -39,6 +39,9 @@ * 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) @@ -67,6 +70,11 @@ 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);