#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "libjio.h"
#include "common.h"
#include "compat.h"
#include "journal.h"
#include "trans.h"
Go to the source code of this file.
Data Structures | |
struct | on_disk_hdr |
Transaction file header. More... | |
struct | on_disk_ophdr |
Transaction file operation header. More... | |
struct | on_disk_trailer |
Transaction file trailer. More... | |
Functions | |
static void | hdr_hton (struct on_disk_hdr *hdr) |
static void | hdr_ntoh (struct on_disk_hdr *hdr) |
static void | ophdr_hton (struct on_disk_ophdr *ophdr) |
static void | ophdr_ntoh (struct on_disk_ophdr *ophdr) |
static void | trailer_hton (struct on_disk_trailer *trailer) |
static void | trailer_ntoh (struct on_disk_trailer *trailer) |
static unsigned int | get_tid (struct jfs *fs) |
Get a new transaction id. | |
static void | free_tid (struct jfs *fs, unsigned int tid) |
Free a transaction id. | |
static int | fsync_dir (int fd) |
fsync() a directory | |
static int | corrupt_journal_file (struct journal_op *jop) |
Corrupt a journal file. | |
static int | mark_broken (struct jfs *fs) |
Mark the journal as broken. | |
static int | is_broken (struct jfs *fs) |
Check if the journal is broken. | |
struct journal_op * | journal_new (struct jfs *fs, unsigned int flags) |
Create a new transaction in the journal. | |
int | journal_add_op (struct journal_op *jop, unsigned char *buf, size_t len, off_t offset) |
Save a single operation in the journal file. | |
void | journal_pre_commit (struct journal_op *jop) |
Prepares to commit the operation. | |
int | journal_commit (struct journal_op *jop) |
Commit the journal operation. | |
int | journal_free (struct journal_op *jop, int do_unlink) |
Free a journal operation. | |
int | fill_trans (unsigned char *map, off_t len, struct jtrans *ts) |
Fill a transaction structure from a mmapped transaction file. | |
Variables | |
struct on_disk_hdr | packed |
Transaction file header. | |
static int | already_warned_about_sync = 0 |
static void hdr_hton | ( | struct on_disk_hdr * | hdr | ) | [static] |
Definition at line 69 of file journal.c.
Referenced by journal_new().
static void hdr_ntoh | ( | struct on_disk_hdr * | hdr | ) | [static] |
Definition at line 76 of file journal.c.
Referenced by fill_trans().
static void ophdr_hton | ( | struct on_disk_ophdr * | ophdr | ) | [static] |
Definition at line 83 of file journal.c.
Referenced by journal_add_op(), and journal_commit().
static void ophdr_ntoh | ( | struct on_disk_ophdr * | ophdr | ) | [static] |
Definition at line 89 of file journal.c.
Referenced by fill_trans().
static void trailer_hton | ( | struct on_disk_trailer * | trailer | ) | [static] |
Definition at line 95 of file journal.c.
Referenced by journal_commit().
static void trailer_ntoh | ( | struct on_disk_trailer * | trailer | ) | [static] |
Definition at line 100 of file journal.c.
Referenced by fill_trans().
static unsigned int get_tid | ( | struct jfs * | fs | ) | [static] |
Get a new transaction id.
Definition at line 111 of file journal.c.
Referenced by journal_new().
static void free_tid | ( | struct jfs * | fs, | |
unsigned int | tid | |||
) | [static] |
Free a transaction id.
Definition at line 137 of file journal.c.
Referenced by journal_free(), and journal_new().
static int fsync_dir | ( | int | fd | ) | [static] |
fsync() a directory
Definition at line 176 of file journal.c.
Referenced by journal_commit(), and journal_free().
static int corrupt_journal_file | ( | struct journal_op * | jop | ) | [static] |
Corrupt a journal file.
Used as a last resource to prevent an applied transaction file laying around
Definition at line 203 of file journal.c.
Referenced by journal_free().
static int mark_broken | ( | struct jfs * | fs | ) | [static] |
Mark the journal as broken.
To do so, we just create a file named "broken" inside the journal directory. Used internally to mark severe journal errors that should prevent further journal use to avoid potential corruption, like failures to remove transaction files. The mark is removed by jfsck().
Definition at line 232 of file journal.c.
Referenced by journal_free().
static int is_broken | ( | struct jfs * | fs | ) | [static] |
Check if the journal is broken.
Definition at line 245 of file journal.c.
Referenced by journal_new().
struct journal_op* journal_new | ( | struct jfs * | fs, | |
unsigned int | flags | |||
) | [read] |
Create a new transaction in the journal.
Returns a pointer to an opaque jop_t (that is freed using journal_free), or NULL if there was an error.
Definition at line 260 of file journal.c.
Referenced by jtrans_commit().
int journal_add_op | ( | struct journal_op * | jop, | |
unsigned char * | buf, | |||
size_t | len, | |||
off_t | offset | |||
) |
Save a single operation in the journal file.
Definition at line 334 of file journal.c.
Referenced by jtrans_commit().
void journal_pre_commit | ( | struct journal_op * | jop | ) |
Prepares to commit the operation.
Can be omitted.
Definition at line 371 of file journal.c.
Referenced by jtrans_commit().
int journal_commit | ( | struct journal_op * | jop | ) |
Commit the journal operation.
Definition at line 380 of file journal.c.
Referenced by jtrans_commit().
int journal_free | ( | struct journal_op * | jop, | |
int | do_unlink | |||
) |
Free a journal operation.
NOTE: It can't assume the save completed successfuly, so we can call it when journal_save() fails.
Definition at line 428 of file journal.c.
Referenced by jsync(), and jtrans_commit().
int fill_trans | ( | unsigned char * | map, | |
off_t | len, | |||
struct jtrans * | ts | |||
) |
Fill a transaction structure from a mmapped transaction file.
Useful for checking purposes.
Definition at line 476 of file journal.c.
Referenced by jfsck().
struct on_disk_trailer packed |
int already_warned_about_sync = 0 [static] |