linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 1/2] vfs: add vfs_iocb_iter_[read|write] helper functions
Date: Tue, 19 Nov 2019 05:14:40 +0200	[thread overview]
Message-ID: <CAOQ4uxgZZ=noynAZWmiuJupdqsfPw1AkG3TJc+JBk6fAv7ofOA@mail.gmail.com> (raw)
In-Reply-To: <1574129643-14664-2-git-send-email-jiufei.xue@linux.alibaba.com>

On Tue, Nov 19, 2019 at 4:14 AM Jiufei Xue <jiufei.xue@linux.alibaba.com> wrote:
>
> This isn't cause any behavior changes and will be used by overlay
> async IO implementation.
>
> Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
> ---
>  fs/read_write.c    | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/fs.h | 16 +++++++++++++++
>  2 files changed, 74 insertions(+)
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 5bbf587..3dfbcec 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -984,6 +984,64 @@ ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,
>  }
>  EXPORT_SYMBOL(vfs_iter_write);
>
> +ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb,
> +                          struct iov_iter *iter)
> +{
> +       ssize_t ret = 0;
> +       ssize_t tot_len;
> +
> +       if (!file->f_op->read_iter)
> +               return -EINVAL;
> +       if (!(file->f_mode & FMODE_READ))
> +               return -EBADF;
> +       if (!(file->f_mode & FMODE_CAN_READ))
> +               return -EINVAL;
> +
> +       tot_len = iov_iter_count(iter);
> +       if (!tot_len)
> +               return 0;
> +
> +       ret = rw_verify_area(READ, file, &iocb->ki_pos, tot_len);
> +       if (ret < 0)
> +               return ret;
> +
> +       ret = call_read_iter(file, iocb, iter);
> +       if (ret >= 0)
> +               fsnotify_access(file);
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL(vfs_iocb_iter_read);
> +
> +ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,
> +                           struct iov_iter *iter)
> +{
> +       ssize_t ret = 0;
> +       ssize_t tot_len;
> +
> +       if (!file->f_op->write_iter)
> +               return -EINVAL;
> +       if (!(file->f_mode & FMODE_WRITE))
> +               return -EBADF;
> +       if (!(file->f_mode & FMODE_CAN_WRITE))
> +               return -EINVAL;
> +
> +       tot_len = iov_iter_count(iter);
> +       if (!tot_len)
> +               return 0;
> +
> +       ret = rw_verify_area(WRITE, file, &iocb->ki_pos, tot_len);
> +       if (ret < 0)
> +               return ret;
> +
> +       ret = call_write_iter(file, iocb, iter);
> +       if (ret >= 0)
> +               fsnotify_modify(file);
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL(vfs_iocb_iter_write);
> +

If it was up to me, I would pass down an optional iocb pointer
to the do_iter_XXX static helpers, instead of duplicating the code.
Others may find your approach cleaner, so let's see what other
people think.

Thanks,
Amir.

  reply	other threads:[~2019-11-19  3:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19  2:14 [PATCH 0/2] ovl: implement async IO routines Jiufei Xue
2019-11-19  2:14 ` [PATCH 1/2] vfs: add vfs_iocb_iter_[read|write] helper functions Jiufei Xue
2019-11-19  3:14   ` Amir Goldstein [this message]
2019-11-19  8:40     ` Jiufei Xue
2019-11-19  2:14 ` [PATCH 2/2] ovl: implement async IO routines Jiufei Xue
2019-11-19  4:22   ` Amir Goldstein
2019-11-19  8:37     ` Jiufei Xue
2019-11-19  9:38       ` Amir Goldstein
2019-11-19 11:22         ` Jiufei Xue
2019-11-19 12:50           ` Amir Goldstein
2019-11-20  9:45 [PATCH V2 0/2] " Jiufei Xue
2019-11-20  9:45 ` [PATCH 1/2] vfs: add vfs_iocb_iter_[read|write] helper functions Jiufei Xue

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='CAOQ4uxgZZ=noynAZWmiuJupdqsfPw1AkG3TJc+JBk6fAv7ofOA@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=jiufei.xue@linux.alibaba.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).