Beispiel #1
0
/******************************************************************************
* Name  main
* 
* This utility, as currently written, repacks objects in the trash directory 
* due to mismatches between the chunk count specified in the trash file xattr
* and the actual number of files found in trash for the specified packed 
* object.
*
* The method for determining whether objects need to repacked is to read the 
* the file specied by the -d option.  This is typically the 
* tmp_packed_log file from garbage collection.  This file lists the packed 
* object name and associated files for the packed object.  It only lists those
* objects that could NOT reconcile with the file counts.  The format of this 
* file is:
*
* OBJECT_NAME  FILE_NAME  EXPECTED_FILE_COUNT  HOST BUCKED  OBJID   
*
* This utility reads the file and finds all files for the associated object
* The number of files found will be less than EXPECTED_FILE_COUNT (post xattr
* chunk count).  It then proceeds to read in the file objects and rewrite
* them back to a new object with offsets re-defined.  Xattrs are updated
* to reflect the new object, chunk_count, and offsets 
*
******************************************************************************/
int main(int argc, char **argv){
   int c;
   char *fnameP = NULL;
   char *outfile = NULL;
   //char *ns = NULL;

   while ((c=getopt(argc,argv,"d:o:h")) != EOF) {
      switch(c) {
         case 'd': fnameP = optarg; break;
         //case 'n': ns = optarg; break;
         case 'o': outfile = optarg; break;
         case 'h': print_usage();
         default:
            exit(-1);
      }
   }
   if (fnameP == NULL || outfile == NULL) {
      print_usage();
      exit(-1);
   }

   if ( setup_config() == -1 ) {
      fprintf(stderr,"Error:  Initializing Configs and Aws failed, quitting!!\n");
      exit(-1);
   }


   File_Handles file_info;
   File_Handles *file_status = &file_info;

   // open associated log file and packed log file
   if ((file_status->outfd = fopen(outfile,"w")) == NULL){
      fprintf(stderr, "Failed to open %s\n", outfile);
      exit(1);
   }
   strcpy(file_status->packed_log, fnameP);



   //MarFS_Namespace* namespace;
   //namespace = find_namespace_by_name(ns);
        //MarFS_Repo* repo = namespace->iwrite_repo;
        // Find the correct repo - the one with the largest range
   //MarFS_Repo* repo = find_repo_by_range(namespace, (size_t)-1);


   repack_objects *objs = NULL;
   find_repack_objects(file_status, &objs);
   pack_objects(file_status, objs);
   update_meta(file_status, objs);
   free_objects(objs);
   return 0;
}
Beispiel #2
0
int main (int argc, char **argv) {
  char *cmd;
  char *fname;
  
  if (argc < 3) {
    usage();
    return 0;
  }
  argv++;

  cmd = *(argv++);
  fname = *(argv++);

  switch (*cmd) {
  case 'c': // create
    if (mw_create(fname, argv, argc)) {
      usage();
    } 
    break;
  case 's': // stats
    print_stats(fname);
    break;
  case 'f': // fetch
    get_data(fname, argv);
    break;
  case 'd': // dump
    dump_data(fname, argv);
    break;
  case 'u': // update
    update_meta(fname, argv);
    break;
  default:
    printf("Error: Unrecognized command: %s\n", cmd);
  }

  return 0;
}
constraint mk_class_instance_root_cnstr(std::shared_ptr<class_instance_context> const & C, local_context const & _ctx,
                                        expr const & m, bool is_strict, unifier_config const & cfg, delay_factor const & factor) {
    environment const & env = C->env();
    justification j         = mk_failed_to_synthesize_jst(env, m);

    auto choice_fn = [=](expr const & meta, expr const & meta_type, substitution const & s,
                         name_generator const & ngen) {
        environment const & env  = C->env();
        auto cls_name_it = is_ext_class(C->tc(), meta_type);
        if (!cls_name_it) {
            // do nothing, since type is not a class.
            return lazy_list<constraints>(constraints());
        }
        local_context ctx        = _ctx.instantiate(substitution(s));
        pair<expr, justification> mj = update_meta(meta, s);
        expr new_meta            = mj.first;
        justification new_j      = mj.second;
        unsigned depth           = 0;
        constraint c             = mk_class_instance_cnstr(C, ctx, new_meta, depth);
        unifier_config new_cfg(cfg);
        new_cfg.m_discard        = false;
        new_cfg.m_use_exceptions = false;
        new_cfg.m_pattern        = true;
        new_cfg.m_kind           = C->m_conservative ? unifier_kind::VeryConservative : unifier_kind::Liberal;

        auto to_cnstrs_fn = [=](substitution const & subst, constraints const & cnstrs) -> constraints {
            substitution new_s = subst;
            // some constraints may have been postponed (example: universe level constraints)
            constraints  postponed = map(cnstrs,
                                         [&](constraint const & c) {
                                             // we erase internal justifications
                                             return update_justification(c, mk_composite1(j, new_j));
                                         });
            metavar_closure cls(new_meta);
            cls.add(meta_type);
            bool relax     = C->m_relax;
            constraints cs = cls.mk_constraints(new_s, new_j, relax);
            return append(cs, postponed);
        };

        auto no_solution_fn = [=]() {
            if (is_strict)
                return lazy_list<constraints>();
            else
                return lazy_list<constraints>(constraints());
        };

        unify_result_seq seq1    = unify(env, 1, &c, ngen, substitution(), new_cfg);
        unify_result_seq seq2    = filter(seq1, [=](pair<substitution, constraints> const & p) {
                substitution new_s = p.first;
                expr result = new_s.instantiate(new_meta);
                // We only keep complete solutions (modulo universe metavariables)
                return !has_expr_metavar_relaxed(result);
            });

        if (get_class_unique_class_instances(C->m_ios.get_options())) {
            optional<expr> solution;
            substitution subst;
            constraints  cnstrs;
            for_each(seq2, [&](pair<substitution, constraints> const & p) {
                    subst  = p.first;
                    cnstrs = p.second;
                    expr next_solution = subst.instantiate(new_meta);
                    if (solution) {
                        throw_class_exception(m, [=](formatter const & fmt) {
                                format r = format("ambiguous class-instance resolution, "
                                                  "there is more than one solution");
                                r += pp_indent_expr(fmt, *solution);
                                r += compose(line(), format("and"));
                                r += pp_indent_expr(fmt, next_solution);
                                return r;
                            });
                    } else {
                        solution = next_solution;
                    }
                });
            if (!solution) {
                return no_solution_fn();
            } else {
                // some constraints may have been postponed (example: universe level constraints)
                return lazy_list<constraints>(to_cnstrs_fn(subst, cnstrs));
            }
        } else {
            if (try_multiple_instances(env, *cls_name_it)) {
                lazy_list<constraints> seq3 = map2<constraints>(seq2, [=](pair<substitution, constraints> const & p) {
                        return to_cnstrs_fn(p.first, p.second);
                    });
                if (is_strict) {
                    return seq3;
                } else {
                    // make sure it does not fail by appending empty set of constraints
                    return append(seq3, lazy_list<constraints>(constraints()));
                }
            } else {
                auto p  = seq2.pull();
                if (!p)
                    return no_solution_fn();
                else
                    return lazy_list<constraints>(to_cnstrs_fn(p->first.first, p->first.second));
            }
        }
    };
    bool owner = false;
    bool relax = C->m_relax;
    return mk_choice_cnstr(m, choice_fn, factor, owner, j, relax);
}