fuse: Add open-gettr for fuse-file-open
Subsystems (2)
PATCH 1/1 fuse: Add open-gettr for fuse-file-open
This is to update attributes on open to achieve close-to-open coherency even if an inode has a attribute cache timeout.
---
libfuse patch:
https://github.com/libfuse/libfuse/pull/1020
(FUSE_OPENDIR_GETATTR still missing at time of writing)
Note: This does not make use of existing atomic-open patches as these are more complex than two new opcodes for open-getattr.
Note2: This is an alternative to Joannes patch that adds FOPEN_FETCH_ATTR, which would need to kernel/userspace transitions
https://lore.kernel.org/all/[email protected]/
Question for reviewers:
- Should this better use statx fields? Probably not needed for coherency?
- Should this introduce a new struct that contains struct fuse_open_out and struct fuse_attr_out, with additional padding between them to avoid incompat issues if either struct should be extended?
--- fs/fuse/file.c | 94 ++++++++++++++++++++++++++++++++++++++- fs/fuse/fuse_i.h | 7 +++ fs/fuse/ioctl.c | 2 +- include/uapi/linux/fuse.h | 5 +++ 4 files changed, 105 insertions(+), 3 deletions(-)
fs/fuse/file.c +92 -2
@@ -51,6 +51,78 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid,return fuse_simple_request (fm, &args); } +/* +* Open the file and update inode attributes +*/ +static int fuse_file_open_getattr (struct fuse_mount *fm,u64 nodeid, +struct inode *inode,unsigned int open_flags, +int opcode, +struct fuse_open_out *open_outargp) +{ +struct fuse_conn *fc = fm->fc; +u64 attr_version =fuse_get_attr_version (fc); +struct fuse_open_in inarg; +struct fuse_attr_out attr_outarg; +FUSE_ARGS (args); +int err; + +/* convert the opcode from plain open to open-with-getattr */ +if (opcode ==FUSE_OPEN ) { +if (fc->no_open_getattr) +return -ENOSYS ; + opcode =FUSE_OPEN_GETATTR ; + }else { +if (fc->no_opendir_getattr) +return -ENOSYS ; + opcode =FUSE_OPENDIR_GETATTR ; + } + +memset (&inarg,0 ,sizeof (inarg)); + inarg.flags = open_flags & ~(O_CREAT |O_EXCL |O_NOCTTY ); +if (!fm->fc->atomic_o_trunc) + inarg.flags &= ~O_TRUNC ; + +if (fm->fc->handle_killpriv_v2 && + (inarg.flags &O_TRUNC ) && !capable (CAP_FSETID )) { + inarg.open_flags |=FUSE_OPEN_KILL_SUIDGID ; + } + + args.opcode = opcode; + args.nodeid = nodeid; + args.in_numargs =1 ; + args.in_args[0 ].size =sizeof (inarg); + args.in_args[0 ].value = &inarg; + args.out_numargs =2 ; + args.out_args[0 ].size =sizeof (*open_outargp); + args.out_args[0 ].value = open_outargp; + args.out_args[1 ].size =sizeof (attr_outarg); + args.out_args[1 ].value = &attr_outarg; + + err =fuse_simple_request (fm, &args); +if (err) { +if (err == -ENOSYS ) { +if (opcode ==FUSE_OPEN ) + fc->no_open_getattr =1 ; +else + fc->no_opendir_getattr =1 ; + } +return err; + } + + err = -EIO ; +if (fuse_invalid_attr (&attr_outarg.attr) || +inode_wrong_type (inode, attr_outarg.attr.mode)) { +fuse_make_bad (inode); +return err; + } + +fuse_change_attributes (inode, &attr_outarg.attr,NULL , +ATTR_TIMEOUT (&attr_outarg), attr_version); + +return 0 ; +} + +struct fuse_file *fuse_file_alloc (struct fuse_mount *fm,bool release) {struct fuse_file *ff;
@@ -123,7 +195,12 @@ static void fuse_file_put(struct fuse_file *ff, bool sync) } } +/* +* @inode might be NULL, the caller indicates the attr updates are not +* needed on open +*/ struct fuse_file *fuse_file_open (struct fuse_mount *fm,u64 nodeid, +struct inode *inode,unsigned int open_flags,bool isdir) {struct fuse_conn *fc = fm->fc;
@@ -143,7 +220,19 @@ struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid,struct fuse_open_out *outargp = &ff->args->open_outarg;int err; - err =fuse_send_open (fm, nodeid, open_flags, opcode, outargp); + err = -ENOSYS ; +if (inode) { +/* +* open-with-getattr preferred for +* close-to-open coherency +*/ + err =fuse_file_open_getattr (fm, nodeid, inode, + open_flags, opcode, + outargp); + } +if (err == -ENOSYS ) + err =fuse_send_open (fm, nodeid, open_flags, opcode, + outargp);if (!err) { ff->fh = outargp->fh; ff->open_flags = outargp->open_flags;
@@ -172,7 +261,8 @@ struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid,int fuse_do_open (struct fuse_mount *fm,u64 nodeid,struct file *file,bool isdir) { -struct fuse_file *ff =fuse_file_open (fm, nodeid, file->f_flags, isdir); +struct fuse_file *ff =fuse_file_open (fm, nodeid,file_inode (file), + file->f_flags, isdir);if (!IS_ERR (ff)) file->private_data = ff;
fs/fuse/fuse_i.h +7 -0
@@ -731,9 +731,15 @@ struct fuse_conn {/** Is open/release not implemented by fs? */ unsigned no_open:1; +/** Is open-getattr not implemented by fs */ + unsigned no_open_getattr:1; +/** Is opendir/releasedir not implemented by fs? */ unsigned no_opendir:1; +/** Is opendir-getattr not implemented by fs? */ + unsigned no_opendir_getattr:1; +/** Is fsync not implemented by fs? */ unsigned no_fsync:1;
@@ -1404,6 +1410,7 @@ void fuse_file_io_release(struct fuse_file *ff, struct inode *inode);/* file.c */ struct fuse_file *fuse_file_open (struct fuse_mount *fm,u64 nodeid, +struct inode *inode,unsigned int open_flags,bool isdir);void fuse_file_release (struct inode *inode,struct fuse_file *ff,unsigned int open_flags,fl_owner_t id,bool isdir);
fs/fuse/ioctl.c +1 -1
@@ -493,7 +493,7 @@ static struct fuse_file *fuse_priv_ioctl_prepare(struct inode *inode)if (!S_ISREG (inode->i_mode) && !isdir)return ERR_PTR (-ENOTTY ); -return fuse_file_open (fm,get_node_id (inode),O_RDONLY , isdir); +return fuse_file_open (fm,get_node_id (inode),NULL ,O_RDONLY , isdir); }static void fuse_priv_ioctl_cleanup (struct inode *inode,struct fuse_file *ff)
include/uapi/linux/fuse.h +5 -0
@@ -217,6 +217,9 @@* - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag * - add FUSE_NO_EXPORT_SUPPORT init flag * - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag +* +* 7.41 +* - add FUSE_OPEN_GETATTR/FUSE_OPENDIR_GETATTR */ #ifndef _LINUX_FUSE_H
@@ -633,6 +636,8 @@ enum fuse_opcode {FUSE_SYNCFS =50 ,FUSE_TMPFILE =51 ,FUSE_STATX =52 , +FUSE_OPEN_GETATTR =53 , +FUSE_OPENDIR_GETATTR =54 ,/* CUSE specific operations */ CUSE_INIT = 4096,
Signature · 1 line
2.43.0
Miklos Szeredi
maintainerQuoted 6 lines · Bernd Schubert
This is to update attributes on open to achieve close-to-open coherency even if an inode has a attribute cache timeout.
Signed-off-by Bernd Schubert <[email protected]>
Quoted 7 lines
---
libfuse patch:
https://github.com/libfuse/libfuse/pull/1020
(FUSE_OPENDIR_GETATTRstill missing at time of writing)Note: This does not make use of existing atomic-open patches as these are more complex than two new opcodes for open-getattr.
The format of the requests would be very similar to the atomic open ones, right?
Thanks,
Miklos
Quoted 12 lines · Miklos Szeredi
Quoted 11 lines · Bernd Schubert
This is to update attributes on open to achieve close-to-open coherency even if an inode has a attribute cache timeout.
Signed-off-by Bernd Schubert <[email protected]>---
libfuse patch:
https://github.com/libfuse/libfuse/pull/1020
(FUSE_OPENDIR_GETATTRstill missing at time of writing)
Quoted 4 lines
Quoted 2 lines
Note: This does not make use of existing atomic-open patches as these are more complex than two new opcodes for open-getattr.
The format of the requests would be very similar to the atomic open ones, right?
Atomic open patches are using fuse_open_out + fuse_entry_out
open-getattr is using fuse_open_out + attr_outarg
We could switch open-getattr to the atomic-open format, but then need to introduce a flag to tell fuse-server that this is a plain atomic and much simpler than atomic-open (atomic-open is also on the server side rather complex).
For open-getattr we need don't need to revalidate the entry with all the fields provided by fuse_entry_out.
Fine with me if you prefer a new struct to be used by atomic-open and open-getattr with a flag and padding. Like
enum atomic_open_flags
{
ATOMIC_OPEN_IS_OPEN_GETATTR = 1ULL < 0;
};struct atomic_open
{
uint64_t atomic_open_flags;
struct fuse_open_out open_out;
uint8_t future_padding1[16];
struct fuse_entry_out entry_out;
uint8_t future_padding2[16];
}What do you think?
Thanks,
Bernd
Miklos Szeredi
maintainerQuoted 11 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Thanks,
Miklos
Quoted 12 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }
Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
I need to figure out how that actually works in NFS.
Do you have a suggestion how to bundle open + getattr in one request with compounds? My thinking is that we need something like
#define MAX_OPS 8 // abitrary value
#define MAX_OP_OUT_SZ
struct op {
uint32_t opcode;
uint32_t arg_sz;
void *arg;
};struct fuse_compound
{
uint32_t n_ops;
struct op ops[MAX_OPS];
}But how would fuse_file_open() know how to send a sequence of requests? I don't see an issue to decode that on the server side into multiple requests, but how do we process the result in fuse-client? For fg requests we have exactly request that gets processed by the vfs operaration sending a request - how would that look like with compounds?
Or do I totally misunderstand you and you want to use compounds to avoid the uber struct for atomic-open? At least we still need to add in the ATOMIC_OPEN_IS_OPEN_GETATTR flag there and actually another like ATOMIC_OPEN_IS_DIRECTORY.
Thanks,
Bernd
Miklos Szeredi
maintainerQuoted 1 line · Bernd Schubert
But how would
fuse_file_open()know how to send a sequence of requests?
It would just send a FUSE_COMPOUND request, which contains a FUSE_GETATTR and a FUSE_OPEN request.
Quoted 4 lines
I don't see an issue to decode that on the server side into multiple requests, but how do we process the result in fuse-client? For fg requests we have exactly request that gets processed by the vfs operaration sending a request - how would that look like with compounds?
AFAIU compunds in NFS4 bundle multiple request into one which the server processes sequentially and the results are also returned in a bundle.
That's just the protocol, the server and the client can use this in any way that conforms to the protocol.
Quoted 5 lines
Or do I totally misunderstand you and you want to use compounds to avoid the uber struct for atomic-open? At least we still need to add in the
ATOMIC_OPEN_IS_OPEN_GETATTRflag there and actually another likeATOMIC_OPEN_IS_DIRECTORY.
Yes, the main advantage would be to avoid having to add new request types for things that are actually just the aggregation of multiple existing request types.
Thanks,
Miklos
Quoted 20 lines · Miklos Szeredi
Quoted 1 line · Bernd Schubert
But how would
fuse_file_open()know how to send a sequence of requests?It would just send a
FUSE_COMPOUNDrequest, which contains aFUSE_GETATTRand aFUSE_OPENrequest.Quoted 4 lines
I don't see an issue to decode that on the server side into multiple requests, but how do we process the result in fuse-client? For fg requests we have exactly request that gets processed by the vfs operaration sending a request - how would that look like with compounds?
AFAIU compunds in NFS4 bundle multiple request into one which the server processes sequentially and the results are also returned in a bundle.
That's just the protocol, the server and the client can use this in any way that conforms to the protocol.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Or do I totally misunderstand you and you want to use compounds to avoid the uber struct for atomic-open? At least we still need to add in the
ATOMIC_OPEN_IS_OPEN_GETATTRflag there and actually another likeATOMIC_OPEN_IS_DIRECTORY.Yes, the main advantage would be to avoid having to add new request types for things that are actually just the aggregation of multiple existing request types.
Thanks, that simplifies things for fuse kernel. I'm still thinking about what is the best way for fuse server. Traveling (back home) the next days - will come with a new patch next week.
Thanks,
Bernd
Quoted 13 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }
Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Are compound requests still something that's planned to be added to fuse given that fuse now has support for sending requests over uring, which diminishes the overhead of kernel/userspace context switches for sending multiple requests vs 1 big compound request?
The reason I ask is because the mitigation for the stale attributes data corruption for servers backed by network filesystems we saw in
[1] is dependent on this patch / compound requests. If compound requests are no longer useful / planned, then what are your thoughts on [1] as an acceptable solution?
Thanks,
Joanne
[1] https://lore.kernel.org/linux-fsdevel/[email protected]/
Quoted 3 lines
Thanks,
Miklos
Hi Joanne,
Quoted 24 lines · Joanne Koong
Quoted 13 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Are compound requests still something that's planned to be added to fuse given that fuse now has support for sending requests over uring, which diminishes the overhead of kernel/userspace context switches for sending multiple requests vs 1 big compound request?
Quoted 5 lines
The reason I ask is because the mitigation for the stale attributes data corruption for servers backed by network filesystems we saw in
[1] is dependent on this patch / compound requests. If compound requests are no longer useful / planned, then what are your thoughts on [1] as an acceptable solution?
sorry, I have it in our ticket system, but I'm totally occupied with others issues for weeks *sigh*
Does io-uring really help if there is just on application doing IO to the current core/ring-queue?
open - blocking fg request
getattr - blocking fg request
If we could dispatch both as bg request and wait for the response it might work out, but in the current form not ideal.
I can only try to find the time over the weekend to work on the compound reuqest, although need to send out the other patch and especially to test it (the one about possible list corruption).
Thanks
Bernd
Quoted 34 lines · Bernd Schubert
Hi Joanne,
Quoted 29 lines · Joanne Koong
Quoted 13 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Are compound requests still something that's planned to be added to fuse given that fuse now has support for sending requests over uring, which diminishes the overhead of kernel/userspace context switches for sending multiple requests vs 1 big compound request?
The reason I ask is because the mitigation for the stale attributes data corruption for servers backed by network filesystems we saw in
[1] is dependent on this patch / compound requests. If compound requests are no longer useful / planned, then what are your thoughts on [1] as an acceptable solution?
Hi Bernd,
Quoted 3 lines
sorry, I have it in our ticket system, but I'm totally occupied with others issues for weeks *sigh*
No worries!
Quoted 6 lines
Does io-uring really help if there is just on application doing IO to the current core/ring-queue?
open - blocking fg request
getattr - blocking fg request
My understanding (and please correct me here if i'm wrong) is that the main benefit of compound requests is that it bundles multiple requests into 1 request to minimize kernel/userspace context switches. For fuse io-uring [2], "motivation ... is... to increase fuse performance by:
Reducing kernel/userspace context switches. Part of that is given by the ring ring - handling multiple requests on either side of kernel/userspace without the need to switch per request".
Am I missing something in my understanding of io-uring reducing context switches?
Quoted 6 lines
If we could dispatch both as bg request and wait for the response it might work out, but in the current form not ideal.
I can only try to find the time over the weekend to work on the compound reuqest, although need to send out the other patch and especially to test it (the one about possible list corruption).
If you need an extra pair of hands, i'm happy to help out with this. Internally, we'd like to get the proper fix in for the issue in [1], but we have a hacky workaround for it right now (returning -ESTALE to redo the lookup and update the file size), so we're not in a huge rush.
Thanks,
Joanne
[2] https://lore.kernel.org/linux-fsdevel/[email protected]/
Quoted 9 lines
Thanks
Bernd
Quoted 48 lines · Joanne Koong
Quoted 34 lines · Bernd Schubert
Hi Joanne,
Quoted 29 lines · Joanne Koong
Quoted 13 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Are compound requests still something that's planned to be added to fuse given that fuse now has support for sending requests over uring, which diminishes the overhead of kernel/userspace context switches for sending multiple requests vs 1 big compound request?
The reason I ask is because the mitigation for the stale attributes data corruption for servers backed by network filesystems we saw in
[1] is dependent on this patch / compound requests. If compound requests are no longer useful / planned, then what are your thoughts on [1] as an acceptable solution?Hi Bernd,
Quoted 3 lines
sorry, I have it in our ticket system, but I'm totally occupied with others issues for weeks *sigh*
No worries!
Quoted 3 lines
Does io-uring really help if there is just on application doing IO to the current core/ring-queue?
Quoted 7 lines
Quoted 3 lines
open - blocking fg request
getattr - blocking fg requestMy understanding (and please correct me here if i'm wrong) is that the main benefit of compound requests is that it bundles multiple requests into 1 request to minimize kernel/userspace context switches. For fuse
I think it would be good, to give fuse-server also the chance to handle the compound on its own. Example, sshfs would benefit from it as well (ok, the sftp protocol needs to get an extension, afaik), see here
https://github.com/libfuse/libfuse/issues/945
If sshfs would now do two requests, it would introduce double network latency - not your about you, but from my home to main lab hardware (US) that would already be quite noticeable.
If sshfs/sftp would get a protocol extension and handle open+getattr in one request, there would be basically zero overhead.
Quoted 7 lines
io-uring [2], "motivation ... is... to increase fuse performance by:
Reducing kernel/userspace context switches. Part of that is given by the ring ring - handling multiple requests on either side of kernel/userspace without the need to switch per request".Am I missing something in my understanding of io-uring reducing context switches?
With fuse-io-uring we have reduced context switches, because result submit can immediately fetch the next request, vs previous read + write.
Then we also avoid context switches if the ring is busy - it can stay on either side if there is still work to do.
For open and then getattr and if the ring is idle, we still have the overhead of two independent operations.
One issue I'm currently working is is reducing memory overhead, we actually might need a fuse-io-uring mode with less rings. In that mode chances to have a busy ring are higher. Although I'm still fighting against it, because it takes away core affinity and that was showing 3x performance gains with blocking / fg requests.
Quoted 9 lines
Quoted 8 lines
If we could dispatch both as bg request and wait for the response it might work out, but in the current form not ideal.
I can only try to find the time over the weekend to work on the compound reuqest, although need to send out the other patch and especially to test it (the one about possible list corruption).
Quoted 5 lines
If you need an extra pair of hands, i'm happy to help out with this. Internally, we'd like to get the proper fix in for the issue in [1], but we have a hacky workaround for it right now (returning
-ESTALEto redo the lookup and update the file size), so we're not in a huge rush.
Could you ping me in latest two weeks again? Either I found some time for compound requests by then, or we need to go the easier way. As long as our DLM mode is not ready we also need this feature, just a lot of the more urgent issues before that.
Thanks,
Bernd
Quoted 76 lines · Bernd Schubert
Quoted 48 lines · Joanne Koong
Quoted 34 lines · Bernd Schubert
Hi Joanne,
Quoted 29 lines · Joanne Koong
Quoted 13 lines · Miklos Szeredi
Quoted 10 lines · Bernd Schubert
struct
atomic_open{ uint64_t atomic_open_flags; struct fuse_open_out open_out; uint8_t future_padding1[16]; struct fuse_entry_out entry_out; uint8_t future_padding2[16]; }Quoted 4 lines
Quoted 1 line
What do you think?
I'm wondering if something like the "compound procedure" in NFSv4 would work for fuse as well?
Are compound requests still something that's planned to be added to fuse given that fuse now has support for sending requests over uring, which diminishes the overhead of kernel/userspace context switches for sending multiple requests vs 1 big compound request?
The reason I ask is because the mitigation for the stale attributes data corruption for servers backed by network filesystems we saw in
[1] is dependent on this patch / compound requests. If compound requests are no longer useful / planned, then what are your thoughts on [1] as an acceptable solution?Hi Bernd,
Quoted 3 lines
sorry, I have it in our ticket system, but I'm totally occupied with others issues for weeks *sigh*
No worries!
Quoted 3 lines
Does io-uring really help if there is just on application doing IO to the current core/ring-queue?
Quoted 7 lines
Quoted 3 lines
open - blocking fg request
getattr - blocking fg requestMy understanding (and please correct me here if i'm wrong) is that the main benefit of compound requests is that it bundles multiple requests into 1 request to minimize kernel/userspace context switches. For fuse
I think it would be good, to give fuse-server also the chance to handle the compound on its own. Example, sshfs would benefit from it as well (ok, the sftp protocol needs to get an extension, afaik), see here
https://github.com/libfuse/libfuse/issues/945
If sshfs would now do two requests, it would introduce double network latency - not your about you, but from my home to main lab hardware (US) that would already be quite noticeable.
If sshfs/sftp would get a protocol extension and handle open+getattr in one request, there would be basically zero overhead.Quoted 5 lines
io-uring [2], "motivation ... is... to increase fuse performance by:
Reducing kernel/userspace context switches. Part of that is given by the ring ring - handling multiple requests on either side of kernel/userspace without the need to switch per request".
Quoted 8 lines
Quoted 2 lines
Am I missing something in my understanding of io-uring reducing context switches?
With fuse-io-uring we have reduced context switches, because result submit can immediately fetch the next request, vs previous read + write.
Then we also avoid context switches if the ring is busy - it
What does it mean for the ring to be "busy"? As in it has multiple requests queued on it?
Quoted 1 line
can stay on either side if there is still work to do.
Can you explain what "there is still work to do" here means?
Quoted 10 lines
For open and then getattr and if the ring is idle, we still have the overhead of two independent operations.
One issue I'm currently working is is reducing memory overhead, we actually might need a fuse-io-uring mode with less rings. In that mode chances to have a busy ring are higher. Although I'm still fighting against it, because it takes away core affinity and that was showing 3x performance gains with blocking / fg requests.
Awesome, excited to hear the updates on this when you have them. We will encounter the same issue.
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
If we could dispatch both as bg request and wait for the response it might work out, but in the current form not ideal.
I can only try to find the time over the weekend to work on the compound reuqest, although need to send out the other patch and especially to test it (the one about possible list corruption).
Quoted 5 lines
If you need an extra pair of hands, i'm happy to help out with this. Internally, we'd like to get the proper fix in for the issue in [1], but we have a hacky workaround for it right now (returning
-ESTALEto redo the lookup and update the file size), so we're not in a huge rush.
Quoted 5 lines
Could you ping me in latest two weeks again? Either I found some time for compound requests by then, or we need to go the easier way. As long as our DLM mode is not ready we also need this feature, just a lot of the more urgent issues before that.
Sounds good, thanks!
Quoted 4 lines
Thanks,
Bernd
Quoted 98 lines · Bernd Schubert
This is to update attributes on open to achieve close-to-open coherency even if an inode has a attribute cache timeout.
Signed-off-by Bernd Schubert <[email protected]>---
libfuse patch:
https://github.com/libfuse/libfuse/pull/1020
(FUSE_OPENDIR_GETATTRstill missing at time of writing)Note: This does not make use of existing atomic-open patches as these are more complex than two new opcodes for open-getattr.
Note2: This is an alternative to Joannes patch that adds
FOPEN_FETCH_ATTR, which would need to kernel/userspace transitions
https://lore.kernel.org/all/[email protected]/Question for reviewers:
- Should this better use statx fields? Probably not needed for coherency?
- Should this introduce a new struct that contains structfuse_open_outand structfuse_attr_out, with additional padding between them to avoid incompat issues if either struct should be extended?--- fs/fuse/file.c | 94 ++++++++++++++++++++++++++++++++++++++- fs/fuse/fuse_i.h | 7 +++ fs/fuse/ioctl.c | 2 +- include/uapi/linux/fuse.h | 5 +++ 4 files changed, 105 insertions(+), 3 deletions(-)fs/fuse/file.c +58
-0@@ -51,6 +51,78 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid,return fuse_simple_request (fm, &args); } +/* +* Open the file and update inode attributes +*/ +static int fuse_file_open_getattr (struct fuse_mount *fm,u64 nodeid, +struct inode *inode,unsigned int open_flags, +int opcode, +struct fuse_open_out *open_outargp) +{ +struct fuse_conn *fc = fm->fc; +u64 attr_version =fuse_get_attr_version (fc); +struct fuse_open_in inarg; +struct fuse_attr_out attr_outarg; +FUSE_ARGS (args); +int err; + +/* convert the opcode from plain open to open-with-getattr */ +if (opcode ==FUSE_OPEN ) { +if (fc->no_open_getattr) +return -ENOSYS ; + opcode =FUSE_OPEN_GETATTR ; + }else { +if (fc->no_opendir_getattr) +return -ENOSYS ; + opcode =FUSE_OPENDIR_GETATTR ; + } + +memset (&inarg,0 ,sizeof (inarg)); + inarg.flags = open_flags & ~(O_CREAT |O_EXCL |O_NOCTTY ); +if (!fm->fc->atomic_o_trunc) + inarg.flags &= ~O_TRUNC ; + +if (fm->fc->handle_killpriv_v2 && + (inarg.flags &O_TRUNC ) && !capable (CAP_FSETID )) { + inarg.open_flags |=FUSE_OPEN_KILL_SUIDGID ; + } + + args.opcode = opcode; + args.nodeid = nodeid; + args.in_numargs =1 ; + args.in_args[0 ].size =sizeof (inarg); + args.in_args[0 ].value = &inarg; + args.out_numargs =2 ; + args.out_args[0 ].size =sizeof (*open_outargp); + args.out_args[0 ].value = open_outargp; + args.out_args[1 ].size =sizeof (attr_outarg); + args.out_args[1 ].value = &attr_outarg; + + err =fuse_simple_request (fm, &args); +if (err) { +if (err == -ENOSYS ) { +if (opcode ==FUSE_OPEN ) + fc->no_open_getattr =1 ; +else + fc->no_opendir_getattr =1 ; + } +return err; + } +
fs/fuse/file.c static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, · line 121
Quoted 10 lines
fs/fuse/file.c +10
-0+ err = -EIO ; +if (fuse_invalid_attr (&attr_outarg.attr) || +inode_wrong_type (inode, attr_outarg.attr.mode)) { +fuse_make_bad (inode); +return err; + } + +fuse_change_attributes (inode, &attr_outarg.attr,NULL , +ATTR_TIMEOUT (&attr_outarg), attr_version); +
Hi Bernrd,
For my use case, it'd be preferred if this could be gated by an FOPEN flag that the server can set in the reply if it doesn't want to opt into the refreshed attributes (eg if this flag is set, then the getattr values in the reply are blank and the kernel should skip fuse_change_attributes()). For the use case I have, the attributes only need to be fetched and changed for O_APPENDs where it'd be ideal if we could skip this overhead for non O_APPENDs.
This flag can be added separately after your patch lands, but just wanted to note this now as a heads-up. I'm also happy to add this in later if it's better to do this later than as part of this patch.
Thanks,
Joanne