]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Update bcachefs sources to f9d2e809a8 bcachefs: Turn encoded_extent_max into a regula...
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 22 Dec 2021 04:42:46 +0000 (23:42 -0500)
committerKent Overstreet <kent.overstreet@gmail.com>
Sat, 25 Dec 2021 23:48:46 +0000 (18:48 -0500)
.bcachefs_revision
libbcachefs.c
libbcachefs.h
libbcachefs/bcachefs.h
libbcachefs/compress.c
libbcachefs/ec.c
libbcachefs/extents.c
libbcachefs/io.c
libbcachefs/opts.h
libbcachefs/super-io.c

index 9b6ed5382aba7915cdff23924bb769084a2d1934..6b23844363abe63a5958838589ada034f24d58d4 100644 (file)
@@ -1 +1 @@
-aa540d47abe2c4ab53fcf2a6d118dfda13800b56
+f9d2e809a8c3b3a3c6bb0f8fe8e646425f7fce8d
index ed4f65f29f77200f093293a0320c259b011cea7c..16f15a8d54679835eeace84412e74bed99b1941e 100644 (file)
@@ -211,9 +211,6 @@ struct bch_sb *bch2_format(struct bch_opt_strs      fs_opt_strs,
                __bch2_opt_set_sb(sb.sb, &bch2_opt_table[opt_id], v);
        }
 
-       SET_BCH_SB_ENCODED_EXTENT_MAX_BITS(sb.sb,
-                               ilog2(opts.encoded_extent_max));
-
        struct timespec now;
        if (clock_gettime(CLOCK_REALTIME, &now))
                die("error getting current time: %m");
index b5f9673f368ee1476ec20e3e86dbc859efdbd5e0..ef90bf2eef702d39c7df4c2e086620a2aa5cec98 100644 (file)
@@ -35,7 +35,6 @@ struct format_opts {
        uuid_le         uuid;
        unsigned        version;
        unsigned        superblock_size;
-       unsigned        encoded_extent_max;
        bool            encrypted;
        char            *passphrase;
 };
@@ -45,7 +44,6 @@ static inline struct format_opts format_opts_default()
        return (struct format_opts) {
                .version                = bcachefs_metadata_version_current,
                .superblock_size        = SUPERBLOCK_SIZE_DEFAULT,
-               .encoded_extent_max     = 128,
        };
 }
 
