]> git.hungrycats.org Git - bees/commitdiff
tempfile: don't need to update the inode if the flags don't change
authorZygo Blaxell <bees@furryterror.org>
Mon, 30 Jun 2025 03:32:40 +0000 (23:32 -0400)
committerZygo Blaxell <bees@furryterror.org>
Mon, 30 Jun 2025 03:34:10 +0000 (23:34 -0400)
A small performance optimization, given that we are constantly clobbering
the file with new content.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees.cc

index d22fe19768c0ed6a36301e4ab38a906679990aa6..80523a5c446592cf799726b075ba6627e1ea5d9b 100644 (file)
@@ -509,10 +509,14 @@ BeesTempFile::resize(off_t offset)
        //   and we don't open FS_NOCOW_FL files for dedupe.
        BEESTRACE("Getting FS_COMPR_FL and FS_NOCOMP_FL on m_fd " << name_fd(m_fd));
        int flags = ioctl_iflags_get(m_fd);
+       const auto orig_flags = flags;
+
        flags |= FS_COMPR_FL;
        flags &= ~(FS_NOCOMP_FL | FS_NOCOW_FL);
-       BEESTRACE("Setting FS_COMPR_FL and clearing FS_NOCOMP_FL | FS_NOCOW_FL on m_fd " << name_fd(m_fd) << " flags " << to_hex(flags));
-       ioctl_iflags_set(m_fd, flags);
+       if (flags != orig_flags) {
+               BEESTRACE("Setting FS_COMPR_FL and clearing FS_NOCOMP_FL | FS_NOCOW_FL on m_fd " << name_fd(m_fd) << " flags " << to_hex(flags));
+               ioctl_iflags_set(m_fd, flags);
+       }
 
        // That may have queued some delayed ref deletes, so throttle them
        bees_throttle(resize_timer.age(), "tmpfile_resize");