]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Update bcachefs sources to 259ff91605 bcachefs: Don't keep around btree_paths unneces...
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 5 Mar 2022 22:06:24 +0000 (17:06 -0500)
committerKent Overstreet <kent.overstreet@gmail.com>
Sat, 5 Mar 2022 22:06:24 +0000 (17:06 -0500)
.bcachefs_revision
libbcachefs/btree_iter.c
libbcachefs/disk_groups.c
libbcachefs/disk_groups.h
libbcachefs/fs.c
libbcachefs/opts.c
libbcachefs/opts.h
libbcachefs/super-io.c
libbcachefs/super.c
libbcachefs/sysfs.c
libbcachefs/xattr.c

index 671d0fb8367097bcdd080f237d37b004913c8a70..619cb82895a8aecc2a929376f00b8452c1fb9019 100644 (file)
@@ -1 +1 @@
-b64d9b7b192a641ef4ea036d6e465e8cfe82e83c
+259ff916050fb6a9ff742891fb8aa379924a187f
index c0357ee9cfb78a102ce1a50848b58e818b66f5a9..8186ee7e23ff7d0b263479630e961200af692a59 100644 (file)
@@ -3016,6 +3016,14 @@ void bch2_trans_begin(struct btree_trans *trans)
        trans_for_each_path(trans, path) {
                path->should_be_locked = false;
 
+               /*
+                * If the transaction wasn't restarted, we're presuming to be
+                * doing something new: dont keep iterators excpt the ones that
+                * are in use - except for the subvolumes btree:
+                */
+               if (!trans->restarted && path->btree_id != BTREE_ID_subvolumes)
+                       path->preserve = false;
+
                /*
                 * XXX: we probably shouldn't be doing this if the transaction
                 * was restarted, but currently we still overflow transaction
index 19698e504b3cb9fb27c673ef36e11cd2491a49ea..81b41b07c24b21b1a2914234ba231b6977416180 100644 (file)
@@ -445,7 +445,10 @@ int bch2_opt_target_parse(struct bch_fs *c, const char *buf, u64 *v)
        return -EINVAL;
 }
 
-void bch2_sb_target_to_text(struct printbuf *out, struct bch_sb *sb, u64 v)
+void bch2_opt_target_to_text(struct printbuf *out,
+                            struct bch_fs *c,
+                            struct bch_sb *sb,
+                            u64 v)
 {
        struct target t = target_decode(v);
 
@@ -453,63 +456,49 @@ void bch2_sb_target_to_text(struct printbuf *out, struct bch_sb *sb, u64 v)
        case TARGET_NULL:
                pr_buf(out, "none");
                break;
-       case TARGET_DEV: {
-               struct bch_sb_field_members *mi = bch2_sb_get_members(sb);
-               struct bch_member *m = mi->members + t.dev;
-
-               if (bch2_dev_exists(sb, mi, t.dev)) {
-                       pr_buf(out, "Device ");
-                       pr_uuid(out, m->uuid.b);
-                       pr_buf(out, " (%u)", t.dev);
+       case TARGET_DEV:
+               if (c) {
+                       struct bch_dev *ca;
+
+                       rcu_read_lock();
+                       ca = t.dev < c->sb.nr_devices
+                               ? rcu_dereference(c->devs[t.dev])
+                               : NULL;
+
+                       if (ca && percpu_ref_tryget(&ca->io_ref)) {
+                               char b[BDEVNAME_SIZE];
+
+                               pr_buf(out, "/dev/%s",
+                                      bdevname(ca->disk_sb.bdev, b));
+                               percpu_ref_put(&ca->io_ref);
+                       } else if (ca) {
+                               pr_buf(out, "offline device %u", t.dev);
+                       } else {
+                               pr_buf(out, "invalid device %u", t.dev);
+                       }
+
+                       rcu_read_unlock();
                } else {
-                       pr_buf(out, "Bad device %u", t.dev);
+                       struct bch_sb_field_members *mi = bch2_sb_get_members(sb);
+                       struct bch_member *m = mi->members + t.dev;
+
+                       if (bch2_dev_exists(sb, mi, t.dev)) {
+                               pr_buf(out, "Device ");
+                               pr_uuid(out, m->uuid.b);
+                               pr_buf(out, " (%u)", t.dev);
+                       } else {
+                               pr_buf(out, "Bad device %u", t.dev);
+                       }
                }
-
                break;
-       }
        case TARGET_GROUP:
-               bch2_disk_path_to_text(out, sb, t.group);
-               break;
-       default:
-               BUG();
-       }
-}
-
-void bch2_opt_target_to_text(struct printbuf *out, struct bch_fs *c, u64 v)
-{
-       struct target t = target_decode(v);
-
-       switch (t.type) {
-       case TARGET_NULL:
-               pr_buf(out, "none");
-               break;
-       case TARGET_DEV: {
-               struct bch_dev *ca;
-
-               rcu_read_lock();
-               ca = t.dev < c->sb.nr_devices
-                       ? rcu_dereference(c->devs[t.dev])
-                       : NULL;
-
-               if (ca && percpu_ref_tryget(&ca->io_ref)) {
-                       char b[BDEVNAME_SIZE];
-
-                       pr_buf(out, "/dev/%s",
-                            bdevname(ca->disk_sb.bdev, b));
-                       percpu_ref_put(&ca->io_ref);
-               } else if (ca) {
-                       pr_buf(out, "offline device %u", t.dev);
+               if (c) {
+                       mutex_lock(&c->sb_lock);
+                       bch2_disk_path_to_text(out, c->disk_sb.sb, t.group);
+                       mutex_unlock(&c->sb_lock);
                } else {
-                       pr_buf(out, "invalid device %u", t.dev);
+                       bch2_disk_path_to_text(out, sb, t.group);
                }
-
-               rcu_read_unlock();
-               break;
-       }
-       case TARGET_GROUP:
-               mutex_lock(&c->sb_lock);
-               bch2_disk_path_to_text(out, c->disk_sb.sb, t.group);
-               mutex_unlock(&c->sb_lock);
                break;
        default:
                BUG();
index a274aacbdf921e5360aca39227f93488d49e5aa8..de915480514b10a4a4a692b84d00d9b5f6724b40 100644 (file)
@@ -77,10 +77,8 @@ int bch2_disk_path_find_or_create(struct bch_sb_handle *, const char *);
 
 void bch2_disk_path_to_text(struct printbuf *, struct bch_sb *, unsigned);
 
-void bch2_sb_target_to_text(struct printbuf *, struct bch_sb *, u64);
-
 int bch2_opt_target_parse(struct bch_fs *, const char *, u64 *);
-void bch2_opt_target_to_text(struct printbuf *, struct bch_fs *, u64);
+void bch2_opt_target_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
 
 int bch2_sb_disk_groups_to_cpu(struct bch_fs *);
 
index f6e961324f7e86271f7bb8f91ee2e8f808b3d742..30720c14778dae245ae35d2d0676e26f6429974b 100644 (file)
@@ -933,7 +933,8 @@ retry:
        bch2_trans_iter_init(&trans, &iter, BTREE_ID_extents,
                             SPOS(ei->v.i_ino, start, snapshot), 0);
 
-       while ((k = bch2_btree_iter_peek(&iter)).k &&
+       while (!(ret = btree_trans_too_many_iters(&trans)) &&
+              (k = bch2_btree_iter_peek(&iter)).k &&
               !(ret = bkey_err(k)) &&
               bkey_cmp(iter.pos, end) < 0) {
                enum btree_id data_btree = BTREE_ID_extents;
@@ -980,9 +981,6 @@ retry:
 
                bch2_btree_iter_set_pos(&iter,
                        POS(iter.pos.inode, iter.pos.offset + sectors));
-
-               if (btree_trans_too_many_iters(&trans))
-                       goto retry;
        }
        start = iter.pos.offset;
        bch2_trans_iter_exit(&trans, &iter);
@@ -1691,7 +1689,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
                        continue;
 
                printbuf_reset(&buf);
-               bch2_opt_to_text(&buf, c, opt, v,
+               bch2_opt_to_text(&buf, c, c->disk_sb.sb, opt, v,
                                 OPT_SHOW_MOUNT_STYLE);
                seq_putc(seq, ',');
                seq_puts(seq, buf.buf);
index 15acbabc6b8d4f3646663c69b6cc09172da85dce..e78d3b75f6fbef3b3e36c4b6f021da1fe7470827 100644 (file)
@@ -290,7 +290,8 @@ int bch2_opt_parse(struct bch_fs *c, const char *msg,
        return bch2_opt_validate(opt, msg, *res);
 }
 
-void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
+void bch2_opt_to_text(struct printbuf *out,
+                     struct bch_fs *c, struct bch_sb *sb,
                      const struct bch_option *opt, u64 v,
                      unsigned flags)
 {
@@ -320,7 +321,7 @@ void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
                        pr_buf(out, opt->choices[v]);
                break;
        case BCH_OPT_FN:
-               opt->to_text(out, c, v);
+               opt->to_text(out, c, sb, v);
                break;
        default:
                BUG();
index 9e68f1002d8dddae816e35d7986e94681240fee1..033115f7a6f4b1b2111aef6631ca60d273211e04 100644 (file)
@@ -461,7 +461,7 @@ struct bch_option {
        };
        struct {
                int (*parse)(struct bch_fs *, const char *, u64 *);
-               void (*to_text)(struct printbuf *, struct bch_fs *, u64);
+               void (*to_text)(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
        };
        };
 
@@ -488,7 +488,7 @@ int bch2_opt_parse(struct bch_fs *, const char *, const struct bch_option *,
 #define OPT_SHOW_FULL_LIST     (1 << 0)
 #define OPT_SHOW_MOUNT_STYLE   (1 << 1)
 
-void bch2_opt_to_text(struct printbuf *, struct bch_fs *,
+void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *,
                      const struct bch_option *, u64, unsigned);
 
 int bch2_opt_check_may_set(struct bch_fs *, int, u64);
index d87edaadaa27ab10e139271b6f0227282035c328..e17ce91c8486fac640f321d583fd8df8e03b4e1a 100644 (file)
@@ -1619,7 +1619,8 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
 
                                pr_buf(out, "%s:", opt->attr.name);
                                pr_tab(out);
-                               bch2_opt_to_text(out, NULL, opt, v, OPT_HUMAN_READABLE|OPT_SHOW_FULL_LIST);
+                               bch2_opt_to_text(out, NULL, sb, opt, v,
+                                                OPT_HUMAN_READABLE|OPT_SHOW_FULL_LIST);
                                pr_newline(out);
                        }
                }
index fb7f8d6d4d1c282b7d9df77b8c1e1c5576eb1f00..46947163a8dcead4ca6d189127d2929d7f16cbba 100644 (file)
@@ -886,7 +886,7 @@ static void print_mount_opts(struct bch_fs *c)
                if (!first)
                        pr_buf(&p, ",");
                first = false;
-               bch2_opt_to_text(&p, c, opt, v, OPT_SHOW_MOUNT_STYLE);
+               bch2_opt_to_text(&p, c, c->disk_sb.sb, opt, v, OPT_SHOW_MOUNT_STYLE);
        }
 
        if (!p.pos)
index 3018250d421b8794e839d9cff4d570adc61ffc8e..49e38859bff819b1d3c21e54504b46473b5fd4d3 100644 (file)
@@ -597,7 +597,7 @@ SHOW(bch2_fs_opts_dir)
        int id = opt - bch2_opt_table;
        u64 v = bch2_opt_get_by_id(&c->opts, id);
 
-       bch2_opt_to_text(out, c, opt, v, OPT_SHOW_FULL_LIST);
+       bch2_opt_to_text(out, c, c->disk_sb.sb, opt, v, OPT_SHOW_FULL_LIST);
        pr_char(out, '\n');
 
        return 0;
index 48e625ab15ff4feb0fae21d1a8b29d2329c112fd..c2e9520a0457959f6b00ccfa7982dd7693e5172f 100644 (file)
@@ -448,7 +448,7 @@ static int __bch2_xattr_bcachefs_get(const struct xattr_handler *handler,
                return -ENODATA;
 
        v = bch2_opt_get_by_id(&opts, id);
-       bch2_opt_to_text(&out, c, opt, v, 0);
+       bch2_opt_to_text(&out, c, c->disk_sb.sb, opt, v, 0);
 
        ret = out.pos;