index 02074a7f59fbe769af249f91e1f4d13dd3213ea7..943487f2c6f5c4d79080c133a2a53596615093da 100644 (file)
@@ -634,7 +634,6 @@ struct bch_fs {
 
                u16             version;
                u16             version_min;
-               u16             encoded_extent_max;
 
                u8              nr_devices;
                u8              clean;
index fd7885dc78ed09cefe2bc2b8833997056b51702d..8e4179d8dc2764d883916cbca64d4a11deb98d4a 100644 (file)
@@ -26,7 +26,7 @@ static struct bbuf __bounce_alloc(struct bch_fs *c, unsigned size, int rw)
 {
        void *b;
 
-       BUG_ON(size > c->sb.encoded_extent_max << 9);
+       BUG_ON(size > c->opts.encoded_extent_max);
 
        b = kmalloc(size, GFP_NOIO|__GFP_NOWARN);
        if (b)
@@ -68,7 +68,7 @@ static struct bbuf __bio_map_or_bounce(struct bch_fs *c, struct bio *bio,
        struct page **pages = NULL;
        void *data;
 
-       BUG_ON(bvec_iter_sectors(start) > c->sb.encoded_extent_max);
+       BUG_ON(start.bi_size > c->opts.encoded_extent_max);
 
        if (!PageHighMem(bio_iter_page(bio, start)) &&
            bio_phys_contig(bio, start))
@@ -231,8 +231,8 @@ int bch2_bio_uncompress_inplace(struct bch_fs *c, struct bio *bio,
        BUG_ON(!bio->bi_vcnt);
        BUG_ON(DIV_ROUND_UP(crc->live_size, PAGE_SECTORS) > bio->bi_max_vecs);
 
-       if (crc->uncompressed_size      > c->sb.encoded_extent_max ||
-           crc->compressed_size        > c->sb.encoded_extent_max) {
+       if (crc->uncompressed_size << 9 > c->opts.encoded_extent_max ||
+           crc->compressed_size << 9   > c->opts.encoded_extent_max) {
                bch_err(c, "error rewriting existing data: extent too big");
                return -EIO;
        }
@@ -272,8 +272,8 @@ int bch2_bio_uncompress(struct bch_fs *c, struct bio *src,
        size_t dst_len = crc.uncompressed_size << 9;
        int ret = -ENOMEM;
 
-       if (crc.uncompressed_size       > c->sb.encoded_extent_max ||
-           crc.compressed_size         > c->sb.encoded_extent_max)
+       if (crc.uncompressed_size << 9  > c->opts.encoded_extent_max ||
+           crc.compressed_size << 9    > c->opts.encoded_extent_max)
                return -EIO;
 
        dst_data = dst_len == dst_iter.bi_size
@@ -466,7 +466,7 @@ unsigned bch2_bio_compress(struct bch_fs *c,
 
        /* Don't consume more than BCH_ENCODED_EXTENT_MAX from @src: */
        src->bi_iter.bi_size = min_t(unsigned, src->bi_iter.bi_size,
-                                    c->sb.encoded_extent_max << 9);
+                                    c->opts.encoded_extent_max);
        /* Don't generate a bigger output than input: */
        dst->bi_iter.bi_size = min(dst->bi_iter.bi_size, src->bi_iter.bi_size);
 
@@ -544,10 +544,9 @@ void bch2_fs_compress_exit(struct bch_fs *c)
 
 static int __bch2_fs_compress_init(struct bch_fs *c, u64 features)
 {
-       size_t max_extent = c->sb.encoded_extent_max << 9;
        size_t decompress_workspace_size = 0;
        bool decompress_workspace_needed;
-       ZSTD_parameters params = ZSTD_getParams(0, max_extent, 0);
+       ZSTD_parameters params = ZSTD_getParams(0, c->opts.encoded_extent_max, 0);
        struct {
                unsigned        feature;
                unsigned        type;
@@ -579,14 +578,14 @@ have_compressed:
 
        if (!mempool_initialized(&c->compression_bounce[READ])) {
                ret = mempool_init_kvpmalloc_pool(&c->compression_bounce[READ],
-                                                 1, max_extent);
+                                                 1, c->opts.encoded_extent_max);
                if (ret)
                        goto out;
        }
 
        if (!mempool_initialized(&c->compression_bounce[WRITE])) {
                ret = mempool_init_kvpmalloc_pool(&c->compression_bounce[WRITE],
-                                                 1, max_extent);
+                                                 1, c->opts.encoded_extent_max);
                if (ret)
                        goto out;
        }
index 033ded88687502393db3943995dfc97798ddab93..7d78672dd017ecfa522869e0024d3f81dcd8b2d2 100644 (file)
@@ -1152,7 +1152,7 @@ static void ec_stripe_key_init(struct bch_fs *c,
        s->v.algorithm                  = 0;
        s->v.nr_blocks                  = nr_data + nr_parity;
        s->v.nr_redundant               = nr_parity;
-       s->v.csum_granularity_bits      = ilog2(c->sb.encoded_extent_max);
+       s->v.csum_granularity_bits      = ilog2(c->opts.encoded_extent_max >> 9);
        s->v.csum_type                  = BCH_CSUM_crc32c;
        s->v.pad                        = 0;
 
index 145b3868e5223a167680bf8bf7ef2fe894bb9182..44c584e9adaa8691a6335e10b70dab66e9a2bd0d 100644 (file)
@@ -303,7 +303,7 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r)
 
                        if (lp.crc.csum_type &&
                            lp.crc.uncompressed_size +
-                           rp.crc.uncompressed_size > c->sb.encoded_extent_max)
+                           rp.crc.uncompressed_size > (c->opts.encoded_extent_max >> 9))
                                return false;
 
                        if (lp.crc.uncompressed_size + rp.crc.uncompressed_size >
index 6e64a04d7f91fef80f577058724705818952d78d..1b954dff5d15116e538a6fab49917d014539901c 100644 (file)
@@ -738,7 +738,7 @@ static struct bio *bch2_write_bio_alloc(struct bch_fs *c,
         */
        bch2_bio_alloc_pages_pool(c, bio,
                                  min_t(unsigned, output_available,
-                                       c->sb.encoded_extent_max << 9));
+                                       c->opts.encoded_extent_max));
 
        if (bio->bi_iter.bi_size < output_available)
                *page_alloc_failed =
@@ -935,8 +935,8 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
                size_t dst_len, src_len;
 
                if (page_alloc_failed &&
-                   bio_sectors(dst) < wp->sectors_free &&
-                   bio_sectors(dst) < c->sb.encoded_extent_max)
+                   dst->bi_iter.bi_size  < (wp->sectors_free << 9) &&
+                   dst->bi_iter.bi_size < c->opts.encoded_extent_max)
                        break;
 
                BUG_ON(op->compression_type &&
@@ -956,7 +956,7 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
 
                        if (op->csum_type)
                                dst_len = min_t(unsigned, dst_len,
-                                               c->sb.encoded_extent_max << 9);
+                                               c->opts.encoded_extent_max);
 
                        if (bounce) {
                                swap(dst->bi_iter.bi_size, dst_len);
@@ -2365,9 +2365,9 @@ int bch2_fs_io_init(struct bch_fs *c)
                        BIOSET_NEED_BVECS) ||
            mempool_init_page_pool(&c->bio_bounce_pages,
                                   max_t(unsigned,
-                                        btree_sectors(c),
-                                        c->sb.encoded_extent_max) /
-                                  PAGE_SECTORS, 0) ||
+                                        c->opts.btree_node_size,
+                                        c->opts.encoded_extent_max) /
+                                  PAGE_SIZE, 0) ||
            rhashtable_init(&c->promote_table, &bch_promote_params))
                return -ENOMEM;
 
index 60fe0301c4b7ab73a33803ea20c46d13a584f512..aadd3958f53ddf4a8828286f9a2f5b40c16e0156 100644 (file)
@@ -127,6 +127,12 @@ enum opt_type {
          OPT_UINT(1, BCH_REPLICAS_MAX),                                \
          BCH_SB_DATA_REPLICAS_REQ,     1,                              \
          "#",          NULL)                                           \
+       x(encoded_extent_max,           u32,                            \
+         OPT_FS|OPT_FORMAT|                                            \
+         OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS|OPT_SB_FIELD_ILOG2,\
+         OPT_UINT(4096, 2U << 20),                                     \
+         BCH_SB_ENCODED_EXTENT_MAX_BITS, 64 << 10,                     \
+         "size",       "Maximum size of checksummed/compressed extents")\
        x(metadata_checksum,            u8,                             \
          OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
          OPT_STR(bch2_csum_opts),                                      \
index 3df4c977061e3951a4da711cb6ebf4ed9a30cb06..b8d2cf66a63020d9c4954b844c991b20cfaa2c3a 100644 (file)
@@ -362,7 +362,6 @@ static void bch2_sb_update(struct bch_fs *c)
        c->sb.nr_devices        = src->nr_devices;
        c->sb.clean             = BCH_SB_CLEAN(src);
        c->sb.encryption_type   = BCH_SB_ENCRYPTION_TYPE(src);
-       c->sb.encoded_extent_max= 1 << BCH_SB_ENCODED_EXTENT_MAX_BITS(src);
 
        c->sb.nsec_per_time_unit = le32_to_cpu(src->time_precision);
        c->sb.time_units_per_sec = NSEC_PER_SEC / c->sb.nsec_per_time_unit;