Merge tag 'for-6.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 2 Jan 2023 19:06:18 +0000 (11:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 2 Jan 2023 19:06:18 +0000 (11:06 -0800)
Pull btrfs fixes from David Sterba:
 "First batch of regression and regular fixes:

   - regressions:
       - fix error handling after conversion to qstr for paths
       - fix raid56/scrub recovery caused by uninitialized variable
         after conversion to error bitmaps
       - restore qgroup backref lookup behaviour after recent
         refactoring
       - fix leak of device lists at module exit time

   - fix resolving backrefs for inline extent followed by prealloc

   - reset defrag ioctl buffer on memory allocation error"

* tag 'for-6.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix fscrypt name leak after failure to join log transaction
  btrfs: scrub: fix uninitialized return value in recover_scrub_rbio
  btrfs: fix resolving backrefs for inline extent followed by prealloc
  btrfs: fix trace event name typo for FLUSH_DELAYED_REFS
  btrfs: restore BTRFS_SEQ_LAST when looking up qgroup backref lookup
  btrfs: fix leak of fs devices after removing btrfs module
  btrfs: fix an error handling path in btrfs_defrag_leaves()
  btrfs: fix an error handling path in btrfs_rename()

fs/btrfs/backref.c
fs/btrfs/defrag.c
fs/btrfs/inode.c
fs/btrfs/qgroup.c
fs/btrfs/raid56.c
fs/btrfs/super.c
fs/btrfs/tree-log.c
include/trace/events/btrfs.h

index 21c92c74bf71a4742a69902d8037531fb7b86b31..46851511b661b38810bde878648d939aeeeb9331 100644 (file)
@@ -484,6 +484,7 @@ static int add_all_parents(struct btrfs_backref_walk_ctx *ctx,
        u64 wanted_disk_byte = ref->wanted_disk_byte;
        u64 count = 0;
        u64 data_offset;
+       u8 type;
 
        if (level != 0) {
                eb = path->nodes[level];
@@ -538,6 +539,9 @@ static int add_all_parents(struct btrfs_backref_walk_ctx *ctx,
                        continue;
                }
                fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item);
+               type = btrfs_file_extent_type(eb, fi);
+               if (type == BTRFS_FILE_EXTENT_INLINE)
+                       goto next;
                disk_byte = btrfs_file_extent_disk_bytenr(eb, fi);
                data_offset = btrfs_file_extent_offset(eb, fi);
 
index 0a3c261b69c9f95ec56c1623bcc7f695bb0bdc54..d81b764a76446ba2b083995c7a40b1c8c0d6be5c 100644 (file)
@@ -358,8 +358,10 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
                goto out;
 
        path = btrfs_alloc_path();
-       if (!path)
-               return -ENOMEM;
+       if (!path) {
+               ret = -ENOMEM;
+               goto out;
+       }
 
        level = btrfs_header_level(root->node);
 
index 8bcad994015487e9a049c7f0d99b1f685176afa8..2ead7b1bdbaf141489ac3186f2d7817d18aa636d 100644 (file)
@@ -9377,8 +9377,10 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
 
        if (flags & RENAME_WHITEOUT) {
                whiteout_args.inode = new_whiteout_inode(mnt_userns, old_dir);
-               if (!whiteout_args.inode)
-                       return -ENOMEM;
+               if (!whiteout_args.inode) {
+                       ret = -ENOMEM;
+                       goto out_fscrypt_names;
+               }
                ret = btrfs_new_inode_prepare(&whiteout_args, &trans_num_items);
                if (ret)
                        goto out_whiteout_inode;
index 5c636e00d77da395a3dbccecadb17b4a02d3879a..d275bf24b250bdfdf78af7d5bdb7f63953660c38 100644 (file)
@@ -2787,6 +2787,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans)
                         * current root. It's safe inside commit_transaction().
                         */
                        ctx.trans = trans;
+                       ctx.time_seq = BTRFS_SEQ_LAST;
                        ret = btrfs_find_all_roots(&ctx, false);
                        if (ret < 0)
                                goto cleanup;
index 2d90a6b5eb00e319c36aed30d330cae6a622ceb2..6a2cf754912df27a9573aeb5f11e8bc85d217aa0 100644 (file)
@@ -2646,7 +2646,7 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
        void **pointers = NULL;
        void **unmap_array = NULL;
        int sector_nr;
-       int ret;
+       int ret = 0;
 
        /*
         * @pointers array stores the pointer for each sector.
index 93f52ee85f6fe9735f379ff9fae3169eba042eb6..d5de18d6517e730066cc2eda0696534a20658920 100644 (file)
@@ -2514,6 +2514,7 @@ static __always_inline void btrfs_exit_btrfs_fs(void)
 static void __exit exit_btrfs_fs(void)
 {
        btrfs_exit_btrfs_fs();
+       btrfs_cleanup_fs_uuids();
 }
 
 static int __init init_btrfs_fs(void)
index a3c43f0b1c95c0aafbc61cccf963aad8850f6dc4..fb52aa0600930102e8f519396b2c7298229c5889 100644 (file)
@@ -7459,8 +7459,11 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
                 * not fail, but if it does, it's not serious, just bail out and
                 * mark the log for a full commit.
                 */
-               if (WARN_ON_ONCE(ret < 0))
+               if (WARN_ON_ONCE(ret < 0)) {
+                       fscrypt_free_filename(&fname);
                        goto out;
+               }
+
                log_pinned = true;
 
                path = btrfs_alloc_path();
index 0bce0b4ff2faf32d9e7a511b127c9a8c87f067be..6548b5b5aa60803c571a2b5fee19ea53dcfc1ee2 100644 (file)
@@ -98,7 +98,7 @@ struct raid56_bio_trace_info;
        EM( FLUSH_DELALLOC_WAIT,        "FLUSH_DELALLOC_WAIT")          \
        EM( FLUSH_DELALLOC_FULL,        "FLUSH_DELALLOC_FULL")          \
        EM( FLUSH_DELAYED_REFS_NR,      "FLUSH_DELAYED_REFS_NR")        \
-       EM( FLUSH_DELAYED_REFS,         "FLUSH_ELAYED_REFS")            \
+       EM( FLUSH_DELAYED_REFS,         "FLUSH_DELAYED_REFS")           \
        EM( ALLOC_CHUNK,                "ALLOC_CHUNK")                  \
        EM( ALLOC_CHUNK_FORCE,          "ALLOC_CHUNK_FORCE")            \
        EM( RUN_DELAYED_IPUTS,          "RUN_DELAYED_IPUTS")            \