@@ -434,6 +434,8 @@ void bch2_submit_wbio_replicas(struct bch_write_bio *wbio, struct bch_fs *c,
434434 n -> nocow = nocow ;
435435 n -> submit_time = local_clock ();
436436 n -> inode_offset = bkey_start_offset (& k -> k );
437+ if (nocow )
438+ n -> nocow_bucket = PTR_BUCKET_NR (ca , ptr );
437439 n -> bio .bi_iter .bi_sector = ptr -> offset ;
438440
439441 if (likely (n -> have_ioref )) {
@@ -659,8 +661,12 @@ static void bch2_write_endio(struct bio *bio)
659661 op -> flags |= BCH_WRITE_IO_ERROR ;
660662 }
661663
662- if (wbio -> nocow )
664+ if (wbio -> nocow ) {
665+ bch2_bucket_nocow_unlock (& c -> nocow_locks ,
666+ POS (ca -> dev_idx , wbio -> nocow_bucket ),
667+ BUCKET_NOCOW_LOCK_UPDATE );
663668 set_bit (wbio -> dev , op -> devs_need_flush -> d );
669+ }
664670
665671 if (wbio -> have_ioref ) {
666672 bch2_latency_acct (ca , wbio -> submit_time , WRITE );
@@ -1114,22 +1120,6 @@ static bool bch2_extent_is_writeable(struct bch_write_op *op,
11141120 return replicas >= op -> opts .data_replicas ;
11151121}
11161122
1117- static inline void bch2_nocow_write_unlock (struct bch_write_op * op )
1118- {
1119- struct bch_fs * c = op -> c ;
1120-
1121- for_each_keylist_key (& op -> insert_keys , k ) {
1122- struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c (bkey_i_to_s_c (k ));
1123-
1124- bkey_for_each_ptr (ptrs , ptr ) {
1125- struct bch_dev * ca = bch2_dev_bkey_exists (c , ptr -> dev );
1126- bch2_bucket_nocow_unlock (& c -> nocow_locks ,
1127- PTR_BUCKET_POS (ca , ptr ),
1128- BUCKET_NOCOW_LOCK_UPDATE );
1129- }
1130- }
1131- }
1132-
11331123static int bch2_nocow_write_convert_one_unwritten (struct btree_trans * trans ,
11341124 struct btree_iter * iter ,
11351125 struct bkey_i * orig ,
@@ -1200,8 +1190,6 @@ static void bch2_nocow_write_convert_unwritten(struct bch_write_op *op)
12001190
12011191static void __bch2_nocow_write_done (struct bch_write_op * op )
12021192{
1203- bch2_nocow_write_unlock (op );
1204-
12051193 if (unlikely (op -> flags & BCH_WRITE_IO_ERROR )) {
12061194 op -> error = - EIO ;
12071195 } else if (unlikely (op -> flags & BCH_WRITE_CONVERT_UNWRITTEN ))
0 commit comments