]> Git Repo - J-linux.git/commitdiff
Merge tag 'bcachefs-2024-01-21' of https://evilpiepirate.org/git/bcachefs
authorLinus Torvalds <[email protected]>
Sun, 21 Jan 2024 22:01:12 +0000 (14:01 -0800)
committerLinus Torvalds <[email protected]>
Sun, 21 Jan 2024 22:01:12 +0000 (14:01 -0800)
Pull more bcachefs updates from Kent Overstreet:
 "Some fixes, Some refactoring, some minor features:

   - Assorted prep work for disk space accounting rewrite

   - BTREE_TRIGGER_ATOMIC: after combining our trigger callbacks, this
     makes our trigger context more explicit

   - A few fixes to avoid excessive transaction restarts on
     multithreaded workloads: fstests (in addition to ktest tests) are
     now checking slowpath counters, and that's shaking out a few bugs

   - Assorted tracepoint improvements

   - Starting to break up bcachefs_format.h and move on disk types so
     they're with the code they belong to; this will make room to start
     documenting the on disk format better.

   - A few minor fixes"

* tag 'bcachefs-2024-01-21' of https://evilpiepirate.org/git/bcachefs: (46 commits)
  bcachefs: Improve inode_to_text()
  bcachefs: logged_ops_format.h
  bcachefs: reflink_format.h
  bcachefs; extents_format.h
  bcachefs: ec_format.h
  bcachefs: subvolume_format.h
  bcachefs: snapshot_format.h
  bcachefs: alloc_background_format.h
  bcachefs: xattr_format.h
  bcachefs: dirent_format.h
  bcachefs: inode_format.h
  bcachefs; quota_format.h
  bcachefs: sb-counters_format.h
  bcachefs: counters.c -> sb-counters.c
  bcachefs: comment bch_subvolume
  bcachefs: bch_snapshot::btime
  bcachefs: add missing __GFP_NOWARN
  bcachefs: opts->compression can now also be applied in the background
  bcachefs: Prep work for variable size btree node buffers
  bcachefs: grab s_umount only if snapshotting
  ...

1  2 
fs/bcachefs/fs-ioctl.c
fs/bcachefs/super-io.c
fs/bcachefs/super.c

