Merge tag 'for-6.2-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-block.git] / fs / btrfs / send.c
index 26dace7b74c60d4ab1f9fcea1ba144e9a38436ea..d50182b6deec8fec035f9735b1a5e6ecefb8e27e 100644 (file)
@@ -485,6 +485,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
        path_len = p->end - p->start;
        old_buf_len = p->buf_len;
 
+       /*
+        * Allocate to the next largest kmalloc bucket size, to let
+        * the fast path happen most of the time.
+        */
+       len = kmalloc_size_roundup(len);
        /*
         * First time the inline_buf does not suffice
         */
@@ -498,11 +503,7 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
        if (!tmp_buf)
                return -ENOMEM;
        p->buf = tmp_buf;
-       /*
-        * The real size of the buffer is bigger, this will let the fast path
-        * happen most of the time
-        */
-       p->buf_len = ksize(p->buf);
+       p->buf_len = len;
 
        if (p->reversed) {
                tmp_buf = p->buf + old_buf_len - path_len - 1;