Re: [RFC PATCH 3/3] fuse: add per-file DAX flag

Started by Vivek Goyal on Jul 16, 2021 · 5 messages from 2 authors · Last reply Jul 16, 2021

open the first message on its own page

  1. [PATCH] virtiofsd: support per-file DAX
    Related patches
Message details and related content
On Fri, Jul 16, 2021 at 08:40:29AM +0800, Liu Bo wrote:
On Thu, Jul 15, 2021 at 05:30:31PM +0800, Jeffle Xu wrote:
quoted
Add one flag for fuse_attr.flags indicating if DAX shall be enabled for
this file.

When the per-file DAX flag changes for an *opened* file, the state of
the file won't be updated until this file is closed and reopened later.

Currently it is not implemented yet to change per-file DAX flag inside
guest kernel, e.g., by chattr(1).
Thanks for the patch, it looks good to me.

I think it's a good starting point, what I'd like to discuss here is
whether we're going to let chattr to toggle the dax flag.
I have the same question. Why not take chattr approach as taken
by ext4/xfs as well.

Vivek
My usecase is like, on the fuse server side, if a file is marked as
DAX, then it won't change any more.  So this 'fuse_attr.flags' works
for me at least.

thanks,
liubo
quoted
Signed-off-by: Jeffle Xu <redacted>
---
 fs/fuse/dax.c             | 28 ++++++++++++++++++++++++----
 fs/fuse/file.c            |  4 ++--
 fs/fuse/fuse_i.h          |  5 +++--
 fs/fuse/inode.c           |  4 +++-
 include/uapi/linux/fuse.h |  5 +++++
 5 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index 4873d764cb66..ed5a430364bb 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -1341,7 +1341,7 @@ static const struct address_space_operations fuse_dax_file_aops  = {
 	.invalidatepage	= noop_invalidatepage,
 };
 
-static bool fuse_should_enable_dax(struct inode *inode)
+static bool fuse_should_enable_dax(struct inode *inode, unsigned int flags)
 {
 	struct fuse_conn *fc = get_fuse_conn(inode);
 	unsigned int mode;
@@ -1354,18 +1354,38 @@ static bool fuse_should_enable_dax(struct inode *inode)
 	if (mode == FUSE_DAX_MOUNT_NEVER)
 		return false;
 
-	return true;
+	if (mode == FUSE_DAX_MOUNT_ALWAYS)
+		return true;
+
+	WARN_ON(mode != FUSE_DAX_MOUNT_INODE);

127 more quoted lines

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Message details and related content

On 7/16/21 8:51 AM, Vivek Goyal wrote:
On Fri, Jul 16, 2021 at 08:40:29AM +0800, Liu Bo wrote:
quoted
On Thu, Jul 15, 2021 at 05:30:31PM +0800, Jeffle Xu wrote:
quoted
Add one flag for fuse_attr.flags indicating if DAX shall be enabled for
this file.

When the per-file DAX flag changes for an *opened* file, the state of
the file won't be updated until this file is closed and reopened later.

Currently it is not implemented yet to change per-file DAX flag inside
guest kernel, e.g., by chattr(1).
Thanks for the patch, it looks good to me.

I think it's a good starting point, what I'd like to discuss here is
whether we're going to let chattr to toggle the dax flag.
I have the same question. Why not take chattr approach as taken
by ext4/xfs as well.

Vivek
Thanks.

We can implement the chattr approach as ext4/xfs do, if we have this use
scenario. It's an RFC patch, and I want to collect more feedback as soon
as possible.

-- 
Thanks,
Jeffle
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Message details and related content
On Fri, Jul 16, 2021 at 09:18:34AM +0800, JeffleXu wrote:

On 7/16/21 8:51 AM, Vivek Goyal wrote:
quoted
On Fri, Jul 16, 2021 at 08:40:29AM +0800, Liu Bo wrote:
quoted
On Thu, Jul 15, 2021 at 05:30:31PM +0800, Jeffle Xu wrote:
quoted
Add one flag for fuse_attr.flags indicating if DAX shall be enabled for
this file.

When the per-file DAX flag changes for an *opened* file, the state of
the file won't be updated until this file is closed and reopened later.

Currently it is not implemented yet to change per-file DAX flag inside
guest kernel, e.g., by chattr(1).
Thanks for the patch, it looks good to me.

I think it's a good starting point, what I'd like to discuss here is
whether we're going to let chattr to toggle the dax flag.
I have the same question. Why not take chattr approach as taken
by ext4/xfs as well.

Vivek
Thanks.

We can implement the chattr approach as ext4/xfs do, if we have this use
scenario. It's an RFC patch, and I want to collect more feedback as soon
as possible.
I guess chattr approach will allow client (as well as server) to control
which files should be DAX. While this approach allows only server to
specify which files should use DAX. Given currently we let client
control whether to use dax or not (-o dax), it probably will make
sense to use chattr based approach?

I will look at the patches. Do you have a corresponding user space
implementation somewhere so that I can test it?

Vivek

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH] virtiofsd: support per-file DAX

