From: Andreas Gruenbacher <agruenba@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: cluster-devel <cluster-devel@redhat.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v9 4/5] gfs2: iomap direct I/O support
Date: Wed, 20 Jun 2018 18:00:40 +0200 [thread overview]
Message-ID: <CAHc6FU73dWRbg9OfEWqT-5zsC-sgOv59K57QDtoJafMiXe7xXg@mail.gmail.com> (raw)
In-Reply-To: <20180619064234.GD24513@lst.de>
On 19 June 2018 at 08:42, Christoph Hellwig <hch@lst.de> wrote:
>> } else if (flags & IOMAP_WRITE) {
>> u64 size;
>> +
>> + if (flags & IOMAP_DIRECT)
>> + goto out;
>> +
>
> Maybe add a comment here on why you don't allow block allocations for
> direct I/O.
>
>> + if (flags & IOMAP_DIRECT) {
>> + ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
>> + release_metapath(&mp);
>> + if (iomap->type != IOMAP_MAPPED)
>> + ret = -ENOTBLK;
>> + } else {
>> + ret = gfs2_iomap_begin_write(inode, pos, length, flags, iomap);
>> + }
>
> A couple too long lines.
>
>> } else {
>> ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
>> release_metapath(&mp);
>
> But shouldn't the direct I/O code try to reuse this part anyway?
>
> E.g. something like:
>
> if ((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE)) {
> ret = gfs2_iomap_begin_write(inode, pos, length, flags, iomap);
> } else {
> ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
> release_metapath(&mp);
> if ((flags & IOMAP_WRITE) && iomap->type != IOMAP_MAPPED)
> ret = -ENOTBLK;
>
>> + /* fall back to buffered I/O for stuffed files */
>> + ret = -ENOTBLK;
>> + if (gfs2_is_stuffed(ip))
>> + goto out;
>
> I think we can handle stuffed files in the direct I/O code trivially
> by copying out the inline data in the iomap. It would be great to
> just handle this instead of adding fallbacks.
On gfs2, direct I/O uses a "deferred lock", which is a special kind of
shared lock. We can probably do inline reads under it, but not inline
writes, so falling back to buffered I/O seems inevitable in that case
at least.
>> + /* Silently fall back to buffered I/O for stuffed files */
>> + if (gfs2_is_stuffed(ip))
>> + goto out;
>
> Same here.
>
>> +static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
>> +{
>> + ssize_t ret;
>> +
>> + if (iocb->ki_flags & IOCB_DIRECT) {
>> + ret = gfs2_file_direct_read(iocb, to);
>> + if (likely(ret != -ENOTBLK))
>> + goto out;
>
> return ret;
>
>> + iocb->ki_flags &= ~IOCB_DIRECT;
>> + }
>> + ret = generic_file_read_iter(iocb, to);
>> +out:
>> + return ret;
>
> return generic_file_read_iter(iocb, to);
Andreas
next prev parent reply other threads:[~2018-06-20 16:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 12:19 [PATCH v9 0/5] gfs2 iomap write support Andreas Gruenbacher
2018-06-15 12:19 ` [PATCH v9 1/5] iomap: add private pointer to struct iomap Andreas Gruenbacher
2018-06-18 15:25 ` Andreas Gruenbacher
2018-06-19 6:29 ` Christoph Hellwig
2018-06-15 12:19 ` [PATCH v9 2/5] gfs2: iomap buffered write support Andreas Gruenbacher
2018-06-19 6:36 ` Christoph Hellwig
2018-06-15 12:19 ` [PATCH v9 3/5] gfs2: gfs2_extent_length cleanup Andreas Gruenbacher
2018-06-15 12:19 ` [PATCH v9 4/5] gfs2: iomap direct I/O support Andreas Gruenbacher
2018-06-19 6:42 ` Christoph Hellwig
2018-06-20 16:00 ` Andreas Gruenbacher [this message]
2018-06-15 12:19 ` [PATCH v9 5/5] gfs2: Remove gfs2_write_{begin,end} Andreas Gruenbacher
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=CAHc6FU73dWRbg9OfEWqT-5zsC-sgOv59K57QDtoJafMiXe7xXg@mail.gmail.com \
--to=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
/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).