Fix: truncate the metadata file in shm-path
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Liguang,
Good catch, thanks for the fix!
I have slightly modified the patch prior to merging it, read on.
Jérémie
Quoted 18 lines · Liguang Li
In the shm-path mode, the metadata will be backuped to a metadata file, when run the lttng command "lttng metadata regenerate" to resample the wall time following a major NTP correction, the metadata file will not be truncated and regenerated.
Add the function
ust_metadata_truncate()to truncate and regenerate the metadata file.Signed-off-by Liguang Li <[email protected]>--- src/bin/lttng-sessiond/cmd.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)src/bin/lttng-sessiond/cmd.c +0
-0
src/bin/lttng-sessiond/cmd.c end: · line 3381
Quoted 4 lines
src/bin/lttng-sessiond/cmd.c +1
-0@@ -3378,6 +3378,25 @@ end: }static +int ust_metadata_truncate (int fd,size_t length)
Changed the name of this function to clear_metadata_file(...) which only takes an "fd" as parameter. There are no other users of this utility yet, so I'm keeping it specific to its current use.
src/bin/lttng-sessiond/cmd.c end: · line 3385
Quoted 4 lines
src/bin/lttng-sessiond/cmd.c +4
-0+{ +int ret; + + ret =lseek (fd, length,SEEK_SET );
length replaced by 0
src/bin/lttng-sessiond/cmd.c end: · line 3391
Quoted 6 lines
src/bin/lttng-sessiond/cmd.c +6
-0+if (ret <0 ) { +PERROR ("lseek" ); + goto out; + } + + ret =ftruncate (fd, length);
length replaced by 0
src/bin/lttng-sessiond/cmd.c end: · line 3393
Quoted 2 lines
src/bin/lttng-sessiond/cmd.c +2
-0+if (ret <0 ) +PERROR ("ftruncate" );
We use curly-braces even on single-line conditionals in this codebase.
src/bin/lttng-sessiond/cmd.c end: · line 3395
Quoted 2 lines
src/bin/lttng-sessiond/cmd.c +2
-0+ +out:
Changed the "out" label to "end" to remain consistent with the rest of the code.
Quoted 30 lines
src/bin/lttng-sessiond/cmd.c +13
-1+return ret; +} + +static int ust_regenerate_metadata (struct ltt_ust_session *usess) {int ret =0 ;@@ -3398,6 +3417,15 @@ int ust_regenerate_metadata(struct ltt_ust_session *usess)memset (registry->metadata,0 , registry->metadata_alloc_len); registry->metadata_len =0 ; registry->metadata_version++; +/*truncate the metadata file*/ +if (registry->metadata_fd >0 ) { + ret =ust_metadata_truncate (registry->metadata_fd,0 ); +if (ret) { +pthread_mutex_unlock (®istry->lock); + goto end; + } + } + ret =ust_metadata_session_statedump (registry,NULL , registry->major, registry->minor);if (ret) { --2.7.4
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): CA+jJMxv_JgJou-Ppn_1+_HOi3SK1fQMJ0Q_cwO9YDJH2Er=58Q@mail.gmail.com
Hi Jérémie,
Thanks for your review, i agree with your modification.
Regards,
Liguang
Quoted 82 lines · Jérémie Galarneau
Hi Liguang,
Good catch, thanks for the fix!
I have slightly modified the patch prior to merging it, read on.Jérémie
Quoted 18 lines · Liguang Li
In the shm-path mode, the metadata will be backuped to a metadata file, when run the lttng command "lttng metadata regenerate" to resample the wall time following a major NTP correction, the metadata file will not be truncated and regenerated.
Add the function
ust_metadata_truncate()to truncate and regenerate the metadata file.Signed-off-by Liguang Li <[email protected]>--- src/bin/lttng-sessiond/cmd.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)src/bin/lttng-sessiond/cmd.c +0
-0src/bin/lttng-sessiond/cmd.c end: · line 3381
Quoted 4 lines
src/bin/lttng-sessiond/cmd.c +1
-0@@ -3378,6 +3378,25 @@ end: }static +int ust_metadata_truncate (int fd,size_t length)Changed the name of this function to
clear_metadata_file(...)which only takes an "fd" as parameter. There are no other users of this utility yet, so I'm keeping it specific to its current use.src/bin/lttng-sessiond/cmd.c end: · line 3385
Quoted 4 lines
src/bin/lttng-sessiond/cmd.c +4
-0+{ +int ret; + + ret =lseek (fd, length,SEEK_SET );length replaced by 0
src/bin/lttng-sessiond/cmd.c end: · line 3391
Quoted 6 lines
src/bin/lttng-sessiond/cmd.c +6
-0+if (ret <0 ) { +PERROR ("lseek" ); + goto out; + } + + ret =ftruncate (fd, length);length replaced by 0
src/bin/lttng-sessiond/cmd.c end: · line 3393
Quoted 2 lines
src/bin/lttng-sessiond/cmd.c +2
-0+if (ret <0 ) +PERROR ("ftruncate" );We use curly-braces even on single-line conditionals in this codebase.
src/bin/lttng-sessiond/cmd.c end: · line 3395
Quoted 2 lines
src/bin/lttng-sessiond/cmd.c +2
-0+ +out:Changed the "out" label to "end" to remain consistent with the rest of the code.
Quoted 26 lines
src/bin/lttng-sessiond/cmd.c +13
-1+return ret; +} + +static int ust_regenerate_metadata (struct ltt_ust_session *usess) {int ret =0 ;@@ -3398,6 +3417,15 @@ int ust_regenerate_metadata(struct ltt_ust_session *usess)memset (registry->metadata,0 , registry->metadata_alloc_len); registry->metadata_len =0 ; registry->metadata_version++; +/*truncate the metadata file*/ +if (registry->metadata_fd >0 ) { + ret =ust_metadata_truncate (registry->metadata_fd,0 ); +if (ret) { +pthread_mutex_unlock (®istry->lock); + goto end; + } + } + ret =ust_metadata_session_statedump (registry,NULL , registry->major, registry->minor);if (ret) { --2.7.4
Quoted 6 lines
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev