linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd.schubert@fastmail.fm>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/5] fuse: add STATX request
Date: Thu, 10 Aug 2023 17:50:10 +0200	[thread overview]
Message-ID: <21beaffb-cf47-61e7-62a4-463da478d1ab@fastmail.fm> (raw)
In-Reply-To: <CAJfpegugchRF8JagD7-zViQVeT_7-h33F+AvpmHhr8FHUcZ4sg@mail.gmail.com>



On 8/10/23 16:08, Miklos Szeredi wrote:
> On Thu, 10 Aug 2023 at 15:23, Bernd Schubert <bernd.schubert@fastmail.fm> wrote:
>>
>>
>>
>> On 8/10/23 12:54, Miklos Szeredi wrote:
>>> Use the same structure as statx.
>>
>> Wouldn't it be easier to just include struct statx? Or is there an issue
>> with __u32, etc? If so, just a sufficiently large array could be used
>> and statx values just mem-copied in/out?
> 
> <linux/uapi/fuse.h> is OS independent.  Ports can grab it and use it
> in their userspace and kernel implementations.

Ok, but why not just like this?

struct fuse_statx {
	uint8_t fuse_statx_values[256];
}

struct fuse_statx fuse_statx;
struct statx *statx_ptr = (struct statx *)&fuse_statx.fuse_statx_values;


Hmm, I see an issue if that struct is passed over network and different 
OS are involved, which _might_ have different structs or sizes. So yeah, 
the copy approach is safest. Although as fuse_statx is between kernel 
and userspace only - it should not matter?

> 
> 
>>
>>>
>>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
>>> ---
>>>    include/uapi/linux/fuse.h | 56 ++++++++++++++++++++++++++++++++++++++-
>>>    1 file changed, 55 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>>> index b3fcab13fcd3..fe700b91b33b 100644
>>> --- a/include/uapi/linux/fuse.h
>>> +++ b/include/uapi/linux/fuse.h
>>> @@ -207,6 +207,9 @@
>>>     *  - add FUSE_EXT_GROUPS
>>>     *  - add FUSE_CREATE_SUPP_GROUP
>>>     *  - add FUSE_HAS_EXPIRE_ONLY
>>> + *
>>> + *  7.39
>>> + *  - add FUSE_STATX and related structures
>>>     */
>>>
>>>    #ifndef _LINUX_FUSE_H
>>> @@ -242,7 +245,7 @@
>>>    #define FUSE_KERNEL_VERSION 7
>>>
>>>    /** Minor version number of this interface */
>>> -#define FUSE_KERNEL_MINOR_VERSION 38
>>> +#define FUSE_KERNEL_MINOR_VERSION 39
>>>
>>>    /** The node ID of the root inode */
>>>    #define FUSE_ROOT_ID 1
>>> @@ -269,6 +272,40 @@ struct fuse_attr {
>>>        uint32_t        flags;
>>>    };
>>>
>>> +/*
>>> + * The following structures are bit-for-bit compatible with the statx(2) ABI in
>>> + * Linux.
>>> + */
>>> +struct fuse_sx_time {
>>> +     int64_t         tv_sec;
>>> +     uint32_t        tv_nsec;
>>> +     int32_t         __reserved;
>>> +};
>>> +
>>> +struct fuse_statx {
>>> +     uint32_t        mask;
>>> +     uint32_t        blksize;
>>> +     uint64_t        attributes;
>>> +     uint32_t        nlink;
>>> +     uint32_t        uid;
>>> +     uint32_t        gid;
>>> +     uint16_t        mode;
>>> +     uint16_t        __spare0[1];
>>> +     uint64_t        ino;
>>> +     uint64_t        size;
>>> +     uint64_t        blocks;
>>> +     uint64_t        attributes_mask;
>>> +     struct fuse_sx_time     atime;
>>> +     struct fuse_sx_time     btime;
>>> +     struct fuse_sx_time     ctime;
>>> +     struct fuse_sx_time     mtime;
>>> +     uint32_t        rdev_major;
>>> +     uint32_t        rdev_minor;
>>> +     uint32_t        dev_major;
>>> +     uint32_t        dev_minor;
>>> +     uint64_t        __spare2[14];
>>> +};
>>
>> Looks like some recent values are missing?
> 
> It doesn't matter, since those parts are not used.
> 
>>
>>          /* 0x90 */
>>          __u64   stx_mnt_id;
>>          __u32   stx_dio_mem_align;      /* Memory buffer alignment for direct I/O */
>>          __u32   stx_dio_offset_align;   /* File offset alignment for direct I/O */
>>          /* 0xa0 */
>>          __u64   __spare3[12];   /* Spare space for future expansion */
>>          /* 0x100 */
>>
>> Which is basically why my personal preference would be not to do have a
>> copy of the struct - there is maintenance overhead.
> 
> Whenever the new fields would be used in the kernel the fields can be
> added.  So no need to continually update the one in fuse, since those

Maybe I'm over optimizing, I just see that userspace side then also 
needs an updated struct - which can be easily forgotten. While plain 
struct statx would't have that issue.



Thanks,
Bernd

  reply	other threads:[~2023-08-10 15:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 10:54 [PATCH 0/5] fuse: support birth time Miklos Szeredi
2023-08-10 10:54 ` [PATCH 1/5] fuse: handle empty request_mask in statx Miklos Szeredi
2023-08-10 10:54 ` [PATCH 2/5] fuse: add STATX request Miklos Szeredi
2023-08-10 13:22   ` Bernd Schubert
2023-08-10 14:08     ` Miklos Szeredi
2023-08-10 15:50       ` Bernd Schubert [this message]
2023-08-10 10:54 ` [PATCH 3/5] fuse: add ATTR_TIMEOUT macro Miklos Szeredi
2023-08-10 10:55 ` [PATCH 4/5] fuse: implement statx Miklos Szeredi
2023-08-10 13:34   ` kernel test robot
2023-08-10 14:19     ` Miklos Szeredi
2023-08-22 15:20   ` Bernd Schubert
2023-08-22 15:33     ` Miklos Szeredi
2023-08-22 16:55       ` Bernd Schubert
2023-08-23  6:18         ` Miklos Szeredi
2023-08-23 14:51           ` Bernd Schubert
2023-08-23 14:58             ` Miklos Szeredi
2023-08-23 15:24               ` Bernd Schubert
2023-08-23 15:24               ` Bernd Schubert
2023-08-22 16:39   ` Bernd Schubert
2023-08-23  6:15     ` Miklos Szeredi
2023-08-10 10:55 ` [PATCH 5/5] fuse: cache btime Miklos Szeredi

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=21beaffb-cf47-61e7-62a4-463da478d1ab@fastmail.fm \
    --to=bernd.schubert@fastmail.fm \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@redhat.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;
as well as URLs for NNTP newsgroup(s).