]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/io.c
Update bcachefs sources to 33a60d9b05 bcachefs: Assorted fixes for clang
[bcachefs-tools-debian] / libbcachefs / io.c
index 77fe49f6c4147f5a10bea0c5c159250a2c222672..5bacc6a9dd8fb57cc6e58610db92b006fb0e3f80 100644 (file)
@@ -150,11 +150,11 @@ static bool bch2_target_congested(struct bch_fs *c, u16 target)
 void bch2_bio_free_pages_pool(struct bch_fs *c, struct bio *bio)
 {
        struct bvec_iter_all iter;
-       struct bio_vec bv;
+       struct bio_vec *bv;
 
        bio_for_each_segment_all(bv, bio, iter)
-               if (bv.bv_page != ZERO_PAGE(0))
-                       mempool_free(bv.bv_page, &c->bio_bounce_pages);
+               if (bv->bv_page != ZERO_PAGE(0))
+                       mempool_free(bv->bv_page, &c->bio_bounce_pages);
        bio->bi_vcnt = 0;
 }
 
@@ -451,7 +451,7 @@ retry:
                                &devs_have,
                                opts.data_replicas,
                                opts.data_replicas,
-                               RESERVE_none, 0, &cl, &wp);
+                               BCH_WATERMARK_normal, 0, &cl, &wp);
                if (ret) {
                        bch2_trans_unlock(trans);
                        closure_sync(&cl);
@@ -1078,11 +1078,12 @@ static enum prep_encoded_ret {
        /* Can we just write the entire extent as is? */
        if (op->crc.uncompressed_size == op->crc.live_size &&
            op->crc.compressed_size <= wp->sectors_free &&
-           (op->crc.compression_type == op->compression_type ||
+           (op->crc.compression_type == bch2_compression_opt_to_type(op->compression_opt) ||
             op->incompressible)) {
                if (!crc_is_compressed(op->crc) &&
                    op->csum_type != op->crc.csum_type &&
-                   bch2_write_rechecksum(c, op, op->csum_type))
+                   bch2_write_rechecksum(c, op, op->csum_type) &&
+                   !c->opts.no_data_io)
                        return PREP_ENCODED_CHECKSUM_ERR;
 
                return PREP_ENCODED_DO_WRITE;
@@ -1102,7 +1103,7 @@ static enum prep_encoded_ret {
                csum = bch2_checksum_bio(c, op->crc.csum_type,
                                         extent_nonce(op->version, op->crc),
                                         bio);
-               if (bch2_crc_cmp(op->crc.csum, csum))
+               if (bch2_crc_cmp(op->crc.csum, csum) && !c->opts.no_data_io)
                        return PREP_ENCODED_CHECKSUM_ERR;
 
                if (bch2_bio_uncompress_inplace(c, bio, &op->crc))
@@ -1120,13 +1121,14 @@ static enum prep_encoded_ret {
         */
        if ((op->crc.live_size != op->crc.uncompressed_size ||
             op->crc.csum_type != op->csum_type) &&
-           bch2_write_rechecksum(c, op, op->csum_type))
+           bch2_write_rechecksum(c, op, op->csum_type) &&
+           !c->opts.no_data_io)
                return PREP_ENCODED_CHECKSUM_ERR;
 
        /*
         * If we want to compress the data, it has to be decrypted:
         */
-       if ((op->compression_type ||
+       if ((op->compression_opt ||
             bch2_csum_type_is_encryption(op->crc.csum_type) !=
             bch2_csum_type_is_encryption(op->csum_type)) &&
            bch2_write_decrypt(op))
@@ -1173,7 +1175,7 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
        }
 
        if (ec_buf ||
-           op->compression_type ||
+           op->compression_opt ||
            (op->csum_type &&
             !(op->flags & BCH_WRITE_PAGES_STABLE)) ||
            (bch2_csum_type_is_encryption(op->csum_type) &&
@@ -1196,16 +1198,16 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
                    dst->bi_iter.bi_size < c->opts.encoded_extent_max)
                        break;
 
-               BUG_ON(op->compression_type &&
+               BUG_ON(op->compression_opt &&
                       (op->flags & BCH_WRITE_DATA_ENCODED) &&
                       bch2_csum_type_is_encryption(op->crc.csum_type));
-               BUG_ON(op->compression_type && !bounce);
+               BUG_ON(op->compression_opt && !bounce);
 
                crc.compression_type = op->incompressible
                        ? BCH_COMPRESSION_TYPE_incompressible
-                       : op->compression_type
+                       : op->compression_opt
                        ? bch2_bio_compress(c, dst, &dst_len, src, &src_len,
-                                           op->compression_type)
+                                           op->compression_opt)
                        : 0;
                if (!crc_is_compressed(crc)) {
                        dst_len = min(dst->bi_iter.bi_size, src->bi_iter.bi_size);
@@ -1645,7 +1647,7 @@ err_bucket_stale:
                percpu_ref_put(&bch_dev_bkey_exists(c, buckets[i].b.inode)->io_ref);
 
        /* We can retry this: */
-       ret = BCH_ERR_transaction_restart;
+       ret = -BCH_ERR_transaction_restart;
        goto out;
 }
 
@@ -1696,7 +1698,7 @@ again:
                                &op->devs_have,
                                op->nr_replicas,
                                op->nr_replicas_required,
-                               op->alloc_reserve,
+                               op->watermark,
                                op->flags,
                                (op->flags & (BCH_WRITE_ALLOC_NOWAIT|
                                              BCH_WRITE_ONLY_SPECIFIED_DEVS))
@@ -1878,7 +1880,7 @@ err:
                op->end_io(op);
 }
 
-const char * const bch2_write_flags[] = {
+static const char * const bch2_write_flags[] = {
 #define x(f)   #f,
        BCH_WRITE_FLAGS()
 #undef x
@@ -2057,10 +2059,11 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
                                .write_flags    = BCH_WRITE_ALLOC_NOWAIT|BCH_WRITE_CACHED,
                        },
                        btree_id, k);
+       /*
+        * possible errors: -BCH_ERR_nocow_lock_blocked,
+        * -BCH_ERR_ENOSPC_disk_reservation:
+        */
        if (ret) {
-               WARN_ONCE(ret != -BCH_ERR_nocow_lock_blocked,
-                         "%s: saw unknown error %s\n", __func__, bch2_err_str(ret));
-
                ret = rhashtable_remove_fast(&c->promote_table, &op->hash,
                                        bch_promote_params);
                BUG_ON(ret);
@@ -2415,7 +2418,8 @@ static void __bch2_read_endio(struct work_struct *work)
                if (ret)
                        goto decrypt_err;
 
-               if (bch2_bio_uncompress(c, src, dst, dst_iter, crc))
+               if (bch2_bio_uncompress(c, src, dst, dst_iter, crc) &&
+                   !c->opts.no_data_io)
                        goto decompression_err;
        } else {
                /* don't need to decrypt the entire bio: */