linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.com, gpiccoli@igalia.com
Subject: Re: [PATCH 4/4] btrfs: show temp_fsid feature in sysfs
Date: Sat, 7 Oct 2023 14:42:19 +0530	[thread overview]
Message-ID: <b658ef3f-9fd0-45a1-8950-c86f4f1b450c@oracle.com> (raw)
In-Reply-To: <20231006145550.GG28758@twin.jikos.cz>



On 10/6/23 22:55, David Sterba wrote:
> On Wed, Oct 04, 2023 at 11:00:27PM +0800, Anand Jain wrote:
>> This adds sysfs objects to indicate temp_fsid feature support and
>> its status.
>>
>>    /sys/fs/btrfs/features/temp_fsid
>>    /sys/fs/btrfs/<UUID>/temp_fsid
>>
>>    For example:
>>
>>       Consider two cloned and mounted devices.
>>
>> 	$ blkid /dev/sdc[1-2]
>> 	/dev/sdc1: UUID="509ad44b-ad2a-4a8a-bc8d-fe69db7220d5" ..
>> 	/dev/sdc2: UUID="509ad44b-ad2a-4a8a-bc8d-fe69db7220d5" ..
>>
>>       One gets actual fsid, and the other gets the temp_fsid when
>>       mounted.
>>
>> 	$ btrfs filesystem show -m
>> 	Label: none  uuid: 509ad44b-ad2a-4a8a-bc8d-fe69db7220d5
>> 		Total devices 1 FS bytes used 54.14MiB
>> 		devid    1 size 300.00MiB used 144.00MiB path /dev/sdc1
>>
>> 	Label: none  uuid: 33bad74e-c91b-43a5-aef8-b3cab97ae63a
>> 		Total devices 1 FS bytes used 54.14MiB
>> 		devid    1 size 300.00MiB used 144.00MiB path /dev/sdc2
>>
>>       Their sysfs as below.
>>
>> 	$ cat /sys/fs/btrfs/features/temp_fsid
>> 	0
>>
>> 	$ cat /sys/fs/btrfs/509ad44b-ad2a-4a8a-bc8d-fe69db7220d5/temp_fsid
>> 	0
>>
>> 	$ cat /sys/fs/btrfs/33bad74e-c91b-43a5-aef8-b3cab97ae63a/temp_fsid
>> 	1
> 
> So the fsid used for the directory is always the new one, is there a way
> to read which is the original filesystem's fsid? In this case it would
> be the 509ad44b-... We could print it in that file instead of '1',
> though it could be confusing that it's not the temp_fsid but the
> original one, file name mismatches the contents on first look.

Instead, can we emit 'fsid' in another kobject altogether?
Furthermore, we also have a 'metadata_uuid' kobject. Here
is how they relate.


1. normally:

  $ cat /sys/fs/btrfs/<meta-fsid>/fsid
  <meta-fsid>
  $ cat /sys/fs/btrfs/<meta-fsid>/metadata_uuid
  <meta-fsid>


2. metadata-uuid flag is set:

  $ cat /sys/fs/btrfs/<sb-fsid>/fsid
  <sb-fsid>
  $ cat /sys/fs/btrfs/<sb-fsid>/metadata_uuid
  <meta-fsid>


3. normal + temp-fsid:

  $ cat /sys/fs/btrfs/<temp-fsid>/fsid
  <meta-fsid>
  $ cat /sys/fs/btrfs/<temp-fsid>/metadata_uuid
  <meta-fsid>


4. metadata-uuid flag is set + temp-fsid:

  $ cat /sys/fs/btrfs/<temp-fsid>/fsid
  <sb-fsid>
  $ cat /sys/fs/btrfs/<temp-fsid>/metadata_uuid
  <meta-fsid>

> 
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/sysfs.c | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
>> index e07be193323a..7f9a4790e013 100644
>> --- a/fs/btrfs/sysfs.c
>> +++ b/fs/btrfs/sysfs.c
>> @@ -425,6 +425,15 @@ static ssize_t acl_show(struct kobject *kobj, struct kobj_attribute *a, char *bu
>>   }
>>   BTRFS_ATTR(static_feature, acl, acl_show);
>>   
>> +static ssize_t temp_fsid_supported_show(struct kobject *kobj,
>> +					struct kobj_attribute *a, char *buf)
>> +{
>> +	int ret = 0;
>> +
>> +	return sysfs_emit(buf, "%d\n", ret);
> 
> This can be
> 
> 	return sysfs_emit(buf, "0\n");

Changes in the misc-next looks better.

Thanks, Anand

  reply	other threads:[~2023-10-07  9:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 15:00 [PATCH 0/4] btrfs: sysfs and unsupported temp-fsid features for clones Anand Jain
2023-10-04 15:00 ` [PATCH 1/4] btrfs: comment for temp-fsid, fsid, and metadata_uuid Anand Jain
2023-10-04 15:00 ` [PATCH 2/4] btrfs: disable seed feature for temp-fsid Anand Jain
2023-10-04 15:00 ` [PATCH 3/4] btrfs: disable the device add " Anand Jain
2023-10-04 15:00 ` [PATCH 4/4] btrfs: show temp_fsid feature in sysfs Anand Jain
2023-10-06 14:55   ` David Sterba
2023-10-07  9:12     ` Anand Jain [this message]
2023-10-07  9:31       ` Anand Jain
2023-10-06 15:07 ` [PATCH 0/4] btrfs: sysfs and unsupported temp-fsid features for clones David Sterba
2023-10-07 10:30   ` Anand Jain
2023-10-09  7:00     ` Guilherme G. Piccoli
2023-10-09  8:07       ` Anand Jain
2023-10-09 23:59         ` David Sterba
2023-10-10  1:22           ` Anand Jain
2023-10-18 13:37           ` Guilherme G. Piccoli
2023-10-18 23:04             ` David Sterba
2023-10-19  8:06               ` Guilherme G. Piccoli

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=b658ef3f-9fd0-45a1-8950-c86f4f1b450c@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=gpiccoli@igalia.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;
as well as URLs for NNTP newsgroup(s).