remove mmap() stuff; checkout is fast enough for now
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
diff --git a/lib/got_pack_lib.h b/lib/got_pack_lib.h
index 0e20e10..497c9c2 100644
--- a/lib/got_pack_lib.h
+++ b/lib/got_pack_lib.h
@@ -14,30 +14,14 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* A pack file segment mapped with mmap(2). */
-struct got_pack_mapping {
- TAILQ_ENTRY(got_pack_mapping) entry;
- int fd;
- uint8_t *addr;
- off_t offset;
- size_t len;
-};
-
-#define GOT_PACK_MAX_OPEN_MAPPINGS 512
-#define GOT_PACK_MAPPING_MIN_SIZE 8192
-#define GOT_PACK_MAPPING_MAX_SIZE (2048 * GOT_PACK_MAPPING_MIN_SIZE)
-
/* An open pack file. */
struct got_pack {
char *path_packfile;
FILE *packfile;
size_t filesize;
- int nmappings;
-
- TAILQ_HEAD(, got_pack_mapping) mappings;
};
-const struct got_error *got_pack_close(struct got_pack *);
+void got_pack_close(struct got_pack *);
/* See Documentation/technical/pack-format.txt in Git. */
diff --git a/lib/pack.c b/lib/pack.c
index f9bf359..98c06d2 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -17,7 +17,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/queue.h>
-#include <sys/mman.h>
#include <dirent.h>
#include <fcntl.h>
@@ -502,56 +501,6 @@ read_packfile_hdr(FILE *f, struct got_packidx_v2_hdr *packidx)
return err;
}
-#ifdef notyet
-static const struct got_error *
-map_packfile_segment(struct got_pack_mapping **map, const char *path_packfile,
- off_t offset, size_t len)
-{
- const struct got_error *err = NULL;
-
- if (len < GOT_PACK_MAPPING_MIN_SIZE)
- len = GOT_PACK_MAPPING_MIN_SIZE;
-
- if (len > GOT_PACK_MAPPING_MAX_SIZE)
- return got_error(GOT_ERR_NO_SPACE);
-
- *map = calloc(1, sizeof(**map));
- if (*map == NULL)
- return got_error(GOT_ERR_NO_MEM);
-
- (*map)->fd = open(path_packfile, O_RDONLY | O_NOFOLLOW);
- if ((*map)->fd == -1) {
- err = got_error_from_errno();
- free((*map));
- *map = NULL;
- return err;
- }
-
- (*map)->addr = mmap(NULL, len, PROT_READ, MAP_PRIVATE, (*map)->fd, offset);
- if ((*map)->addr == NULL) {
- err = got_error_from_errno();
- close((*map)->fd);
- free((*map));
- *map = NULL;
- return err;
- }
-
- (*map)->offset = offset;
- (*map)->len = len;
-
- return NULL;
-}
-#endif
-
-static const struct got_error *
-unmap_packfile_segment(struct got_pack_mapping *map)
-{
- if (munmap(map->addr, map->len) == -1 || close(map->fd) == -1)
- return got_error_from_errno();
- free(map);
- return NULL;
-}
-
static const struct got_error *
open_packfile(FILE **packfile, const char *path_packfile,
struct got_repository *repo, struct got_packidx_v2_hdr *packidx)
@@ -576,29 +525,14 @@ open_packfile(FILE **packfile, const char *path_packfile,
return err;
}
-const struct got_error *
+void
got_pack_close(struct got_pack *pack)
{
- const struct got_error *err = NULL;
-
- while (!TAILQ_EMPTY(&pack->mappings)) {
- struct got_pack_mapping *map = TAILQ_FIRST(&pack->mappings);
- err = unmap_packfile_segment(map);
- if (err)
- break;
- TAILQ_REMOVE(&pack->mappings, map, entry);
- pack->nmappings--;
- }
-
- if (err == NULL) {
- fclose(pack->packfile);
- pack->packfile = NULL;
- free(pack->path_packfile);
- pack->path_packfile = NULL;
- pack->filesize = 0;
- }
-
- return err;
+ fclose(pack->packfile);
+ pack->packfile = NULL;
+ free(pack->path_packfile);
+ pack->path_packfile = NULL;
+ pack->filesize = 0;
}
static const struct got_error *
@@ -629,8 +563,6 @@ cache_pack(struct got_pack **packp, const char *path_packfile,
pack = &repo->packs[i];
- TAILQ_INIT(&pack->mappings);
-
pack->path_packfile = strdup(path_packfile);
if (pack->path_packfile == NULL) {
err = got_error(GOT_ERR_NO_MEM);