@@ -574,6 +574,11 @@ static inline void prt_bytes_reversed(struct printbuf *out, const void *b, unsig
574
574
printbuf_nul_terminate (out );
575
575
}
576
576
577
+ static inline void prt_str_reversed (struct printbuf * out , const char * s )
578
+ {
579
+ prt_bytes_reversed (out , s , strlen (s ));
580
+ }
581
+
577
582
static inline void reverse_bytes (void * b , size_t n )
578
583
{
579
584
char * e = b + n , * s = b ;
@@ -596,25 +601,25 @@ int bch2_inum_to_path(struct btree_trans *trans, subvol_inum inum, struct printb
596
601
struct bch_inode_unpacked inode ;
597
602
ret = bch2_inode_find_by_inum_trans (trans , inum , & inode );
598
603
if (ret )
599
- goto err ;
604
+ goto disconnected ;
600
605
601
606
if (!inode .bi_dir && !inode .bi_dir_offset ) {
602
607
ret = - BCH_ERR_ENOENT_inode_no_backpointer ;
603
- goto err ;
608
+ goto disconnected ;
604
609
}
605
610
606
611
u32 snapshot ;
607
612
ret = bch2_subvolume_get_snapshot (trans , inum .subvol , & snapshot );
608
613
if (ret )
609
- goto err ;
614
+ goto disconnected ;
610
615
611
616
struct btree_iter d_iter ;
612
617
struct bkey_s_c_dirent d = bch2_bkey_get_iter_typed (trans , & d_iter ,
613
618
BTREE_ID_dirents , SPOS (inode .bi_dir , inode .bi_dir_offset , snapshot ),
614
619
0 , dirent );
615
620
ret = bkey_err (d .s_c );
616
621
if (ret )
617
- goto err ;
622
+ goto disconnected ;
618
623
619
624
struct qstr dirent_name = bch2_dirent_get_name (d );
620
625
prt_bytes_reversed (path , dirent_name .name , dirent_name .len );
@@ -630,7 +635,7 @@ int bch2_inum_to_path(struct btree_trans *trans, subvol_inum inum, struct printb
630
635
631
636
if (orig_pos == path -> pos )
632
637
prt_char (path , '/' );
633
-
638
+ out :
634
639
ret = path -> allocation_failure ? - ENOMEM : 0 ;
635
640
if (ret )
636
641
goto err ;
@@ -639,4 +644,10 @@ int bch2_inum_to_path(struct btree_trans *trans, subvol_inum inum, struct printb
639
644
return 0 ;
640
645
err :
641
646
return ret ;
647
+ disconnected :
648
+ if (bch2_err_matches (ret , BCH_ERR_transaction_restart ))
649
+ goto err ;
650
+
651
+ prt_str_reversed (path , "(disconnected)" );
652
+ goto out ;
642
653
}
0 commit comments