]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mmap-cache: s/mmap_cache/mmap_cache_fd_/ where apropos 21452/head
authorVito Caputo <vcaputo@pengaru.com>
Wed, 17 Nov 2021 04:37:30 +0000 (20:37 -0800)
committerVito Caputo <vcaputo@pengaru.com>
Fri, 19 Nov 2021 21:43:00 +0000 (13:43 -0800)
Mostly mechanical renaming of mmap-cache functions that now
operate exclusively on the MMapFileDescriptor.

src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-verify.c
src/libsystemd/sd-journal/mmap-cache.c
src/libsystemd/sd-journal/mmap-cache.h
src/libsystemd/sd-journal/test-mmap-cache.c

index 957a09ef216fe6720fa270e25b238350d573a3ed..1def74e2c905c6ea87643d6268a89e39798abc25 100644 (file)
@@ -163,7 +163,7 @@ static int journal_file_set_offline_thread_join(JournalFile *f) {
 
         f->offline_state = OFFLINE_JOINED;
 
-        if (mmap_cache_got_sigbus(f->cache_fd))
+        if (mmap_cache_fd_got_sigbus(f->cache_fd))
                 return -EIO;
 
         return 0;
@@ -323,7 +323,7 @@ static int journal_file_set_online(JournalFile *f) {
                 }
         }
 
