Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Stefan N <stefannnau@gmail.com>,
	Qu Wenruo <quwenruo.btrfs@gmx.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: Out of space loop: skip_balance not working
Date: Sat, 17 Jun 2023 13:30:39 +0800	[thread overview]
Message-ID: <403c9e19-e58e-8857-bee8-dd9f9d8fc34f@suse.com> (raw)
In-Reply-To: <CA+W5K0pm+Aum0vQGeRfUCsH_4x8+L3O+baUfRJM-iWdh+tDwNA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2505 bytes --]



On 2023/6/17 13:11, Stefan N wrote:
> Hi Qu,
> 
> I believe I've got this environment ready, with the 6.2.0 kernel as
> before using the Ubuntu kernel, but can switch to vanilla if required.
> 
> I've not done anything kernel modifications for a solid decade, so
> would be keen for a bit of guidance.

Sure no problem.

Please fetch the kernel source tar ball (6.2.x) first, decompress, then 
apply the attached one-line patch by:

$ tar czf linux*.tar.xz
$ cd linux*
$ patch -np1 -i <the patch file>

Then use your running system kernel config if possible:

$ cp /proc/config.gz .
$ gunzip config.gz
$ mv config .config
$ make olddefconfig

Then you can start your kernel compiling, and considering you're using 
your distro's default, it would include tons of drivers, thus would be 
very slow. (Replace the number to something more suitable to your 
system, using all CPU cores can be very hot)

$ make -j12

Finally you need to install the modules/kernel.

Unfortunately this is distro specific, but if you're using Ubuntu, it 
may be much easier:

$ make bindeb-pkg

Then install the generated dpkg I guess? I have never tried kernel 
building using deb/rpm, but only manual installation, which is also 
distro dependent in the initramfs generation part.

# cp arch/x86/boot/bzImage /boot/vmlinuz-custom
# make modules_install
# mkinitcpio -k /boot/vmlinuz-custom -g /boot/initramfs-custom.img


The last step is to update your bootloader to add the new kernel, which 
is not only distro dependent but also bootloader dependent.

In my case, I go with systemd-boot with manually crafted entries.
But if you go Ubuntu I believe just installing the kernel dpkg would 
have everything handled?

Finally you can try reboot into the newer kernel, and try device add 
(need to add 4 disks), then sync and see if things work as expected.

Thanks,
Qu
> 
> I will recover a 1tb SSD and partition it into 4 in a USB enclosure,
> but failing this will use 4x loop devices.
> 
> On Tue, 13 Jun 2023 at 11:28, Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>> In your particular case, since you're running RAID1C4 you need to add 4
>> devices in one transaction.
>>
>> I can easily craft a patch to avoid commit transaction, but still you'll
>> need to add at least 4 disks, and then sync to see if things would work.
>>
>> Furthermore this means you need a liveCD with full kernel compiling
>> environment.
>>
>> If you want to go this path, I can send you the patch when you've
>> prepared the needed environment.

[-- Attachment #2: 0001-btrfs-do-not-commit-transaction-when-adding-a-new-de.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]

From b55b383150a185d367dd3b7a820dbe1efc5cfc9d Mon Sep 17 00:00:00 2001
Message-ID: <b55b383150a185d367dd3b7a820dbe1efc5cfc9d.1686979163.git.wqu@suse.com>
From: Qu Wenruo <wqu@suse.com>
Date: Sat, 17 Jun 2023 13:15:30 +0800
Subject: [PATCH] btrfs: do not commit transaction when adding a new device

This is to address a ENOSPC situation where one has to add more than one
disks before having enough space to commit the current transaction.
(Including the one to add a new device).

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index df43093b7a46..b8f68d58f498 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2773,7 +2773,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 		btrfs_sysfs_update_sprout_fsid(fs_devices);
 	}
 
-	ret = btrfs_commit_transaction(trans);
+	ret = btrfs_end_transaction(trans);
 
 	if (seeding_dev) {
 		mutex_unlock(&uuid_mutex);
-- 
2.41.0


  reply	other threads:[~2023-06-17  5:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  4:47 Out of space loop: skip_balance not working Stefan N
2023-06-12  5:20 ` Qu Wenruo
2023-06-12 10:31   ` Stefan N
2023-06-12 10:46     ` Qu Wenruo
2023-06-12 13:02       ` Stefan N
2023-06-13  1:29         ` Paul Jones
2023-06-13  1:54           ` Stefan N
2023-06-13  1:58             ` Qu Wenruo
2023-06-17  5:11               ` Stefan N
2023-06-17  5:30                 ` Qu Wenruo [this message]
2023-06-22  8:33                   ` Stefan N
2023-06-22  9:18                     ` Qu Wenruo
2023-06-22 22:18                       ` Stefan N
2023-06-23  0:57                         ` Qu Wenruo
2023-06-23  9:00                           ` Stefan N
2023-06-23  9:46                             ` Qu Wenruo
2023-06-24 15:29                               ` Stefan N
2023-06-26 10:18                                 ` Qu Wenruo
2023-06-26 12:58                                   ` Stefan N
2023-07-22  5:28                                     ` Stefan N
2023-07-22 10:08                                       ` Qu Wenruo
     [not found]                                         ` <CA+W5K0oDRo2LZMiUiysYXpcpmfXTvS27hPdjm1pzq4kfq9=vdQ@mail.gmail.com>
2023-07-23  7:23                                           ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=403c9e19-e58e-8857-bee8-dd9f9d8fc34f@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=stefannnau@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox