fusefs: raise protocol level to 7.23

None of the new features are implemented yet.  This commit just adds the new
protocol definitions and adds backwards-compatibility code for pre 7.23
servers.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-06-21 04:57:23 +00:00
parent 1f309e37f5
commit 87ff949a7b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=349263
5 changed files with 63 additions and 12 deletions

View File

@ -910,7 +910,8 @@ fuse_internal_init_callback(struct fuse_ticket *tick, struct uio *uio)
} }
if (fuse_libabi_geq(data, 7, 5)) { if (fuse_libabi_geq(data, 7, 5)) {
if (fticket_resp(tick)->len == sizeof(struct fuse_init_out)) { if (fticket_resp(tick)->len == sizeof(struct fuse_init_out) ||
fticket_resp(tick)->len == FUSE_COMPAT_22_INIT_OUT_SIZE) {
data->max_write = fiio->max_write; data->max_write = fiio->max_write;
if (fiio->flags & FUSE_ASYNC_READ) if (fiio->flags & FUSE_ASYNC_READ)
data->dataflags |= FSESS_ASYNC_READ; data->dataflags |= FSESS_ASYNC_READ;
@ -923,8 +924,8 @@ fuse_internal_init_callback(struct fuse_ticket *tick, struct uio *uio)
* redundant with max_write * redundant with max_write
*/ */
/* /*
* max_background and congestion_threshold are not * max_background, congestion_threshold, and time_gran
* implemented * are not implemented
*/ */
} else { } else {
err = EINVAL; err = EINVAL;

View File

@ -812,7 +812,9 @@ fuse_body_audit(struct fuse_ticket *ftick, size_t blen)
break; break;
case FUSE_INIT: case FUSE_INIT:
if (blen == sizeof(struct fuse_init_out) || blen == 8) { if (blen == sizeof(struct fuse_init_out) ||
blen == FUSE_COMPAT_INIT_OUT_SIZE ||
blen == FUSE_COMPAT_22_INIT_OUT_SIZE) {
err = 0; err = 0;
} else { } else {
err = EINVAL; err = EINVAL;

View File

@ -90,6 +90,18 @@
* 7.21 * 7.21
* - add FUSE_READDIRPLUS * - add FUSE_READDIRPLUS
* - send the requested events in POLL request * - send the requested events in POLL request
*
* 7.22
* - add FUSE_ASYNC_DIO
*
* 7.23
* - add FUSE_WRITEBACK_CACHE
* - add time_gran to fuse_init_out
* - add reserved space to fuse_init_out
* - add FATTR_CTIME
* - add ctime and ctimensec to fuse_setattr_in
* - add FUSE_RENAME2 request
* - add FUSE_NO_OPEN_SUPPORT flag
*/ */
#ifndef _FUSE_FUSE_KERNEL_H #ifndef _FUSE_FUSE_KERNEL_H
@ -105,7 +117,7 @@
#define FUSE_KERNEL_VERSION 7 #define FUSE_KERNEL_VERSION 7
/** Minor version number of this interface */ /** Minor version number of this interface */
#define FUSE_KERNEL_MINOR_VERSION 21 #define FUSE_KERNEL_MINOR_VERSION 23
/** The node ID of the root inode */ /** The node ID of the root inode */
#define FUSE_ROOT_ID 1 #define FUSE_ROOT_ID 1
@ -165,6 +177,7 @@ struct fuse_file_lock {
#define FATTR_ATIME_NOW (1 << 7) #define FATTR_ATIME_NOW (1 << 7)
#define FATTR_MTIME_NOW (1 << 8) #define FATTR_MTIME_NOW (1 << 8)
#define FATTR_LOCKOWNER (1 << 9) #define FATTR_LOCKOWNER (1 << 9)
#define FATTR_CTIME (1 << 10)
/** /**
* Flags returned by the OPEN request * Flags returned by the OPEN request
@ -195,6 +208,9 @@ struct fuse_file_lock {
* FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages * FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
* FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one) * FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
* FUSE_READDIRPLUS_AUTO: adaptive readdirplus * FUSE_READDIRPLUS_AUTO: adaptive readdirplus
* FUSE_ASYNC_DIO: asynchronous direct I/O submission
* FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
* FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
*/ */
#define FUSE_ASYNC_READ (1 << 0) #define FUSE_ASYNC_READ (1 << 0)
#define FUSE_POSIX_LOCKS (1 << 1) #define FUSE_POSIX_LOCKS (1 << 1)
@ -211,6 +227,9 @@ struct fuse_file_lock {
#define FUSE_AUTO_INVAL_DATA (1 << 12) #define FUSE_AUTO_INVAL_DATA (1 << 12)
#define FUSE_DO_READDIRPLUS (1 << 13) #define FUSE_DO_READDIRPLUS (1 << 13)
#define FUSE_READDIRPLUS_AUTO (1 << 14) #define FUSE_READDIRPLUS_AUTO (1 << 14)
#define FUSE_ASYNC_DIO (1 << 15)
#define FUSE_WRITEBACK_CACHE (1 << 16)
#define FUSE_NO_OPEN_SUPPORT (1 << 17)
#ifdef linux #ifdef linux
/** /**
@ -320,6 +339,7 @@ enum fuse_opcode {
FUSE_BATCH_FORGET = 42, FUSE_BATCH_FORGET = 42,
FUSE_FALLOCATE = 43, FUSE_FALLOCATE = 43,
FUSE_READDIRPLUS = 44, FUSE_READDIRPLUS = 44,
FUSE_RENAME2 = 45,
#ifdef linux #ifdef linux
/* CUSE specific operations */ /* CUSE specific operations */
@ -400,6 +420,12 @@ struct fuse_rename_in {
uint64_t newdir; uint64_t newdir;
}; };
struct fuse_rename2_in {
uint64_t newdir;
uint32_t flags;
uint32_t padding;
};
struct fuse_link_in { struct fuse_link_in {
uint64_t oldnodeid; uint64_t oldnodeid;
}; };
@ -412,10 +438,10 @@ struct fuse_setattr_in {
uint64_t lock_owner; uint64_t lock_owner;
uint64_t atime; uint64_t atime;
uint64_t mtime; uint64_t mtime;
uint64_t unused2; uint64_t ctime;
uint32_t atimensec; uint32_t atimensec;
uint32_t mtimensec; uint32_t mtimensec;
uint32_t unused3; uint32_t ctimensec;
uint32_t mode; uint32_t mode;
uint32_t unused4; uint32_t unused4;
uint32_t uid; uint32_t uid;
@ -543,6 +569,9 @@ struct fuse_init_in {
uint32_t flags; uint32_t flags;
}; };
#define FUSE_COMPAT_INIT_OUT_SIZE 8
#define FUSE_COMPAT_22_INIT_OUT_SIZE 24
struct fuse_init_out { struct fuse_init_out {
uint32_t major; uint32_t major;
uint32_t minor; uint32_t minor;
@ -551,6 +580,8 @@ struct fuse_init_out {
uint16_t max_background; uint16_t max_background;
uint16_t congestion_threshold; uint16_t congestion_threshold;
uint32_t max_write; uint32_t max_write;
uint32_t time_gran;
uint32_t unused[9];
}; };
#ifdef linux #ifdef linux
@ -615,7 +646,7 @@ struct fuse_poll_in {
uint64_t fh; uint64_t fh;
uint64_t kh; uint64_t kh;
uint32_t flags; uint32_t flags;
uint32_t events; uint32_t events;
}; };
struct fuse_poll_out { struct fuse_poll_out {
@ -661,7 +692,8 @@ struct fuse_dirent {
}; };
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) #define FUSE_DIRENT_ALIGN(x) \
(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
#define FUSE_DIRENT_SIZE(d) \ #define FUSE_DIRENT_SIZE(d) \
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)

View File

@ -469,11 +469,15 @@ void MockFS::init(uint32_t flags) {
out->body.init.major = FUSE_KERNEL_VERSION; out->body.init.major = FUSE_KERNEL_VERSION;
out->body.init.minor = m_kernel_minor_version;; out->body.init.minor = m_kernel_minor_version;;
out->body.init.flags = in->body.init.flags & flags; out->body.init.flags = in->body.init.flags & flags;
out->body.init.max_write = m_maxwrite; out->body.init.max_write = m_maxwrite;
out->body.init.max_readahead = m_maxreadahead; out->body.init.max_readahead = m_maxreadahead;
SET_OUT_HEADER_LEN(*out, init);
if (m_kernel_minor_version < 23) {
SET_OUT_HEADER_LEN(*out, init_7_22);
} else {
SET_OUT_HEADER_LEN(*out, init);
}
write(m_fuse_fd, out.get(), out->header.len); write(m_fuse_fd, out.get(), out->header.len);
} }

View File

@ -122,6 +122,17 @@ struct fuse_create_out_7_8 {
struct fuse_open_out open; struct fuse_open_out open;
}; };
/* Output struct for FUSE_INIT for protocol 7.22 and earlier servers */
struct fuse_init_out_7_22 {
uint32_t major;
uint32_t minor;
uint32_t max_readahead;
uint32_t flags;
uint16_t max_background;
uint16_t congestion_threshold;
uint32_t max_write;
};
union fuse_payloads_in { union fuse_payloads_in {
fuse_access_in access; fuse_access_in access;
fuse_bmap_in bmap; fuse_bmap_in bmap;
@ -178,6 +189,7 @@ union fuse_payloads_out {
fuse_lk_out getlk; fuse_lk_out getlk;
fuse_getxattr_out getxattr; fuse_getxattr_out getxattr;
fuse_init_out init; fuse_init_out init;
fuse_init_out_7_22 init_7_22;
/* The inval_entry structure should be followed by the entry's name */ /* The inval_entry structure should be followed by the entry's name */
fuse_notify_inval_entry_out inval_entry; fuse_notify_inval_entry_out inval_entry;
fuse_notify_inval_inode_out inval_inode; fuse_notify_inval_inode_out inval_inode;