Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef WRITE_OR_DIE_H |
2 | | #define WRITE_OR_DIE_H |
3 | | |
4 | | void maybe_flush_or_die(FILE *, const char *); |
5 | | __attribute__((format (printf, 2, 3))) |
6 | | void fprintf_or_die(FILE *, const char *fmt, ...); |
7 | | void fwrite_or_die(FILE *f, const void *buf, size_t count); |
8 | | void fflush_or_die(FILE *f); |
9 | | void write_or_die(int fd, const void *buf, size_t count); |
10 | | |
11 | | /* |
12 | | * These values are used to help identify parts of a repository to fsync. |
13 | | * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the |
14 | | * repository and so shouldn't be fsynced. |
15 | | */ |
16 | | enum fsync_component { |
17 | | FSYNC_COMPONENT_NONE, |
18 | | FSYNC_COMPONENT_LOOSE_OBJECT = 1 << 0, |
19 | | FSYNC_COMPONENT_PACK = 1 << 1, |
20 | | FSYNC_COMPONENT_PACK_METADATA = 1 << 2, |
21 | | FSYNC_COMPONENT_COMMIT_GRAPH = 1 << 3, |
22 | | FSYNC_COMPONENT_INDEX = 1 << 4, |
23 | | FSYNC_COMPONENT_REFERENCE = 1 << 5, |
24 | | }; |
25 | | |
26 | 0 | #define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \ |
27 | 0 | FSYNC_COMPONENT_PACK) |
28 | | |
29 | 0 | #define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \ |
30 | 0 | FSYNC_COMPONENT_COMMIT_GRAPH) |
31 | | |
32 | 0 | #define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \ |
33 | 0 | FSYNC_COMPONENTS_DERIVED_METADATA) & \ |
34 | 0 | ~FSYNC_COMPONENT_LOOSE_OBJECT) |
35 | | |
36 | | #define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \ |
37 | | FSYNC_COMPONENT_REFERENCE) |
38 | | |
39 | | #define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \ |
40 | | FSYNC_COMPONENT_INDEX) |
41 | | |
42 | | #define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \ |
43 | | FSYNC_COMPONENT_PACK | \ |
44 | | FSYNC_COMPONENT_PACK_METADATA | \ |
45 | | FSYNC_COMPONENT_COMMIT_GRAPH | \ |
46 | | FSYNC_COMPONENT_INDEX | \ |
47 | | FSYNC_COMPONENT_REFERENCE) |
48 | | |
49 | | #ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT |
50 | 0 | #define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT |
51 | | #endif |
52 | | |
53 | | /* IO helper functions */ |
54 | | void fsync_or_die(int fd, const char *); |
55 | | int fsync_component(enum fsync_component component, int fd); |
56 | | void fsync_component_or_die(enum fsync_component component, int fd, const char *msg); |
57 | | |
58 | | /* |
59 | | * A bitmask indicating which components of the repo should be fsynced. |
60 | | */ |
61 | | extern enum fsync_component fsync_components; |
62 | | extern int fsync_object_files; |
63 | | extern int use_fsync; |
64 | | |
65 | | enum fsync_method { |
66 | | FSYNC_METHOD_FSYNC, |
67 | | FSYNC_METHOD_WRITEOUT_ONLY, |
68 | | FSYNC_METHOD_BATCH, |
69 | | }; |
70 | | |
71 | | extern enum fsync_method fsync_method; |
72 | | |
73 | | static inline int batch_fsync_enabled(enum fsync_component component) |
74 | 53.6k | { |
75 | 53.6k | return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH); |
76 | 53.6k | } Unexecuted instantiation: blame.c:batch_fsync_enabled Unexecuted instantiation: cat-file.c:batch_fsync_enabled Unexecuted instantiation: check-attr.c:batch_fsync_enabled Unexecuted instantiation: check-ignore.c:batch_fsync_enabled Unexecuted instantiation: check-mailmap.c:batch_fsync_enabled Unexecuted instantiation: credential-cache.c:batch_fsync_enabled Unexecuted instantiation: credential-store.c:batch_fsync_enabled Unexecuted instantiation: fast-import.c:batch_fsync_enabled Unexecuted instantiation: fsck.c:batch_fsync_enabled Unexecuted instantiation: gc.c:batch_fsync_enabled Unexecuted instantiation: grep.c:batch_fsync_enabled Unexecuted instantiation: hash-object.c:batch_fsync_enabled Unexecuted instantiation: index-pack.c:batch_fsync_enabled Unexecuted instantiation: log.c:batch_fsync_enabled Unexecuted instantiation: notes.c:batch_fsync_enabled Unexecuted instantiation: pack-objects.c:batch_fsync_enabled Unexecuted instantiation: receive-pack.c:batch_fsync_enabled Unexecuted instantiation: repack.c:batch_fsync_enabled Unexecuted instantiation: rev-list.c:batch_fsync_enabled Unexecuted instantiation: send-pack.c:batch_fsync_enabled Unexecuted instantiation: show-index.c:batch_fsync_enabled Unexecuted instantiation: stripspace.c:batch_fsync_enabled Unexecuted instantiation: tag.c:batch_fsync_enabled Unexecuted instantiation: unpack-objects.c:batch_fsync_enabled Unexecuted instantiation: update-index.c:batch_fsync_enabled Unexecuted instantiation: bulk-checkin.c:batch_fsync_enabled Unexecuted instantiation: bundle.c:batch_fsync_enabled Unexecuted instantiation: commit-graph.c:batch_fsync_enabled Unexecuted instantiation: config.c:batch_fsync_enabled Unexecuted instantiation: csum-file.c:batch_fsync_enabled Unexecuted instantiation: delta-islands.c:batch_fsync_enabled Unexecuted instantiation: diagnose.c:batch_fsync_enabled Unexecuted instantiation: environment.c:batch_fsync_enabled Unexecuted instantiation: fetch-pack.c:batch_fsync_enabled Unexecuted instantiation: log-tree.c:batch_fsync_enabled Unexecuted instantiation: midx.c:batch_fsync_enabled Unexecuted instantiation: midx-write.c:batch_fsync_enabled object-file.c:batch_fsync_enabled Line | Count | Source | 74 | 53.6k | { | 75 | 53.6k | return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH); | 76 | 53.6k | } |
Unexecuted instantiation: pack-bitmap-write.c:batch_fsync_enabled Unexecuted instantiation: pack-bitmap.c:batch_fsync_enabled Unexecuted instantiation: pack-check.c:batch_fsync_enabled Unexecuted instantiation: pack-revindex.c:batch_fsync_enabled Unexecuted instantiation: pack-write.c:batch_fsync_enabled Unexecuted instantiation: packfile.c:batch_fsync_enabled Unexecuted instantiation: pkt-line.c:batch_fsync_enabled Unexecuted instantiation: pseudo-merge.c:batch_fsync_enabled Unexecuted instantiation: reachable.c:batch_fsync_enabled Unexecuted instantiation: read-cache.c:batch_fsync_enabled Unexecuted instantiation: files-backend.c:batch_fsync_enabled Unexecuted instantiation: packed-backend.c:batch_fsync_enabled Unexecuted instantiation: sideband.c:batch_fsync_enabled Unexecuted instantiation: upload-pack.c:batch_fsync_enabled Unexecuted instantiation: write-or-die.c:batch_fsync_enabled Unexecuted instantiation: archive-tar.c:batch_fsync_enabled Unexecuted instantiation: archive-zip.c:batch_fsync_enabled Unexecuted instantiation: chunk-format.c:batch_fsync_enabled Unexecuted instantiation: stack.c:batch_fsync_enabled |
77 | | |
78 | | #endif /* WRITE_OR_DIE_H */ |