3333
3434struct fsck_ctx {
3535 flux_t * h ;
36+ bool validate_available ;
3637 json_t * root ;
3738 int sequence ;
3839 int repair_count ;
@@ -136,6 +137,8 @@ static void valref_validate_continuation (flux_future_t *f, void *arg)
136137
137138static void valref_validate (struct fsck_valref_data * fvd )
138139{
140+ const char * topic = fvd -> ctx -> validate_available ?
141+ "content-backing.validate" : "content-backing.load" ;
139142 uint32_t hash [BLOBREF_MAX_DIGEST_SIZE ];
140143 ssize_t hash_size ;
141144 const char * blobref ;
@@ -147,13 +150,9 @@ static void valref_validate (struct fsck_valref_data *fvd)
147150 if ((hash_size = blobref_strtohash (blobref , hash , sizeof (hash ))) < 0 )
148151 log_err_exit ("cannot get hash from ref string" );
149152
150- if (!(f = flux_rpc_raw (fvd -> ctx -> h ,
151- "content-backing.validate" ,
152- hash ,
153- hash_size ,
154- 0 ,
155- 0 ))
156- || flux_future_then (f , -1 , valref_validate_continuation , fvd ) < 0 )
153+ if (!(f = flux_rpc_raw (fvd -> ctx -> h , topic , hash , hash_size , 0 , 0 )))
154+ log_err_exit ("failed to validate valref blob" );
155+ if (flux_future_then (f , -1 , valref_validate_continuation , fvd ) < 0 )
157156 log_err_exit ("cannot validate valref blob" );
158157 if (!(indexp = (int * )malloc (sizeof (int ))))
159158 log_err_exit ("cannot allocate index memory" );
@@ -636,6 +635,32 @@ static void sync_checkpoint (struct fsck_ctx *ctx)
636635 fprintf (stderr , "Updated primary checkpoint to include lost+found\n" );
637636}
638637
638+ /* "validate" support added in v0.77.0. Use "load" for backwards
639+ * compatibility if "validate" is not available.
640+ */
641+ static void check_validate_available (struct fsck_ctx * ctx , const char * blobref )
642+ {
643+ uint32_t hash [BLOBREF_MAX_DIGEST_SIZE ];
644+ ssize_t hash_size ;
645+ flux_future_t * f ;
646+
647+ if ((hash_size = blobref_strtohash (blobref , hash , sizeof (hash ))) < 0 )
648+ log_err_exit ("cannot get hash from ref string" );
649+
650+ ctx -> validate_available = true;
651+ // doesn't matter if the request is correct, we are looking for ENOSYS
652+ if ((f = flux_rpc_raw (ctx -> h ,
653+ "content-backing.validate" ,
654+ hash ,
655+ hash_size ,
656+ 0 ,
657+ 0 ))
658+ && flux_rpc_get (f , NULL ) < 0
659+ && errno == ENOSYS )
660+ ctx -> validate_available = false;
661+ flux_future_destroy (f );
662+ }
663+
639664static int cmd_fsck (optparse_t * p , int ac , char * av [])
640665{
641666 struct fsck_ctx ctx = {0 };
@@ -695,6 +720,8 @@ static int cmd_fsck (optparse_t *p, int ac, char *av[])
695720 ctx .sequence = sequence ;
696721 }
697722
723+ check_validate_available (& ctx , blobref );
724+
698725 fsck_blobref (& ctx , blobref );
699726
700727 flux_future_destroy (f );
0 commit comments