Skip to content

Commit 2ee019f

Browse files
lostjeffleMiklos Szeredi
authored andcommitted
fuse: negotiate per inode DAX in FUSE_INIT
Among the FUSE_INIT phase, client shall advertise per inode DAX if it's mounted with "dax=inode". Then server is aware that client is in per inode DAX mode, and will construct per-inode DAX attribute accordingly. Server shall also advertise support for per inode DAX. If server doesn't support it while client is mounted with "dax=inode", client will silently fallback to "dax=never" since "dax=inode" is advisory only. Signed-off-by: Jeffle Xu <[email protected]> Reviewed-by: Vivek Goyal <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 93a497b commit 2ee019f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

fs/fuse/dax.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ static bool fuse_should_enable_dax(struct inode *inode, unsigned int flags)
13491349
return true;
13501350

13511351
/* dax_mode is FUSE_DAX_INODE* */
1352-
return flags & FUSE_ATTR_DAX;
1352+
return fc->inode_dax && (flags & FUSE_ATTR_DAX);
13531353
}
13541354

13551355
void fuse_dax_inode_init(struct inode *inode, unsigned int flags)

fs/fuse/fuse_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ struct fuse_conn {
780780
/* Initialize security xattrs when creating a new inode */
781781
unsigned int init_security:1;
782782

783+
/* Does the filesystem support per inode DAX? */
784+
unsigned int inode_dax:1;
785+
783786
/** The number of requests waiting for completion */
784787
atomic_t num_waiting;
785788

fs/fuse/inode.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,13 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
11711171
min_t(unsigned int, fc->max_pages_limit,
11721172
max_t(unsigned int, arg->max_pages, 1));
11731173
}
1174-
if (IS_ENABLED(CONFIG_FUSE_DAX) &&
1175-
flags & FUSE_MAP_ALIGNMENT &&
1176-
!fuse_dax_check_alignment(fc, arg->map_alignment)) {
1177-
ok = false;
1174+
if (IS_ENABLED(CONFIG_FUSE_DAX)) {
1175+
if (flags & FUSE_MAP_ALIGNMENT &&
1176+
!fuse_dax_check_alignment(fc, arg->map_alignment)) {
1177+
ok = false;
1178+
}
1179+
if (flags & FUSE_HAS_INODE_DAX)
1180+
fc->inode_dax = 1;
11781181
}
11791182
if (flags & FUSE_HANDLE_KILLPRIV_V2) {
11801183
fc->handle_killpriv_v2 = 1;
@@ -1233,6 +1236,8 @@ void fuse_send_init(struct fuse_mount *fm)
12331236
#ifdef CONFIG_FUSE_DAX
12341237
if (fm->fc->dax)
12351238
flags |= FUSE_MAP_ALIGNMENT;
1239+
if (fuse_is_inode_dax_mode(fm->fc->dax_mode))
1240+
flags |= FUSE_HAS_INODE_DAX;
12361241
#endif
12371242
if (fm->fc->auto_submounts)
12381243
flags |= FUSE_SUBMOUNTS;

0 commit comments

Comments
 (0)