mmap-cache: s/mmap_cache/mmap_cache_fd_/ where apropos
Mostly mechanical renaming of mmap-cache functions that now operate exclusively on the MMapFileDescriptor.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user