@@ -380,10 +380,14 @@ struct content_region *content_mmap_region_lookup (struct content_mmap *mm,
380380static struct content_region * content_mmap_region_create (
381381 struct content_mmap * mm ,
382382 const char * path ,
383- const char * fpath ,
384- struct blobvec_param * param ,
383+ int chunksize ,
385384 flux_error_t * error )
386385{
386+ struct blobvec_param param = {
387+ .hashtype = mm -> hash_name ,
388+ .chunksize = chunksize ,
389+ .small_file_threshold = 0 , // always choose blobvec encoding here
390+ };
387391 struct content_region * reg ;
388392
389393 if (!(reg = calloc (1 , sizeof (* reg )))) {
@@ -393,15 +397,22 @@ static struct content_region *content_mmap_region_create (
393397 reg -> refcount = 1 ;
394398 reg -> mm = mm ;
395399 reg -> mapinfo .base = MAP_FAILED ;
396- if (!(reg -> fullpath = strdup (fpath )))
400+ if (!(reg -> fullpath = strdup (path )))
397401 goto error ;
398402
399403 if (!(reg -> fileref = fileref_create_ex (path ,
400- fpath ,
401- param ,
404+ & param ,
402405 & reg -> mapinfo ,
403406 error )))
404407 goto error ;
408+ /* fileref_create_ex() accepts all file types, but flux-archive(1) should
409+ * not be requesting that files be mapped which do not meet criteria.
410+ */
411+ if (reg -> mapinfo .base == MAP_FAILED ) {
412+ errprintf (error , "%s: not suitable for mapping" , path );
413+ errno = EINVAL ;
414+ goto error ;
415+ }
405416 if (region_cache_add (reg ) < 0 ) {
406417 errprintf (error ,
407418 "%s: error caching region blobrefs: %s" ,
@@ -415,70 +426,41 @@ static struct content_region *content_mmap_region_create (
415426 return NULL ;
416427}
417428
418- static int check_string_array (json_t * o , int min_count )
419- {
420- size_t index ;
421- json_t * entry ;
422-
423- if (!json_is_array (o )
424- || json_array_size (o ) < min_count )
425- goto error ;
426- json_array_foreach (o , index , entry ) {
427- if (!json_is_string (entry ))
428- goto error ;
429- }
430- return 0 ;
431- error :
432- errno = EPROTO ;
433- return -1 ;
434- }
435-
436429static void content_mmap_add_cb (flux_t * h ,
437430 flux_msg_handler_t * mh ,
438431 const flux_msg_t * msg ,
439432 void * arg )
440433{
441434 struct content_mmap * mm = arg ;
442435 const char * path ;
443- const char * fpath = NULL ;
444- int disable_mmap ;
445- struct blobvec_param param ;
446- json_t * tags ;
436+ int chunksize ;
437+ const char * tag ;
447438 struct content_region * reg = NULL ;
448439 flux_error_t error ;
449440 const char * errmsg = NULL ;
450- size_t index ;
451- json_t * entry ;
452441
453442 if (flux_request_unpack (msg ,
454443 NULL ,
455- "{s:s s?s s:b s: i s:i s:o }" ,
444+ "{s:s s: i s:s }" ,
456445 "path" , & path ,
457- "fullpath" , & fpath ,
458- "disable_mmap" , & disable_mmap ,
459- "chunksize" , & param .chunksize ,
460- "threshold" , & param .small_file_threshold ,
461- "tags" , & tags ) < 0
462- || check_string_array (tags , 1 ) < 0 )
446+ "chunksize" , & chunksize ,
447+ "tag" , & tag ) < 0 )
463448 goto error ;
464449 if (mm -> rank != 0 ) {
465450 errmsg = "content may only be mmapped on rank 0" ;
466451 goto inval ;
467452 }
468- param .hashtype = mm -> hash_name ;
469- if (!(reg = content_mmap_region_create (mm ,
470- path ,
471- fpath ,
472- disable_mmap ? NULL : & param ,
473- & error ))) {
453+ if (path [0 ] != '/' ) {
454+ errmsg = "path must be fully qualified" ;
455+ goto inval ;
456+ }
457+ if (!(reg = content_mmap_region_create (mm , path , chunksize , & error ))) {
474458 errmsg = error .text ;
475459 goto error ;
476460 }
477- json_array_foreach (tags , index , entry ) {
478- // takes a reference on region
479- if (!hola_list_add_end (mm -> tags , json_string_value (entry ), reg ))
480- goto error ;
481- }
461+ // takes a reference on region
462+ if (!hola_list_add_end (mm -> tags , tag , reg ))
463+ goto error ;
482464 if (flux_respond (h , msg , NULL ) < 0 )
483465 flux_log_error (h , "error responding to content.mmap-add request" );
484466 content_mmap_region_decref (reg );
@@ -498,22 +480,17 @@ static void content_mmap_remove_cb (flux_t *h,
498480{
499481 struct content_mmap * mm = arg ;
500482 const char * errmsg = NULL ;
501- json_t * tags ;
502- size_t index ;
503- json_t * entry ;
483+ const char * tag ;
504484 int unmap_count = 0 ;
505485
506- if (flux_request_unpack (msg , NULL , "{s:o}" , "tags" , & tags ) < 0
507- || check_string_array (tags , 1 ) < 0 )
486+ if (flux_request_unpack (msg , NULL , "{s:s}" , "tag" , & tag ) < 0 )
508487 goto error ;
509488 if (mm -> rank != 0 ) {
510489 errmsg = "content can only be mmapped on rank 0" ;
511490 goto inval ;
512491 }
513- json_array_foreach (tags , index , entry ) {
514- if (hola_hash_delete (mm -> tags , json_string_value (entry )) == 0 )
515- unmap_count ++ ;
516- }
492+ if (hola_hash_delete (mm -> tags , tag ) == 0 )
493+ unmap_count ++ ;
517494 if (unmap_count > 0 ) {
518495 if (plug_cache_holes (mm ) < 0 ) {
519496 errmsg = "error filling missing cache entries after unmap" ;
0 commit comments