From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: util-linux@vger.kernel.org
Subject: [PATCH] libuuid: avoid truncate clocks.txt to improve performance
Date: Tue, 10 Oct 2023 18:08:59 -0500 [thread overview]
Message-ID: <i4fuwkw2hvj6gge3uhuy3jlq5gg4ls7djibygcb5duxhumvllx@cernuqwwl7pi> (raw)
Instead of explicitly truncating clocks.txt file, pad with
whitespaces in the end of file.
This is done to improve performance of libuuid on xfs
filesystems. Instead of truncating the file, pad it with whitespaces.
This is anyways used as a failsafe method in case truncate fails.
The reason why this regression was introduced was because of:
869ae85dae64 ("xfs: flush new eof page on truncate to avoid post-eof corruption")
An attempt to move the clocks.txt to /run (tmpfs) has been attempted before
[1] and with commit ab2e7dd17 ("libuuid: move clock state file from
/var/lib to /var/run"). The latter was reverted.
[1] https://www.spinics.net/lists/util-linux-ng/msg17331.html
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
libuuid/src/gen_uuid.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index 619ef0131..97e2dec4e 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -229,7 +229,6 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
struct timeval tv;
uint64_t clock_reg;
mode_t save_umask;
- int len;
int ret = 0;
if (state_fd == -1)
@@ -324,14 +323,10 @@ try_again:
if (state_fd >= 0) {
rewind(state_f);
- len = fprintf(state_f,
- "clock: %04x tv: %016ld %08ld adj: %08d\n",
+ fprintf(state_f,
+ "clock: %04x tv: %016ld %08ld adj: %08d \n",
clock_seq, (long)last.tv_sec, (long)last.tv_usec, adjustment);
fflush(state_f);
- if (ftruncate(state_fd, len) < 0) {
- fprintf(state_f, " \n");
- fflush(state_f);
- }
rewind(state_f);
flock(state_fd, LOCK_UN);
}
--
2.42.0
--
Goldwyn
next reply other threads:[~2023-10-10 23:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 23:08 Goldwyn Rodrigues [this message]
2023-11-07 10:33 ` [PATCH] libuuid: avoid truncate clocks.txt to improve performance Karel Zak
2023-11-09 15:14 ` Trapp, Michael
[not found] ` <AS4PR02MB85506893B87E53BFF5276BFAF9AFA@AS4PR02MB8550.eurprd02.prod.outlook.com>
2023-11-13 13:54 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=i4fuwkw2hvj6gge3uhuy3jlq5gg4ls7djibygcb5duxhumvllx@cernuqwwl7pi \
--to=rgoldwyn@suse.de \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).