-        if (mmap_cache_got_sigbus(f->cache_fd))
+        if (mmap_cache_fd_got_sigbus(f->cache_fd))
                 return -EIO;
 
         switch (f->header->state) {
@@ -376,7 +376,7 @@ JournalFile* journal_file_close(JournalFile *f) {
         journal_file_set_offline(f, true);
 
         if (f->mmap && f->cache_fd)
-                mmap_cache_free_fd(f->cache_fd);
+                mmap_cache_fd_free(f->cache_fd);
 
         if (f->fd >= 0 && f->defrag_on_close) {
 
@@ -654,7 +654,7 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
         if (size > PAGE_ALIGN_DOWN(UINT64_MAX) - offset)
                 return -EINVAL;
 
-        if (mmap_cache_got_sigbus(f->cache_fd))
+        if (mmap_cache_fd_got_sigbus(f->cache_fd))
                 return -EIO;
 
         old_header_size = le64toh(READ_NOW(f->header->header_size));
@@ -754,7 +754,7 @@ static int journal_file_move_to(
                         return -EADDRNOTAVAIL;
         }
 
-        return mmap_cache_get(f->cache_fd, type_to_context(type), keep_always, offset, size, &f->last_stat, ret);
+        return mmap_cache_fd_get(f->cache_fd, type_to_context(type), keep_always, offset, size, &f->last_stat, ret);
 }
 
 static uint64_t minimum_header_size(Object *o) {
@@ -2185,7 +2185,7 @@ int journal_file_append_entry(
          * it is very likely just an effect of a nullified replacement
          * mapping page */
 
-        if (mmap_cache_got_sigbus(f->cache_fd))
+        if (mmap_cache_fd_got_sigbus(f->cache_fd))
                 r = -EIO;
 
         if (f->post_change_timer)
@@ -3571,7 +3571,7 @@ int journal_file_open(
                 goto fail;
         }
 
-        r = mmap_cache_get(f->cache_fd, CONTEXT_HEADER, true, 0, PAGE_ALIGN(sizeof(Header)), &f->last_stat, &h);
+        r = mmap_cache_fd_get(f->cache_fd, CONTEXT_HEADER, true, 0, PAGE_ALIGN(sizeof(Header)), &f->last_stat, &h);
         if (r == -EINVAL) {
                 /* Some file systems (jffs2 or p9fs) don't support mmap() properly (or only read-only
                  * mmap()), and return EINVAL in that case. Let's propagate that as a more recognizable error
@@ -3634,7 +3634,7 @@ int journal_file_open(
 #endif
         }
 
-        if (mmap_cache_got_sigbus(f->cache_fd)) {
+        if (mmap_cache_fd_got_sigbus(f->cache_fd)) {
                 r = -EIO;
                 goto fail;
         }
@@ -3656,7 +3656,7 @@ int journal_file_open(
         return 0;
 
 fail:
-        if (f->cache_fd && mmap_cache_got_sigbus(f->cache_fd))
+        if (f->cache_fd && mmap_cache_fd_got_sigbus(f->cache_fd))
                 r = -EIO;
 
         (void) journal_file_close(f);
@@ -3942,7 +3942,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
         r = journal_file_append_entry_internal(to, &ts, boot_id, xor_hash, items, n,
                                                NULL, NULL, NULL);
 
-        if (mmap_cache_got_sigbus(to->cache_fd))
+        if (mmap_cache_fd_got_sigbus(to->cache_fd))
                 return -EIO;
 
         return r;
index 1965408754b8657bf3ae29cab290ebe0d09d521d..38849e6451eb684736c503ce553b305d6bfe3b01 100644 (file)
@@ -401,7 +401,7 @@ static int contains_uint64(MMapFileDescriptor *f, uint64_t n, uint64_t p) {
 
                 c = (a + b) / 2;
 
-                r = mmap_cache_get(f, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z);
+                r = mmap_cache_fd_get(f, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z);
                 if (r < 0)
                         return r;
 
@@ -1336,9 +1336,9 @@ int journal_file_verify(
         if (show_progress)
                 flush_progress();
 
-        mmap_cache_free_fd(cache_data_fd);
-        mmap_cache_free_fd(cache_entry_fd);
-        mmap_cache_free_fd(cache_entry_array_fd);
+        mmap_cache_fd_free(cache_data_fd);
+        mmap_cache_fd_free(cache_entry_fd);
+        mmap_cache_fd_free(cache_entry_array_fd);
 
         if (first_contained)
                 *first_contained = le64toh(f->header->head_entry_realtime);
@@ -1360,13 +1360,13 @@ fail:
                   100 * p / f->last_stat.st_size);
 
         if (cache_data_fd)
-                mmap_cache_free_fd(cache_data_fd);
+                mmap_cache_fd_free(cache_data_fd);
 
         if (cache_entry_fd)
-                mmap_cache_free_fd(cache_entry_fd);
+                mmap_cache_fd_free(cache_entry_fd);
 
         if (cache_entry_array_fd)
-                mmap_cache_free_fd(cache_entry_array_fd);
+                mmap_cache_fd_free(cache_entry_array_fd);
 
         return r;
 }
index 00bbb9e9f7feefe15c5d42427561d2153adb202b..cc02d8c76c4417274d7929f4ca4a0f5d445c269b 100644 (file)
@@ -480,7 +480,7 @@ outofmem:
         return -ENOMEM;
 }
 
-int mmap_cache_get(
+int mmap_cache_fd_get(
                 MMapFileDescriptor *f,
                 unsigned context,
                 bool keep_always,
@@ -582,7 +582,7 @@ static void mmap_cache_process_sigbus(MMapCache *m) {
         }
 }
 
-bool mmap_cache_got_sigbus(MMapFileDescriptor *f) {
+bool mmap_cache_fd_got_sigbus(MMapFileDescriptor *f) {
         assert(f);
 
         mmap_cache_process_sigbus(f->cache);
@@ -620,7 +620,7 @@ MMapFileDescriptor* mmap_cache_add_fd(MMapCache *m, int fd, int prot) {
         return f;
 }
 
-void mmap_cache_free_fd(MMapFileDescriptor *f) {
+void mmap_cache_fd_free(MMapFileDescriptor *f) {
         assert(f);
         assert(f->cache);
 
index 0851ec3ef75438842ee8995b2fcdf3e6e3ecff82..28f699dbd13c85fa41eb8e321ba395721eae30bc 100644 (file)
@@ -14,7 +14,7 @@ MMapCache* mmap_cache_new(void);
 MMapCache* mmap_cache_ref(MMapCache *m);
 MMapCache* mmap_cache_unref(MMapCache *m);
 
-int mmap_cache_get(
+int mmap_cache_fd_get(
         MMapFileDescriptor *f,
         unsigned context,
         bool keep_always,
@@ -23,8 +23,8 @@ int mmap_cache_get(
         struct stat *st,
         void **ret);
 MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd, int prot);
-void mmap_cache_free_fd(MMapFileDescriptor *f);
+void mmap_cache_fd_free(MMapFileDescriptor *f);
 
 void mmap_cache_stats_log_debug(MMapCache *m);
 
-bool mmap_cache_got_sigbus(MMapFileDescriptor *f);
+bool mmap_cache_fd_got_sigbus(MMapFileDescriptor *f);
index 1b8c632f56fa3e4a1545383c6b010c97df000d4e..6ec36931fda9ef3425910d3fd716e08214db6be0 100644 (file)
@@ -34,28 +34,28 @@ int main(int argc, char *argv[]) {
         assert_se(z >= 0);
         unlink(pz);
 
-        r = mmap_cache_get(fx, 0, false, 1, 2, NULL, &p);
+        r = mmap_cache_fd_get(fx, 0, false, 1, 2, NULL, &p);
         assert_se(r >= 0);
 
-        r = mmap_cache_get(fx, 0, false, 2, 2, NULL, &q);
+        r = mmap_cache_fd_get(fx, 0, false, 2, 2, NULL, &q);
         assert_se(r >= 0);
 
         assert_se((uint8_t*) p + 1 == (uint8_t*) q);
 
-        r = mmap_cache_get(fx, 1, false, 3, 2, NULL, &q);
+        r = mmap_cache_fd_get(fx, 1, false, 3, 2, NULL, &q);
         assert_se(r >= 0);
 
         assert_se((uint8_t*) p + 2 == (uint8_t*) q);
 
-        r = mmap_cache_get(fx, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p);
+        r = mmap_cache_fd_get(fx, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p);
         assert_se(r >= 0);
 
-        r = mmap_cache_get(fx, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q);
+        r = mmap_cache_fd_get(fx, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q);
         assert_se(r >= 0);
 
         assert_se((uint8_t*) p + 1 == (uint8_t*) q);
 
-        mmap_cache_free_fd(fx);
+        mmap_cache_fd_free(fx);
         mmap_cache_unref(m);
 
         safe_close(x);