@@ -1728,10 +1728,12 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned disk_label,
1728
1728
1729
1729
rcu_read_lock ();
1730
1730
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 );
1731
1732
1732
1733
for_each_member_device_rcu (c , ca , & h -> devs )
1733
1734
if (!ca -> mi .durability )
1734
1735
__clear_bit (ca -> dev_idx , h -> devs .d );
1736
+ unsigned nr_devs_with_durability = dev_mask_nr (& h -> devs );
1735
1737
1736
1738
h -> blocksize = pick_blocksize (c , & h -> devs );
1737
1739
@@ -1745,9 +1747,20 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned disk_label,
1745
1747
* If we only have redundancy + 1 devices, we're better off with just
1746
1748
* replication:
1747
1749
*/
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
+ }
1751
1764
1752
1765
list_add (& h -> list , & c -> ec_stripe_head_list );
1753
1766
return h ;
0 commit comments