[systemd-commits] 4 commits - TODO src/journal src/shared src/tmpfiles

Lennart Poettering lennart at kemper.freedesktop.org
Tue Jan 6 11:42:42 PST 2015


 TODO                       |    8 ++++++++
 src/journal/journal-file.c |   16 +++++++++++++++-
 src/journal/journal-file.h |    1 +
 src/shared/btrfs-util.c    |   19 +++++++++++++++++++
 src/shared/btrfs-util.h    |    3 +++
 src/tmpfiles/tmpfiles.c    |    2 +-
 6 files changed, 47 insertions(+), 2 deletions(-)

New commits:
commit 1e95893a89b87e4ed656910e30c430e583bc8133
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 6 20:33:46 2015 +0100

    tmpfiles: make gcc shut up

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index ea1d11c..ac9a072 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1123,7 +1123,7 @@ static int clean_item(Item *i) {
 }
 
 static int process_item(Item *i) {
-        int r, q, p, s, t = 0;
+        int r, q, p, t = 0;
         _cleanup_free_ char *prefix = NULL;
 
         assert(i);

commit b9a1617d75c16a48cccf4ff135013dca9af94e7d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 6 20:27:29 2015 +0100

    journal: consider file deletion errors a reason for rotation

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 4c7dd24..c9030c5 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2780,7 +2780,8 @@ int journal_file_open_reliably(
             r != -EPROTONOSUPPORT && /* incompatible feature */
             r != -EBUSY && /* unclean shutdown */
             r != -ESHUTDOWN && /* already archived */
-            r != -EIO /* IO error, including SIGBUS on mmap */)
+            r != -EIO && /* IO error, including SIGBUS on mmap */
+            r != -EIDRM /* File has been deleted */)
                 return r;
 
         if ((flags & O_ACCMODE) == O_RDONLY)

commit f27a386430cc7a27ebd06899d93310fb3bd4cee7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 6 19:51:03 2015 +0100

    journald: whenever we rotate a file, btrfs defrag it
    
    Our write pattern is quite awful for CoW file systems (btrfs...), as we
    keep updating file parts in the beginning of the file. This results in
    fragmented journal files. Hence: when rotating files, defragment them,
    since at that point we know that no further write accesses will be made.

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 304ce03..4c7dd24 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <stddef.h>
 
+#include "btrfs-util.h"
 #include "journal-def.h"
 #include "journal-file.h"
 #include "journal-authenticate.h"
@@ -140,6 +141,9 @@ void journal_file_close(JournalFile *f) {
         if (f->mmap && f->fd >= 0)
                 mmap_cache_close_fd(f->mmap, f->fd);
 
+        if (f->fd >= 0 && f->defrag_on_close)
+                btrfs_defrag_fd(f->fd);
+
         safe_close(f->fd);
         free(f->path);
 
@@ -2741,6 +2745,11 @@ int journal_file_rotate(JournalFile **f, bool compress, bool seal) {
 
         old_file->header->state = STATE_ARCHIVED;
 
+        /* Currently, btrfs is not very good with out write patterns
+         * and fragments heavily. Let's defrag our journal files when
+         * we archive them */
+        old_file->defrag_on_close = true;
+
         r = journal_file_open(old_file->path, old_file->flags, old_file->mode, compress, seal, NULL, old_file->mmap, old_file, &new_file);
         journal_file_close(old_file);
 
@@ -2796,6 +2805,10 @@ int journal_file_open_reliably(
         if (r < 0)
                 return -errno;
 
+        /* btrfs doesn't cope well with our write pattern and
+         * fragments heavily. Let's defrag all files we rotate */
+        (void) btrfs_defrag(p);
+
         log_warning("File %s corrupted or uncleanly shut down, renaming and replacing.", fname);
 
         return journal_file_open(fname, flags, mode, compress, seal,
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index b3a0679..6812385 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -73,6 +73,7 @@ typedef struct JournalFile {
         bool compress_xz:1;
         bool compress_lz4:1;
         bool seal:1;
+        bool defrag_on_close:1;
 
         bool tail_entry_monotonic_valid:1;
 
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 164ac9f..e648121 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -531,3 +531,22 @@ finish:
 
         return 0;
 }
+
+int btrfs_defrag_fd(int fd) {
+        assert(fd >= 0);
+
+        if (ioctl(fd, BTRFS_IOC_DEFRAG, NULL) < 0)
+                return -errno;
+
+        return 0;
+}
+
+int btrfs_defrag(const char *p) {
+        _cleanup_close_ int fd = -1;
+
+        fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
+        if (fd < 0)
+                return -errno;
+
+        return btrfs_defrag_fd(fd);
+}
diff --git a/src/shared/btrfs-util.h b/src/shared/btrfs-util.h
index 1532c12..1bff917 100644
--- a/src/shared/btrfs-util.h
+++ b/src/shared/btrfs-util.h
@@ -57,3 +57,6 @@ int btrfs_subvol_get_quota_fd(int fd, BtrfsQuotaInfo *quota);
 int btrfs_reflink(int infd, int outfd);
 
 int btrfs_get_block_device(const char *path, dev_t *dev);
+
+int btrfs_defrag_fd(int fd);
+int btrfs_defrag(const char *p);

commit 7c75c5ca68970d2d47f211f068883e9b8c3ff5e7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 6 19:50:52 2015 +0100

    Update TODO

diff --git a/TODO b/TODO
index ec3746b..3aeef66 100644
--- a/TODO
+++ b/TODO
@@ -31,6 +31,14 @@ External:
 
 Features:
 
+* support mbr raw disk images in systemd-nspawn, so that we can boot fedora cloud images unmodified
+
+* add fd store to pid 1 serialization
+
+* rework sigbus stuff to use mutex
+
+* create importd daemon, move "systemd-import" tool into machinectl
+
 * change default container location from /var/lib/container to /var/lib/machines
 
 * nspawn: when start a container "foobar" look for its configuration in a file "foobar.nspawn" in /etc/systemd/nspawn/ as well as next to the actualy directory or image to boot



More information about the systemd-commits mailing list