* [PATCH 1/2] bcachefs: Add support for FS_IOC_GETFSUUID
@ 2024-07-09 1:11 Youling Tang
2024-07-09 1:11 ` [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH Youling Tang
0 siblings, 1 reply; 5+ messages in thread
From: Youling Tang @ 2024-07-09 1:11 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, Youling Tang, Youling Tang
From: Kent Overstreet <kent.overstreet@linux.dev>
Use super_set_uuid() to set `sb->s_uuid_len` to avoid returning `-ENOTTY`
with sb->s_uuid_len being 0.
Original patch link:
[1]: https://lore.kernel.org/all/20240207025624.1019754-2-kent.overstreet@linux.dev/
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
fs/bcachefs/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 3ea8dbc4d8e4..011ee5075a52 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1977,7 +1977,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
sb->s_time_gran = c->sb.nsec_per_time_unit;
sb->s_time_min = div_s64(S64_MIN, c->sb.time_units_per_sec) + 1;
sb->s_time_max = div_s64(S64_MAX, c->sb.time_units_per_sec);
- sb->s_uuid = c->sb.user_uuid;
+ super_set_uuid(sb, c->sb.user_uuid.b, sizeof(c->sb.user_uuid));
sb->s_shrink->seeks = 0;
c->vfs_sb = sb;
strscpy(sb->s_id, c->name, sizeof(sb->s_id));
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH
2024-07-09 1:11 [PATCH 1/2] bcachefs: Add support for FS_IOC_GETFSUUID Youling Tang
@ 2024-07-09 1:11 ` Youling Tang
2024-07-09 2:04 ` Hongbo Li
0 siblings, 1 reply; 5+ messages in thread
From: Youling Tang @ 2024-07-09 1:11 UTC (permalink / raw)
To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, Youling Tang
From: Kent Overstreet <kent.overstreet@linux.dev>
[TEST]:
```
$ cat ioctl_getsysfspath.c
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int fd;
struct fs_sysfs_path sysfs_path = {};
if (argc != 2) {
fprintf(stderr, "Usage: %s <path_to_file_or_directory>\n", argv[0]);
exit(EXIT_FAILURE);
}
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
}
if (ioctl(fd, FS_IOC_GETFSSYSFSPATH, &sysfs_path) == -1) {
perror("ioctl FS_IOC_GETFSSYSFSPATH");
close(fd);
exit(EXIT_FAILURE);
}
printf("FS_IOC_GETFSSYSFSPATH: %s\n", sysfs_path.name);
close(fd);
return 0;
}
$ gcc ioctl_getsysfspath.c
$ sudo bcachefs format /dev/sda
$ sudo mount.bcachefs /dev/sda /mnt
$ sudo ./a.out /mnt
FS_IOC_GETFSSYSFSPATH: bcachefs/c380b4ab-fbb6-41d2-b805-7a89cae9cadb
```
Original patch link:
[1]: https://lore.kernel.org/all/20240207025624.1019754-8-kent.overstreet@linux.dev/
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Youling Tang <youling.tang@linux.dev>
---
fs/bcachefs/fs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 011ee5075a52..8699770398d1 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1978,6 +1978,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
sb->s_time_min = div_s64(S64_MIN, c->sb.time_units_per_sec) + 1;
sb->s_time_max = div_s64(S64_MAX, c->sb.time_units_per_sec);
super_set_uuid(sb, c->sb.user_uuid.b, sizeof(c->sb.user_uuid));
+ super_set_sysfs_name_uuid(sb);
sb->s_shrink->seeks = 0;
c->vfs_sb = sb;
strscpy(sb->s_id, c->name, sizeof(sb->s_id));
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH
2024-07-09 1:11 ` [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH Youling Tang
@ 2024-07-09 2:04 ` Hongbo Li
2024-07-09 2:11 ` Youling Tang
0 siblings, 1 reply; 5+ messages in thread
From: Hongbo Li @ 2024-07-09 2:04 UTC (permalink / raw)
To: Youling Tang, Kent Overstreet; +Cc: linux-bcachefs, linux-kernel
On 2024/7/9 9:11, Youling Tang wrote:
> From: Kent Overstreet <kent.overstreet@linux.dev>
>
> [TEST]:
> ```
> $ cat ioctl_getsysfspath.c
> #include <stdio.h>
> #include <stdlib.h>
> #include <fcntl.h>
> #include <sys/ioctl.h>
> #include <linux/fs.h>
> #include <unistd.h>
>
> int main(int argc, char *argv[]) {
> int fd;
> struct fs_sysfs_path sysfs_path = {};
>
> if (argc != 2) {
> fprintf(stderr, "Usage: %s <path_to_file_or_directory>\n", argv[0]);
> exit(EXIT_FAILURE);
> }
>
> fd = open(argv[1], O_RDONLY);
> if (fd == -1) {
> perror("open");
> exit(EXIT_FAILURE);
> }
>
> if (ioctl(fd, FS_IOC_GETFSSYSFSPATH, &sysfs_path) == -1) {
> perror("ioctl FS_IOC_GETFSSYSFSPATH");
> close(fd);
> exit(EXIT_FAILURE);
> }
>
> printf("FS_IOC_GETFSSYSFSPATH: %s\n", sysfs_path.name);
> close(fd);
> return 0;
> }
>
> $ gcc ioctl_getsysfspath.c
> $ sudo bcachefs format /dev/sda
> $ sudo mount.bcachefs /dev/sda /mnt
> $ sudo ./a.out /mnt
> FS_IOC_GETFSSYSFSPATH: bcachefs/c380b4ab-fbb6-41d2-b805-7a89cae9cadb
> ```
>
> Original patch link:
> [1]: https://lore.kernel.org/all/20240207025624.1019754-8-kent.overstreet@linux.dev/
>
> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
> Signed-off-by: Youling Tang <youling.tang@linux.dev>
> ---
> fs/bcachefs/fs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
> index 011ee5075a52..8699770398d1 100644
> --- a/fs/bcachefs/fs.c
> +++ b/fs/bcachefs/fs.c
> @@ -1978,6 +1978,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
> sb->s_time_min = div_s64(S64_MIN, c->sb.time_units_per_sec) + 1;
> sb->s_time_max = div_s64(S64_MAX, c->sb.time_units_per_sec);
> super_set_uuid(sb, c->sb.user_uuid.b, sizeof(c->sb.user_uuid));
> + super_set_sysfs_name_uuid(sb);
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
It's quite strange that other commits have been merged, but the ones for
bcachefs have not been merged.
Thanks,
Hongbo
> sb->s_shrink->seeks = 0;
> c->vfs_sb = sb;
> strscpy(sb->s_id, c->name, sizeof(sb->s_id));
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH
2024-07-09 2:04 ` Hongbo Li
@ 2024-07-09 2:11 ` Youling Tang
2024-07-09 2:27 ` Hongbo Li
0 siblings, 1 reply; 5+ messages in thread
From: Youling Tang @ 2024-07-09 2:11 UTC (permalink / raw)
To: Hongbo Li; +Cc: linux-bcachefs, linux-kernel, Kent Overstreet
On 09/07/2024 10:04, Hongbo Li wrote:
>
>
> On 2024/7/9 9:11, Youling Tang wrote:
>> From: Kent Overstreet <kent.overstreet@linux.dev>
>>
>> [TEST]:
>> ```
>> $ cat ioctl_getsysfspath.c
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <fcntl.h>
>> #include <sys/ioctl.h>
>> #include <linux/fs.h>
>> #include <unistd.h>
>>
>> int main(int argc, char *argv[]) {
>> int fd;
>> struct fs_sysfs_path sysfs_path = {};
>>
>> if (argc != 2) {
>> fprintf(stderr, "Usage: %s <path_to_file_or_directory>\n",
>> argv[0]);
>> exit(EXIT_FAILURE);
>> }
>>
>> fd = open(argv[1], O_RDONLY);
>> if (fd == -1) {
>> perror("open");
>> exit(EXIT_FAILURE);
>> }
>>
>> if (ioctl(fd, FS_IOC_GETFSSYSFSPATH, &sysfs_path) == -1) {
>> perror("ioctl FS_IOC_GETFSSYSFSPATH");
>> close(fd);
>> exit(EXIT_FAILURE);
>> }
>>
>> printf("FS_IOC_GETFSSYSFSPATH: %s\n", sysfs_path.name);
>> close(fd);
>> return 0;
>> }
>>
>> $ gcc ioctl_getsysfspath.c
>> $ sudo bcachefs format /dev/sda
>> $ sudo mount.bcachefs /dev/sda /mnt
>> $ sudo ./a.out /mnt
>> FS_IOC_GETFSSYSFSPATH: bcachefs/c380b4ab-fbb6-41d2-b805-7a89cae9cadb
>> ```
>>
>> Original patch link:
>> [1]:
>> https://lore.kernel.org/all/20240207025624.1019754-8-kent.overstreet@linux.dev/
>>
>> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
>> Signed-off-by: Youling Tang <youling.tang@linux.dev>
>> ---
>> fs/bcachefs/fs.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
>> index 011ee5075a52..8699770398d1 100644
>> --- a/fs/bcachefs/fs.c
>> +++ b/fs/bcachefs/fs.c
>> @@ -1978,6 +1978,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
>> sb->s_time_min = div_s64(S64_MIN,
>> c->sb.time_units_per_sec) + 1;
>> sb->s_time_max = div_s64(S64_MAX,
>> c->sb.time_units_per_sec);
>> super_set_uuid(sb, c->sb.user_uuid.b, sizeof(c->sb.user_uuid));
>> + super_set_sysfs_name_uuid(sb);
>
> Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
>
> It's quite strange that other commits have been merged, but the ones
> for bcachefs have not been merged.
Because bcachefs was not upstream at the time, [1] described the following:
Note, I dropped the bcachefs changes because they're not upstream yet.
But once this is a stable branch you can just pull in vfs.uuid and rely
on that.
[1]:
https://lore.kernel.org/all/20240208-wecken-nutzen-3df1102a39b2@brauner/
Thanks,
Youling.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH
2024-07-09 2:11 ` Youling Tang
@ 2024-07-09 2:27 ` Hongbo Li
0 siblings, 0 replies; 5+ messages in thread
From: Hongbo Li @ 2024-07-09 2:27 UTC (permalink / raw)
To: Youling Tang; +Cc: linux-bcachefs, linux-kernel, Kent Overstreet
On 2024/7/9 10:11, Youling Tang wrote:
> On 09/07/2024 10:04, Hongbo Li wrote:
>>
>>
>> On 2024/7/9 9:11, Youling Tang wrote:
>>> From: Kent Overstreet <kent.overstreet@linux.dev>
>>>
>>> [TEST]:
>>> ```
>>> $ cat ioctl_getsysfspath.c
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> #include <fcntl.h>
>>> #include <sys/ioctl.h>
>>> #include <linux/fs.h>
>>> #include <unistd.h>
>>>
>>> int main(int argc, char *argv[]) {
>>> int fd;
>>> struct fs_sysfs_path sysfs_path = {};
>>>
>>> if (argc != 2) {
>>> fprintf(stderr, "Usage: %s <path_to_file_or_directory>\n",
>>> argv[0]);
>>> exit(EXIT_FAILURE);
>>> }
>>>
>>> fd = open(argv[1], O_RDONLY);
>>> if (fd == -1) {
>>> perror("open");
>>> exit(EXIT_FAILURE);
>>> }
>>>
>>> if (ioctl(fd, FS_IOC_GETFSSYSFSPATH, &sysfs_path) == -1) {
>>> perror("ioctl FS_IOC_GETFSSYSFSPATH");
>>> close(fd);
>>> exit(EXIT_FAILURE);
>>> }
>>>
>>> printf("FS_IOC_GETFSSYSFSPATH: %s\n", sysfs_path.name);
>>> close(fd);
>>> return 0;
>>> }
>>>
>>> $ gcc ioctl_getsysfspath.c
>>> $ sudo bcachefs format /dev/sda
>>> $ sudo mount.bcachefs /dev/sda /mnt
>>> $ sudo ./a.out /mnt
>>> FS_IOC_GETFSSYSFSPATH: bcachefs/c380b4ab-fbb6-41d2-b805-7a89cae9cadb
>>> ```
>>>
>>> Original patch link:
>>> [1]:
>>> https://lore.kernel.org/all/20240207025624.1019754-8-kent.overstreet@linux.dev/
>>>
>>> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
>>> Signed-off-by: Youling Tang <youling.tang@linux.dev>
>>> ---
>>> fs/bcachefs/fs.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
>>> index 011ee5075a52..8699770398d1 100644
>>> --- a/fs/bcachefs/fs.c
>>> +++ b/fs/bcachefs/fs.c
>>> @@ -1978,6 +1978,7 @@ static int bch2_fs_get_tree(struct fs_context *fc)
>>> sb->s_time_min = div_s64(S64_MIN,
>>> c->sb.time_units_per_sec) + 1;
>>> sb->s_time_max = div_s64(S64_MAX,
>>> c->sb.time_units_per_sec);
>>> super_set_uuid(sb, c->sb.user_uuid.b, sizeof(c->sb.user_uuid));
>>> + super_set_sysfs_name_uuid(sb);
>>
>> Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
>>
>> It's quite strange that other commits have been merged, but the ones
>> for bcachefs have not been merged.
> Because bcachefs was not upstream at the time, [1] described the following:
> Note, I dropped the bcachefs changes because they're not upstream yet.
> But once this is a stable branch you can just pull in vfs.uuid and rely
> on that.
>
Got it! Thank you!
Thanks,
Hongbo
> [1]:
> https://lore.kernel.org/all/20240208-wecken-nutzen-3df1102a39b2@brauner/
>
> Thanks,
> Youling.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-09 2:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 1:11 [PATCH 1/2] bcachefs: Add support for FS_IOC_GETFSUUID Youling Tang
2024-07-09 1:11 ` [PATCH 2/2] bcachefs: Add support for FS_IOC_GETFSSYSFSPATH Youling Tang
2024-07-09 2:04 ` Hongbo Li
2024-07-09 2:11 ` Youling Tang
2024-07-09 2:27 ` Hongbo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox