Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz
Cc: Li Zhang <zhanglikernel@gmail.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-prog: scrub: print message when scrubbing a read-only filesystem without r option
Date: Thu, 4 Jul 2024 09:49:52 +0930	[thread overview]
Message-ID: <d7e06214-0166-4db2-836c-36b2abde054b@gmx.com> (raw)
In-Reply-To: <20240704001309.GV21023@twin.jikos.cz>



在 2024/7/4 09:43, David Sterba 写道:
> On Thu, Jul 04, 2024 at 08:56:47AM +0930, Qu Wenruo wrote:
>>> --- a/cmds/scrub.c
>>> +++ b/cmds/scrub.c
>>> @@ -957,7 +957,10 @@ static void *scrub_one_dev(void *ctx)
>>>    		warning("setting ioprio failed: %m (ignored)");
>>>
>>>    	ret = ioctl(sp->fd, BTRFS_IOC_SCRUB, &sp->scrub_args);
>>> -        pr_verbose(LOG_DEFAULT, "scrub ioctl devid:%llu ret:%d errno:%d\n",sp->scrub_args.devid, ret, errno);
>>> +	if (ret){
>>> +		pr_verbose(LOG_DEFAULT, "scrub on devid %llu failed ret=%d errno=%d (%m)\n",
>>> +			sp->scrub_args.devid, ret, errno);
>>> +	}
>>
>> Doing direct output inside a thread can lead to race of the output.
>
> We'd have to communicate the ioctl start errors back to the main thread,
> or rely on internal locking of printf, that it can race is possible but
> as long as the string is printed in one go we'll get only lines
> reordered.
>
>> And we do not know if the scrub ioctl would return error early or run
>> for a long long time, that's the dilemma.
>>
>> I'm wondering if it's possible to do a blkid/mountinfo based probe.
>> Then it would avoid the possible output race and error out earilier.
>
> We can detet read/write status of the block devices. I'm not sure about
> the mount info, what function can we use for that?
>

E.g, setmntent() and getmntent() used inside check_mounted_where()?

Since mntent structure provides mnt_opts, it should not be that hard to
find if the destination mount point is mounted ro?

Thanks,
Qu

  reply	other threads:[~2024-07-04  0:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 17:47 [PATCH] btrfs-prog: scrub: print message when scrubbing a read-only filesystem without r option Li Zhang
2024-07-03 23:26 ` Qu Wenruo
2024-07-04  0:13   ` David Sterba
2024-07-04  0:19     ` Qu Wenruo [this message]
2024-07-04  0:22       ` David Sterba
2024-07-05 16:06         ` li zhang

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=d7e06214-0166-4db2-836c-36b2abde054b@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zhanglikernel@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