From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz, Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC] btrfs-progs: mkfs: optimize file descriptor usage in mkfs.btrfs
Date: Fri, 2 Feb 2024 07:22:38 +0530 [thread overview]
Message-ID: <3d693d91-0a6e-43ea-a114-43a25904022b@oracle.com> (raw)
In-Reply-To: <20240201191811.GX31555@twin.jikos.cz>
On 2/2/24 00:48, David Sterba wrote:
> On Wed, Jan 31, 2024 at 03:48:00PM -0500, Josef Bacik wrote:
>> On Wed, Jan 31, 2024 at 11:49:28PM +0800, Anand Jain wrote:
>>> This cleanup patch reuses the main file descriptor (fd1) in open_ctree(),
>>> and with this change both the test cases (with partition and without
>>> partition) now runs fine.
>>>
>>> I've done an initial tests only, not validated with the multi-device mkfs.
>>> More cleanup is possible but pending feedback; marking this patch as an RFC.
>>
>> I'd like to see the cleaned up version of this patch, but I have a few comments.
>>
>> 1) I think re-using the fd is reasonable, tho could this just be reworked to
>> create the temp-sb and write this to all the devs, close the file
>> descriptors, and then call open_ctree?
Multiple sequential open-close maybe fine.
> This would trigger the udev unnecessarily and could let other processes
> to eg. try to mount the device (like systemd did or maybe still does).
> This could fail the second open_ctree.
I think you are missing the point that when we write the temp-sb, there
is no valid BTRFS magic. As a result, the kernel won't get the scan, and
systemd won't attempt to mount.
However, there will be a udev event (due to the write-close), and in
this udev event, we shall have:
ID_FS_UUID=<blank>
This action cleans the /dev/disk/by-uuid directory, which is fine.
> That it's all done with one fd
> open reduces possible interactions that could be problematic.
Hmm reduced possible interactions is problematic? I didn't get this.
Here is the sequence of events to help discuss:
Consider a single device, for now:
fd1 writes zero and temp-sb.
fd2 writes good-sb.
fd2 closes.
fd1 closes.
Please note that the fd which wrote zero/temp-sb (fd1) closes last.
Per udevadm monitor the change event OR the UUID is missing (depending
on the systemd version).
ID_FS_UUID=<blank> instead of ID_FS_UUID=<UUID>
>> 2) I hate adding another thing into a core file that we'll have to figure out
>> how to undo later as we sync more code from the kernel into btrfs-progs, I'm
>> not sure if there's a way around this, but thinking harder about adding
>> something to disk-io.c that is for userspace only would be good.
>
> Yeah the open_ctree functions in progs are misplaced in disk-io.c and
> are there for historical reasons. We'd need separate file (or maybe
> whole compat directory) but for now let it be there, the cleanup is
> going to be big.
Thanks, Anand
next prev parent reply other threads:[~2024-02-02 1:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 15:49 [PATCH RFC] btrfs-progs: mkfs: optimize file descriptor usage in mkfs.btrfs Anand Jain
2024-01-31 20:48 ` Josef Bacik
2024-02-01 8:49 ` Qu Wenruo
2024-02-01 19:07 ` David Sterba
2024-02-01 20:50 ` Qu Wenruo
2024-02-01 19:18 ` David Sterba
2024-02-02 1:52 ` Anand Jain [this message]
2024-02-01 21:59 ` 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=3d693d91-0a6e-43ea-a114-43a25904022b@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/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