Message details and related content
An example implementation of supporting per-file DAX flag for virtiofsd,
where DAx is enabled for files larger than 1M size.

Signed-off-by: Jeffle Xu <redacted>
---
 contrib/virtiofsd/fuse_kernel.h   | 4 +++-
 contrib/virtiofsd/fuse_lowlevel.c | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/virtiofsd/fuse_kernel.h b/contrib/virtiofsd/fuse_kernel.h
index d2b7ccf96b..9c476b7021 100644
--- a/contrib/virtiofsd/fuse_kernel.h
+++ b/contrib/virtiofsd/fuse_kernel.h
@@ -165,6 +165,8 @@
 /** The node ID of the root inode */
 #define FUSE_ROOT_ID 1
 
+#define FUSE_ATTR_DAX  (1 << 1)
+
 /* Make sure all structures are padded to 64bit boundary, so 32bit
    userspace works under 64bit kernels */
 
@@ -184,7 +186,7 @@ struct fuse_attr {
 	uint32_t	gid;
 	uint32_t	rdev;
 	uint32_t	blksize;
-	uint32_t	padding;
+	uint32_t	flags;
 };
 
 struct fuse_kstatfs {
diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
index 046a1b4a02..d8a3873246 100644
--- a/contrib/virtiofsd/fuse_lowlevel.c
+++ b/contrib/virtiofsd/fuse_lowlevel.c
@@ -60,6 +60,9 @@ static void convert_stat(const struct stat *stbuf, struct fuse_attr *attr)
 	attr->atimensec = ST_ATIM_NSEC(stbuf);
 	attr->mtimensec = ST_MTIM_NSEC(stbuf);
 	attr->ctimensec = ST_CTIM_NSEC(stbuf);
+
+	if (stbuf->st_size >= 1048576)
+		attr->flags |= FUSE_ATTR_DAX;
 }
 
 static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
-- 
2.27.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Message details and related content

On 7/16/21 9:32 AM, Vivek Goyal wrote:
On Fri, Jul 16, 2021 at 09:18:34AM +0800, JeffleXu wrote:
quoted

On 7/16/21 8:51 AM, Vivek Goyal wrote:
quoted
On Fri, Jul 16, 2021 at 08:40:29AM +0800, Liu Bo wrote:
quoted
On Thu, Jul 15, 2021 at 05:30:31PM +0800, Jeffle Xu wrote:
quoted
Add one flag for fuse_attr.flags indicating if DAX shall be enabled for
this file.

When the per-file DAX flag changes for an *opened* file, the state of
the file won't be updated until this file is closed and reopened later.

Currently it is not implemented yet to change per-file DAX flag inside
guest kernel, e.g., by chattr(1).
Thanks for the patch, it looks good to me.

I think it's a good starting point, what I'd like to discuss here is
whether we're going to let chattr to toggle the dax flag.
I have the same question. Why not take chattr approach as taken
by ext4/xfs as well.

Vivek
Thanks.

We can implement the chattr approach as ext4/xfs do, if we have this use
scenario. It's an RFC patch, and I want to collect more feedback as soon
as possible.
I guess chattr approach will allow client (as well as server) to control
which files should be DAX. While this approach allows only server to
specify which files should use DAX. Given currently we let client
control whether to use dax or not (-o dax), it probably will make
sense to use chattr based approach?
Yes, changing the per-file DAX flag from guest side, such as by chattr,
may be needed for completeness. I will include this in the next version.
I will look at the patches. Do you have a corresponding user space
implementation somewhere so that I can test it?
Thanks. I have sent the corresponding patch in-reply-to your mail.

-- 
Thanks,
Jeffle
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help