@@ -1728,10 +1728,12 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned disk_label,
17281728
17291729 rcu_read_lock ();
17301730 h -> devs = target_rw_devs (c , BCH_DATA_user , disk_label ? group_to_target (disk_label - 1 ) : 0 );
1731+ unsigned nr_devs = dev_mask_nr (& h -> devs );
17311732
17321733 for_each_member_device_rcu (c , ca , & h -> devs )
17331734 if (!ca -> mi .durability )
17341735 __clear_bit (ca -> dev_idx , h -> devs .d );
1736+ unsigned nr_devs_with_durability = dev_mask_nr (& h -> devs );
17351737
17361738 h -> blocksize = pick_blocksize (c , & h -> devs );
17371739
@@ -1745,9 +1747,20 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned disk_label,
17451747 * If we only have redundancy + 1 devices, we're better off with just
17461748 * replication:
17471749 */
1748- if (h -> nr_active_devs < h -> redundancy + 2 )
1749- bch_err (c , "insufficient devices available to create stripe (have %u, need %u) - mismatched bucket sizes?" ,
1750- h -> nr_active_devs , h -> redundancy + 2 );
1750+ if (h -> nr_active_devs < h -> redundancy + 2 ) {
1751+ const char * err ;
1752+
1753+ if (nr_devs < h -> redundancy + 2 )
1754+ err = NULL ;
1755+ else if (nr_devs_with_durability < h -> redundancy + 2 )
1756+ err = "cannot use durability=0 devices" ;
1757+ else
1758+ err = "mismatched bucket sizes" ;
1759+
1760+ if (err )
1761+ bch_err (c , "insufficient devices available to create stripe (have %u, need %u): %s" ,
1762+ h -> nr_active_devs , h -> redundancy + 2 , err );
1763+ }
17511764
17521765 list_add (& h -> list , & c -> ec_stripe_head_list );
17531766 return h ;
0 commit comments