diff --combined fs/bcachefs/fs-ioctl.c
index 1cbc5807bc807ba700875152d08f766f466ec40a,1346861ed9443da15cf6864ab2e762af386992be..3a4c24c28e7fa06deff38f6bb0b240a5daacda8c
@@@ -287,12 -287,12 +287,12 @@@ static int bch2_ioc_goingdown(struct bc
  
        switch (flags) {
        case FSOP_GOING_FLAGS_DEFAULT:
 -              ret = freeze_bdev(c->vfs_sb->s_bdev);
 +              ret = bdev_freeze(c->vfs_sb->s_bdev);
                if (ret)
                        break;
                bch2_journal_flush(&c->journal);
                bch2_fs_emergency_read_only(c);
 -              thaw_bdev(c->vfs_sb->s_bdev);
 +              bdev_thaw(c->vfs_sb->s_bdev);
                break;
        case FSOP_GOING_FLAGS_LOGFLUSH:
                bch2_journal_flush(&c->journal);
@@@ -337,11 -337,12 +337,12 @@@ static long __bch2_ioctl_subvolume_crea
        if (arg.flags & BCH_SUBVOL_SNAPSHOT_RO)
                create_flags |= BCH_CREATE_SNAPSHOT_RO;
  
-       /* why do we need this lock? */
-       down_read(&c->vfs_sb->s_umount);
-       if (arg.flags & BCH_SUBVOL_SNAPSHOT_CREATE)
+       if (arg.flags & BCH_SUBVOL_SNAPSHOT_CREATE) {
+               /* sync_inodes_sb enforce s_umount is locked */
+               down_read(&c->vfs_sb->s_umount);
                sync_inodes_sb(c->vfs_sb);
+               up_read(&c->vfs_sb->s_umount);
+       }
  retry:
        if (arg.src_ptr) {
                error = user_path_at(arg.dirfd,
@@@ -425,8 -426,6 +426,6 @@@ err2
                goto retry;
        }
  err1:
-       up_read(&c->vfs_sb->s_umount);
        return error;
  }
  
@@@ -443,36 -442,33 +442,36 @@@ static long bch2_ioctl_subvolume_create
  static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
                                struct bch_ioctl_subvolume arg)
  {
 +      const char __user *name = (void __user *)(unsigned long)arg.dst_ptr;
        struct path path;
        struct inode *dir;
 +      struct dentry *victim;
        int ret = 0;
  
        if (arg.flags)
                return -EINVAL;
  
 -      ret = user_path_at(arg.dirfd,
 -                      (const char __user *)(unsigned long)arg.dst_ptr,
 -                      LOOKUP_FOLLOW, &path);
 -      if (ret)
 -              return ret;
 +      victim = user_path_locked_at(arg.dirfd, name, &path);
 +      if (IS_ERR(victim))
 +              return PTR_ERR(victim);
  
 -      if (path.dentry->d_sb->s_fs_info != c) {
 +      if (victim->d_sb->s_fs_info != c) {
                ret = -EXDEV;
                goto err;
        }
 -
 -      dir = path.dentry->d_parent->d_inode;
 -
 -      ret = __bch2_unlink(dir, path.dentry, true);
 -      if (ret)
 +      if (!d_is_positive(victim)) {
 +              ret = -ENOENT;
                goto err;
 -
 -      fsnotify_rmdir(dir, path.dentry);
 -      d_delete(path.dentry);
 +      }
 +      dir = d_inode(path.dentry);
 +      ret = __bch2_unlink(dir, victim, true);
 +      if (!ret) {
 +              fsnotify_rmdir(dir, victim);
 +              d_delete(victim);
 +      }
 +      inode_unlock(dir);
  err:
 +      dput(victim);
        path_put(&path);
        return ret;
  }
diff --combined fs/bcachefs/super-io.c
index 6d3db5cce5f6ac9e315500c14fbb5e1d97ea8098,4e4da1a5e5d78d8c4e0b4811f23202bcb009a338..d60c7d27a0477cb0de116675671d5c888d8f1c86
@@@ -2,7 -2,6 +2,6 @@@
  
  #include "bcachefs.h"
  #include "checksum.h"
- #include "counters.h"
  #include "disk_groups.h"
  #include "ec.h"
  #include "error.h"
@@@ -13,6 -12,7 +12,7 @@@
  #include "replicas.h"
  #include "quota.h"
  #include "sb-clean.h"
+ #include "sb-counters.h"
  #include "sb-downgrade.h"
  #include "sb-errors.h"
  #include "sb-members.h"
@@@ -142,8 -142,8 +142,8 @@@ void bch2_sb_field_delete(struct bch_sb
  void bch2_free_super(struct bch_sb_handle *sb)
  {
        kfree(sb->bio);
 -      if (!IS_ERR_OR_NULL(sb->bdev))
 -              blkdev_put(sb->bdev, sb->holder);
 +      if (!IS_ERR_OR_NULL(sb->bdev_handle))
 +              bdev_release(sb->bdev_handle);
        kfree(sb->holder);
        kfree(sb->sb_name);
  
@@@ -704,22 -704,21 +704,22 @@@ retry
        if (!opt_get(*opts, nochanges))
                sb->mode |= BLK_OPEN_WRITE;
  
 -      sb->bdev = blkdev_get_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
 -      if (IS_ERR(sb->bdev) &&
 -          PTR_ERR(sb->bdev) == -EACCES &&
 +      sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
 +      if (IS_ERR(sb->bdev_handle) &&
 +          PTR_ERR(sb->bdev_handle) == -EACCES &&
            opt_get(*opts, read_only)) {
                sb->mode &= ~BLK_OPEN_WRITE;
  
 -              sb->bdev = blkdev_get_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
 -              if (!IS_ERR(sb->bdev))
 +              sb->bdev_handle = bdev_open_by_path(path, sb->mode, sb->holder, &bch2_sb_handle_bdev_ops);
 +              if (!IS_ERR(sb->bdev_handle))
                        opt_set(*opts, nochanges, true);
        }
  
 -      if (IS_ERR(sb->bdev)) {
 -              ret = PTR_ERR(sb->bdev);
 +      if (IS_ERR(sb->bdev_handle)) {
 +              ret = PTR_ERR(sb->bdev_handle);
                goto out;
        }
 +      sb->bdev = sb->bdev_handle->bdev;
  
        ret = bch2_sb_realloc(sb, 0);
        if (ret) {
@@@ -1321,7 -1320,9 +1321,9 @@@ void bch2_sb_to_text(struct printbuf *o
  
        prt_printf(out, "Superblock size:");
        prt_tab(out);
-       prt_printf(out, "%zu", vstruct_bytes(sb));
+       prt_units_u64(out, vstruct_bytes(sb));
+       prt_str(out, "/");
+       prt_units_u64(out, 512ULL << sb->layout.sb_max_size_bits);
        prt_newline(out);
  
        prt_printf(out, "Clean:");
diff --combined fs/bcachefs/super.c
index cefe52898e8ebce68e82a9dfc7fb8ed3cda23cb1,670fe1e6733ad34d500617115db947fd9828629f..b9911402b1753baa986a1673339c4454eba87431
@@@ -23,7 -23,6 +23,6 @@@
  #include "checksum.h"
  #include "clock.h"
  #include "compress.h"
- #include "counters.h"
  #include "debug.h"
  #include "disk_groups.h"
  #include "ec.h"
@@@ -49,6 -48,7 +48,7 @@@
  #include "recovery.h"
  #include "replicas.h"
  #include "sb-clean.h"
+ #include "sb-counters.h"
  #include "sb-errors.h"
  #include "sb-members.h"
  #include "snapshot.h"
@@@ -883,7 -883,7 +883,7 @@@ static struct bch_fs *bch2_fs_alloc(str
            !(c->pcpu = alloc_percpu(struct bch_fs_pcpu)) ||
            !(c->online_reserved = alloc_percpu(u64)) ||
            mempool_init_kvpmalloc_pool(&c->btree_bounce_pool, 1,
-                                       btree_bytes(c)) ||
+                                       c->opts.btree_node_size) ||
            mempool_init_kmalloc_pool(&c->large_bkey_pool, 1, 2048) ||
            !(c->unused_inode_hints = kcalloc(1U << c->inode_shard_bits,
                                              sizeof(u64), GFP_KERNEL))) {
@@@ -1386,8 -1386,8 +1386,8 @@@ static int bch2_dev_attach_bdev(struct 
        prt_bdevname(&name, ca->disk_sb.bdev);
  
        if (c->sb.nr_devices == 1)
 -              strlcpy(c->name, name.buf, sizeof(c->name));
 -      strlcpy(ca->name, name.buf, sizeof(ca->name));
 +              strscpy(c->name, name.buf, sizeof(c->name));
 +      strscpy(ca->name, name.buf, sizeof(ca->name));
  
        printbuf_exit(&name);
  
@@@ -1625,7 -1625,7 +1625,7 @@@ int bch2_dev_remove(struct bch_fs *c, s
        if (data) {
                struct printbuf data_has = PRINTBUF;
  
-               prt_bitflags(&data_has, bch2_data_types, data);
+               prt_bitflags(&data_has, __bch2_data_types, data);
                bch_err(ca, "Remove failed, still has data (%s)", data_has.buf);
                printbuf_exit(&data_has);
                ret = -EBUSY;
This page took 0.064929 seconds and 4 git commands to generate.