int default_purge_obj(void) { uint32_t tgt_epoch = get_latest_epoch(); return for_each_object_in_wd(move_object_to_stale_dir, true, &tgt_epoch); }
int default_end_recover(uint32_t old_epoch, struct vnode_info *old_vnode_info) { if (old_epoch == 0) return SD_RES_SUCCESS; return for_each_object_in_wd(check_stale_objects, false, &old_epoch); }
int default_init(void) { int ret; sd_dprintf("use plain store driver"); ret = for_each_obj_path(make_stale_dir); if (ret != SD_RES_SUCCESS) return ret; return for_each_object_in_wd(init_objlist_and_vdi_bitmap, true, NULL); }
int trunk_file_write(unsigned char *outsha1) { struct strbuf buf; struct sha1_file_hdr hdr = {}; struct trunk_entry entry = {}; struct dirent *d; DIR *dir; uint64_t data_size, oid, object_nr = 0; int ret = 0; /* Add the hdr first */ for_each_object_in_wd(inc_object_nr, false, &object_nr); data_size = sizeof(struct trunk_entry) * object_nr; hdr.size = data_size; hdr.priv = object_nr; memcpy(hdr.tag, TAG_TRUNK, TAG_LEN); strbuf_init(&buf, sizeof(hdr) + data_size); strbuf_add(&buf, &hdr, sizeof(hdr)); dir = opendir(obj_path); if (!dir) { ret = -1; goto out; } while ((d = readdir(dir))) { if (!strncmp(d->d_name, ".", 1)) continue; oid = strtoull(d->d_name, NULL, 16); if (oid == 0 || oid == ULLONG_MAX) continue; entry.oid = oid; if (fill_entry_new_sha1(&entry) < 0) { ret = -1; goto out; } strbuf_add(&buf, &entry, sizeof(struct trunk_entry)); } if (sha1_file_write((void *)buf.buf, buf.len, outsha1) < 0) { ret = -1; goto out; } dprintf("trunk sha1: %s\n", sha1_to_hex(outsha1)); out: closedir(dir); strbuf_release(&buf); return ret; }
int default_init(char *p) { dprintf("use plain store driver\n"); /* create a stale directory */ snprintf(stale_dir, sizeof(stale_dir), "%s/.stale", p); if (mkdir(stale_dir, 0755) < 0) { if (errno != EEXIST) { eprintf("%m\n"); return SD_RES_EIO; } } return for_each_object_in_wd(init_objlist_and_vdi_bitmap, true, NULL); }
static int farm_restore(const struct siocb *iocb) { int ret = SD_RES_EIO, epoch = iocb->epoch; sd_dprintf("try recover user epoch %d", epoch); /* Remove all the objects of WD and object cache */ for_each_object_in_wd(rm_object, true, NULL); if (sys->enable_object_cache) object_cache_format(); ret = restore_objects_from_snap(epoch); if (ret != SD_RES_SUCCESS) goto out; out: return ret; }
static int migrate_from_v3_to_v4(void) { bool is_stale = true; int ret; ret = for_each_object_in_stale(convert_ecidx_xattr2path, (void *)&is_stale); if (ret < 0) { sd_emerg("converting store format of stale object directory" "failed"); return ret; } is_stale = false; ret = for_each_object_in_wd(convert_ecidx_xattr2path, false, (void *)&is_stale); if (ret < 0) { sd_emerg("converting store format of object directory failed"); return ret; } sd_info("converting store format v3 to v4 is ended successfully"); return 0; }
int default_update_epoch(uint32_t epoch) { assert(epoch); return for_each_object_in_wd(check_stale_objects, false, &epoch); }