X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Flog.c;h=38606c1f69bb7d0020dee31cc21086fe715670ee;hb=9f0e2f7de7d919d6a83944f0e7fdbd07cb6c4189;hp=8801b330da34abb9928ed7b1d6bd6493447b106a;hpb=772058dfc33fbe4857864b4bdb8ba947eca19303;p=bluesky.git diff --git a/bluesky/log.c b/bluesky/log.c index 8801b33..38606c1 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -468,8 +468,14 @@ BlueSkyCacheFile *bluesky_cachefile_lookup(BlueSkyFS *fs, return map; } +/* The arguments are mostly straightforward. log_dir is -1 for access from the + * journal, and non-negative for access to a cloud log segment. map_data + * should be TRUE for the case that are mapping just the data of an item where + * we have already parsed the item headers; this surpresses the error when the + * access is not to the first bytes of the item. */ BlueSkyRCStr *bluesky_log_map_object(BlueSkyFS *fs, int log_dir, - int log_seq, int log_offset, int log_size) + int log_seq, int log_offset, int log_size, + gboolean map_data) { if (page_size == 0) { page_size = getpagesize(); @@ -485,9 +491,17 @@ BlueSkyRCStr *bluesky_log_map_object(BlueSkyFS *fs, int log_dir, /* Log segments fetched from the cloud might only be partially-fetched. * Check whether the object we are interested in is available. */ if (log_dir >= 0) { - if (!bluesky_rangeset_lookup(map->items, log_offset)) { + const BlueSkyRangesetItem *rangeitem; + rangeitem = bluesky_rangeset_lookup(map->items, log_offset); + if (rangeitem == NULL || rangeitem->start != log_offset) { g_warning("log-%d: Item at offset %d does not seem to be available\n", log_seq, log_offset); } + if (map_data && rangeitem != NULL + && log_offset > rangeitem->start + && log_size <= rangeitem->length - (log_offset - rangeitem->start)) + { + g_warning(" ...allowing access to middle of log item"); + } } if (map->addr == NULL) {