Skip to content

Commit 1030457

Browse files
committed
abi: fix the conflict of PERFILE_DAX flag
The current upstream flag is defined as: FUSE_INIT_EXT (1 << 30) FUSE_HAS_INODE_DAX (1ULL << 33) We should follow it. Signed-off-by: Huang Jianan <[email protected]>
1 parent 87818ac commit 1030457

File tree

2 files changed

+57
-34
lines changed

2 files changed

+57
-34
lines changed

src/abi/fuse_abi.rs

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -110,95 +110,98 @@ bitflags! {
110110
// INIT request/reply flags.
111111

112112
/// Asynchronous read requests.
113-
const ASYNC_READ: u32 = 0x1;
113+
const ASYNC_READ: u64 = 0x1;
114114

115115
/// Remote locking for POSIX file locks.
116-
const POSIX_LOCKS: u32 = 0x2;
116+
const POSIX_LOCKS: u64 = 0x2;
117117

118118
/// Kernel sends file handle for fstat, etc... (not yet supported).
119-
const FILE_OPS: u32 = 0x4;
119+
const FILE_OPS: u64 = 0x4;
120120

121121
/// Handles the O_TRUNC open flag in the filesystem.
122-
const ATOMIC_O_TRUNC: u32 = 0x8;
122+
const ATOMIC_O_TRUNC: u64 = 0x8;
123123

124124
/// FileSystem handles lookups of "." and "..".
125-
const EXPORT_SUPPORT: u32 = 0x10;
125+
const EXPORT_SUPPORT: u64 = 0x10;
126126

127127
/// FileSystem can handle write size larger than 4kB.
128-
const BIG_WRITES: u32 = 0x20;
128+
const BIG_WRITES: u64 = 0x20;
129129

130130
/// Don't apply umask to file mode on create operations.
131-
const DONT_MASK: u32 = 0x40;
131+
const DONT_MASK: u64 = 0x40;
132132

133133
/// Kernel supports splice write on the device.
134-
const SPLICE_WRITE: u32 = 0x80;
134+
const SPLICE_WRITE: u64 = 0x80;
135135

136136
/// Kernel supports splice move on the device.
137-
const SPLICE_MOVE: u32 = 0x100;
137+
const SPLICE_MOVE: u64 = 0x100;
138138

139139
/// Kernel supports splice read on the device.
140-
const SPLICE_READ: u32 = 0x200;
140+
const SPLICE_READ: u64 = 0x200;
141141

142142
/// Remote locking for BSD style file locks.
143-
const FLOCK_LOCKS: u32 = 0x400;
143+
const FLOCK_LOCKS: u64 = 0x400;
144144

145145
/// Kernel supports ioctl on directories.
146-
const HAS_IOCTL_DIR: u32 = 0x800;
146+
const HAS_IOCTL_DIR: u64 = 0x800;
147147

148148
/// Automatically invalidate cached pages.
149-
const AUTO_INVAL_DATA: u32 = 0x1000;
149+
const AUTO_INVAL_DATA: u64 = 0x1000;
150150

151151
/// Do READDIRPLUS (READDIR+LOOKUP in one).
152-
const DO_READDIRPLUS: u32 = 0x2000;
152+
const DO_READDIRPLUS: u64 = 0x2000;
153153

154154
/// Adaptive readdirplus.
155-
const READDIRPLUS_AUTO: u32 = 0x4000;
155+
const READDIRPLUS_AUTO: u64 = 0x4000;
156156

157157
/// Asynchronous direct I/O submission.
158-
const ASYNC_DIO: u32 = 0x8000;
158+
const ASYNC_DIO: u64 = 0x8000;
159159

160160
/// Use writeback cache for buffered writes.
161-
const WRITEBACK_CACHE: u32 = 0x1_0000;
161+
const WRITEBACK_CACHE: u64 = 0x1_0000;
162162

163163
/// Kernel supports zero-message opens.
164-
const NO_OPEN_SUPPORT: u32 = 0x2_0000;
164+
const NO_OPEN_SUPPORT: u64 = 0x2_0000;
165165

166166
/// Allow parallel lookups and readdir.
167-
const PARALLEL_DIROPS: u32 = 0x4_0000;
167+
const PARALLEL_DIROPS: u64 = 0x4_0000;
168168

169169
/// Fs handles killing suid/sgid/cap on write/chown/trunc.
170-
const HANDLE_KILLPRIV: u32 = 0x8_0000;
170+
const HANDLE_KILLPRIV: u64 = 0x8_0000;
171171

172172
/// FileSystem supports posix acls.
173-
const POSIX_ACL: u32 = 0x10_0000;
173+
const POSIX_ACL: u64 = 0x10_0000;
174174

175175
// Reading the fuse device after abort returns ECONNABORTED
176-
const ABORT_ERROR: u32 = 0x20_0000;
176+
const ABORT_ERROR: u64 = 0x20_0000;
177177

178178
// INIT response init_out.max_pages contains the max number of req pages
179-
const MAX_PAGES: u32 = 0x40_0000;
179+
const MAX_PAGES: u64 = 0x40_0000;
180180

181181
// Kernel caches READLINK responses
182-
const CACHE_SYMLINKS: u32 = 0x80_0000;
182+
const CACHE_SYMLINKS: u64 = 0x80_0000;
183183

184184
// Kernel supports zero-message opendir
185-
const NO_OPENDIR_SUPPORT: u32 = 0x100_0000;
185+
const NO_OPENDIR_SUPPORT: u64 = 0x100_0000;
186186

187187
// Only invalidate cached pages on explicit request
188-
const EXPLICIT_INVAL_DATA: u32 = 0x200_0000;
188+
const EXPLICIT_INVAL_DATA: u64 = 0x200_0000;
189189

190190
// INIT response init_out.map_alignment contains byte alignment for foffset and
191191
// moffset fields in struct fuse_setupmapping_out and fuse_removemapping_one.
192-
const MAP_ALIGNMENT: u32 = 0x400_0000;
192+
const MAP_ALIGNMENT: u64 = 0x400_0000;
193193

194194
// Kernel supports auto-mounting directory submounts
195-
const SUBMOUNTS: u32 = 0x800_0000;
195+
const SUBMOUNTS: u64 = 0x800_0000;
196196

197197
// Filesystem responsible for clearing security.capability xattr and setuid/setgid bits.
198-
const HANDLE_KILLPRIV_V2: u32 = 0x1000_0000;
198+
const HANDLE_KILLPRIV_V2: u64 = 0x1000_0000;
199+
200+
// This flag indicates whether the fuse_init_in is extended
201+
const INIT_EXT: u64 = 0x4000_0000;
199202

200203
// This flag indicates whether the guest kernel enable per-file dax
201-
const PERFILE_DAX: u32 = 0x4000_0000;
204+
const PERFILE_DAX: u64 = 0x2_0000_0000;
202205

203206
/**
204207
*
@@ -214,7 +217,7 @@ pub const FUSE_ATTR_DAX: u32 = 1 << 1;
214217
bitflags! {
215218
/// A bitfield passed in as a parameter to and returned from the `init` method of the
216219
/// `FileSystem` trait.
217-
pub struct FsOptions: u32 {
220+
pub struct FsOptions: u64 {
218221
/// Indicates that the filesystem supports asynchronous read requests.
219222
///
220223
/// If this capability is not requested/available, the kernel will ensure that there is at
@@ -445,6 +448,9 @@ bitflags! {
445448
/// -. write has WRITE_KILL_PRIV
446449
const HANDLE_KILLPRIV_V2 = HANDLE_KILLPRIV_V2;
447450

451+
/// The fuse_init_in is extended.
452+
const INIT_EXT = INIT_EXT;
453+
448454
/// Indicates whether the guest kernel enable per-file dax
449455
///
450456
/// If this feature is enabled, filesystem will notify guest kernel whether file
@@ -1082,6 +1088,15 @@ pub struct InitIn {
10821088
}
10831089
unsafe impl ByteValued for InitIn {}
10841090

1091+
//The flag has been extended to 64 bit since fuse 7.36
1092+
#[repr(C)]
1093+
#[derive(Debug, Default, Copy, Clone)]
1094+
pub struct InitIn2 {
1095+
pub flags2: u32,
1096+
pub unused: [u32; 11],
1097+
}
1098+
unsafe impl ByteValued for InitIn2 {}
1099+
10851100
#[repr(C)]
10861101
#[derive(Debug, Default, Copy, Clone)]
10871102
pub struct InitOut {
@@ -1095,7 +1110,8 @@ pub struct InitOut {
10951110
pub time_gran: u32,
10961111
pub max_pages: u16,
10971112
pub map_alignment: u16,
1098-
pub unused: [u32; 8],
1113+
pub flags2: u32,
1114+
pub unused: [u32; 7],
10991115
}
11001116
unsafe impl ByteValued for InitOut {}
11011117

src/api/server/sync_io.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,12 @@ impl<F: FileSystem + Sync> Server<F> {
606606
return ctx.reply_ok(Some(out), None);
607607
}
608608

609-
let capable = FsOptions::from_bits_truncate(flags);
609+
let mut flags_u64 = flags as u64;
610+
if flags_u64 & FsOptions::INIT_EXT.bits() != 0 {
611+
let InitIn2 { flags2, unused: _ } = ctx.r.read_obj().map_err(Error::DecodeMessage)?;
612+
flags_u64 |= (flags2 as u64) << 32;
613+
}
614+
let capable = FsOptions::from_bits_truncate(flags_u64);
610615

611616
match self.fs.init(capable) {
612617
Ok(want) => {
@@ -622,15 +627,17 @@ impl<F: FileSystem + Sync> Server<F> {
622627
max_readahead
623628
};
624629

630+
let enabled_flags = enabled.bits();
625631
let mut out = InitOut {
626632
major: KERNEL_VERSION,
627633
minor: KERNEL_MINOR_VERSION,
628634
max_readahead: readahead,
629-
flags: enabled.bits(),
635+
flags: enabled_flags as u32,
630636
max_background: ::std::u16::MAX,
631637
congestion_threshold: (::std::u16::MAX / 4) * 3,
632638
max_write: MIN_READ_BUFFER - BUFFER_HEADER_SIZE,
633639
time_gran: 1, // nanoseconds
640+
flags2: (enabled_flags >> 32) as u32,
634641
..Default::default()
635642
};
636643
if enabled.contains(FsOptions::BIG_WRITES) {

0 commit comments

Comments
 (0)