All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: virtio-fs@redhat.com, joseph.qi@linux.alibaba.com, miklos@szeredi.hu
Subject: Re: [Virtio-fs] [PATCH v7 5/6] virtiofsd: implement xflag based dax policy
Date: Thu, 9 Dec 2021 17:02:06 -0500	[thread overview]
Message-ID: <YbJ83lJB5eoy/gyQ@redhat.com> (raw)
In-Reply-To: <20211102055646.103337-6-jefflexu@linux.alibaba.com>

On Tue, Nov 02, 2021 at 01:56:45PM +0800, Jeffle Xu wrote:
> The per inode DAX feature in ext4/xfs uses the persistent inode flag,
> i.e. FS_DAX_FL/FS_XFLAG_DAX, to indicate if DAX shall be enabled for
> this file or not when filesystem is mounted in per inode DAX mode.
> 
> To keep compatible with this feature in ext4/xfs, virtiofs also supports
> enabling DAX depending on the persistent inode flag, which may be
> set/cleared by users inside guest or admin on host.
> 
> This policy is used when '-o dax=inode' option is specified for
> virtiofsd.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
>  tools/virtiofsd/passthrough_ll.c | 33 ++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 999c906da2..dac5063594 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -1026,6 +1026,35 @@ static int do_statx(struct lo_data *lo, int dirfd, const char *pathname,
>      return 0;
>  }
>  
> +static bool lo_should_enable_dax(struct lo_data *lo, struct lo_inode *inode,
> +                                 struct fuse_entry_param *e)
> +{
> +    if (lo->dax == INODE_DAX_NONE || !S_ISREG(e->attr.st_mode)) {
> +        return false;
> +    }
> +
> +    if (lo->dax == INODE_DAX_INODE) {
> +        int res, fd;
> +        int ret = false;
> +        unsigned int attr;
> +
> +        fd = lo_inode_open(lo, inode, O_RDONLY);
> +        if (fd == -1) {
> +            return false;
> +        }
> +
> +        res = ioctl(fd, FS_IOC_GETFLAGS, &attr);
> +        if (!res && (attr & FS_DAX_FL)) {
> +            ret = true;
> +        }
> +
> +        close(fd);
> +        return ret;
> +    }
> +
> +    return false;
> +}
> +
>  /*
>   * Increments nlookup on the inode on success. unref_inode_lolocked() must be
>   * called eventually to decrement nlookup again. If inodep is non-NULL, the
> @@ -1116,6 +1145,10 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
>      }
>      e->ino = inode->fuse_ino;
>  
> +    if (lo_should_enable_dax(lo, inode, e)) {
> +        e->attr_flags |= FUSE_ATTR_DAX;
> +    }
> +

If we were too strict then we should probably add a
lo_should_enable_dax() call in lo_getattr() as well?

I guess for now it is ok. Overhead of checking fs_xflag_dax seems
enough and not many might care about immediate chnage of dax
status in guest.

Vivek

>      /* Transfer ownership of inode pointer to caller or drop it */
>      if (inodep) {
>          *inodep = inode;
> -- 
> 2.27.0
> 


  parent reply	other threads:[~2021-12-09 22:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  5:56 [Virtio-fs] [PATCH v7 0/6] virtiofsd: support per inode DAX Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 1/6] virtiofsd: add .ioctl() support Jeffle Xu
2021-12-09 19:33   ` Vivek Goyal
2021-12-10  2:51     ` JeffleXu
2021-12-13 18:02       ` Vivek Goyal
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 2/6] virtiofsd: support per inode DAX in fuse protocol Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 3/6] virtiofsd: add 'dax=' option Jeffle Xu
2021-12-09 20:00   ` Vivek Goyal
2021-12-10  3:02     ` JeffleXu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 4/6] virtiofsd: negotiate per inode DAX in FUSE_INIT Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 5/6] virtiofsd: implement xflag based dax policy Jeffle Xu
2021-12-09 20:16   ` Vivek Goyal
2021-12-10  3:13     ` JeffleXu
2021-12-09 22:02   ` Vivek Goyal [this message]
2021-12-10  3:16     ` JeffleXu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 6/6] virtiofsd: implement file size " Jeffle Xu
2021-12-09 21:59   ` Vivek Goyal
2021-12-10  3:21     ` JeffleXu
2021-12-07 14:42 ` [Virtio-fs] [PATCH v7 0/6] virtiofsd: support per inode DAX Vivek Goyal
2021-12-08  1:38   ` JeffleXu
2021-12-08 20:05     ` Vivek Goyal
2021-12-09  1:41       ` JeffleXu
2021-12-10  2:54       ` JeffleXu
2021-12-13 18:03         ` Vivek Goyal
2021-12-14 10:17           ` Miklos Szeredi
2021-12-14 15:51             ` JeffleXu
2021-12-14 16:10               ` Miklos Szeredi
2021-12-15  1:08                 ` JeffleXu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YbJ83lJB5eoy/gyQ@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=miklos@szeredi.hu \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.