Skip to content

Commit 9e7f529

Browse files
aftersnowMiklos Szeredi
authored andcommitted
fuse: Use the high bit of request ID for indicating resend requests
Some FUSE daemons want to know if the received request is a resend request. The high bit of the fuse request ID is utilized for indicating this, enabling the receiver to perform appropriate handling. The init flag "FUSE_HAS_RESEND" is added to indicate this feature. Signed-off-by: Zhao Chen <winters.zc@antgroup.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 760eac7 commit 9e7f529

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

fs/fuse/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,8 @@ static void fuse_resend(struct fuse_conn *fc)
18141814

18151815
list_for_each_entry_safe(req, next, &to_queue, list) {
18161816
__set_bit(FR_PENDING, &req->flags);
1817+
/* mark the request as resend request */
1818+
req->in.h.unique |= FUSE_UNIQUE_RESEND;
18171819
}
18181820

18191821
spin_lock(&fiq->lock);

fs/fuse/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ void fuse_send_init(struct fuse_mount *fm)
13701370
FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT |
13711371
FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP |
13721372
FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP |
1373-
FUSE_NO_EXPORT_SUPPORT;
1373+
FUSE_NO_EXPORT_SUPPORT | FUSE_HAS_RESEND;
13741374
#ifdef CONFIG_FUSE_DAX
13751375
if (fm->fc->dax)
13761376
flags |= FUSE_MAP_ALIGNMENT;

include/uapi/linux/fuse.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
* - add max_stack_depth to fuse_init_out, add FUSE_PASSTHROUGH init flag
217217
* - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag
218218
* - add FUSE_NO_EXPORT_SUPPORT init flag
219-
* - add FUSE_NOTIFY_RESEND
219+
* - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag
220220
*/
221221

222222
#ifndef _LINUX_FUSE_H
@@ -419,6 +419,8 @@ struct fuse_file_lock {
419419
* FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation
420420
* FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode.
421421
* FUSE_NO_EXPORT_SUPPORT: explicitly disable export support
422+
* FUSE_HAS_RESEND: kernel supports resending pending requests, and the high bit
423+
* of the request ID indicates resend requests
422424
*/
423425
#define FUSE_ASYNC_READ (1 << 0)
424426
#define FUSE_POSIX_LOCKS (1 << 1)
@@ -460,6 +462,7 @@ struct fuse_file_lock {
460462
#define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL << 36)
461463
#define FUSE_PASSTHROUGH (1ULL << 37)
462464
#define FUSE_NO_EXPORT_SUPPORT (1ULL << 38)
465+
#define FUSE_HAS_RESEND (1ULL << 39)
463466

464467
/* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */
465468
#define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP
@@ -973,6 +976,14 @@ struct fuse_fallocate_in {
973976
uint32_t padding;
974977
};
975978

979+
/**
980+
* FUSE request unique ID flag
981+
*
982+
* Indicates whether this is a resend request. The receiver should handle this
983+
* request accordingly.
984+
*/
985+
#define FUSE_UNIQUE_RESEND (1ULL << 63)
986+
976987
struct fuse_in_header {
977988
uint32_t len;
978989
uint32_t opcode;

0 commit comments

Comments
 (0)