From: Christoph Hellwig <hch@infradead.org>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz,
Goldwyn Rodrigues <rgoldwyn@suse.com>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] nonblocking aio: xfs
Date: Mon, 13 Feb 2017 23:43:26 -0800 [thread overview]
Message-ID: <20170214074326.GA20629@infradead.org> (raw)
In-Reply-To: <20170214024603.9563-7-rgoldwyn@suse.de>
On Mon, Feb 13, 2017 at 08:46:02PM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Please Cc the while series to all lists, otherwiwe it's impossible
to review the thing.
>
> If IOCB_NONBLOCKING is set:
> + Check if writing beyond end of file, if yes return EAGAIN
> - check if writing to a hole which does not have allocated
> file blocks.
> - Check if i_rwsem is immediately lockable in xfs_rw_ilock()
Why the + vs - above?
> -static inline void
> +static inline int
> xfs_rw_ilock(
This function has been removed a while ago.
>
> + if (iocb->ki_flags & IOCB_NONBLOCKING) {
> + struct xfs_bmbt_irec imap;
> + xfs_fileoff_t offset_fsb, end_fsb;
> + int nimaps = 1, ret = 0;
> + end_fsb = XFS_B_TO_FSB(ip->i_mount, iocb->ki_pos + count);
> + if (XFS_B_TO_FSB(ip->i_mount, i_size_read(inode)) < end_fsb)
> + return -EAGAIN;
Bogus check, XFS supports async write beyond EOF if the space is
preallocated.
> + /* Check if it is an unallocated hole */
> + offset_fsb = XFS_B_TO_FSBT(ip->i_mount, iocb->ki_pos);
> +
> + ret = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
> + &nimaps, 0);
> + if (ret)
> + return ret;
> + if (!nimaps || imap.br_startblock == HOLESTARTBLOCK)
> + return -EAGAIN;
This would need the ilock. But extent list lookups are expensive,
so please don't add another one here. Just return when we hit the
first unallocated extent in xfs_bmapi_write - either a short write or
-EAGAIN if nothing has been written.
> error = xfs_break_layouts(inode, iolock, true);
> if (error)
> return error;
Additionally this can drop the iolock, so you might get a new
hole after it.
next prev parent reply other threads:[~2017-02-14 7:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170214024603.9563-1-rgoldwyn@suse.de>
2017-02-14 2:46 ` [PATCH 6/7] nonblocking aio: xfs Goldwyn Rodrigues
2017-02-14 6:44 ` Darrick J. Wong
2017-02-14 7:43 ` Christoph Hellwig [this message]
2017-02-15 15:30 ` Goldwyn Rodrigues
2017-02-15 16:11 ` Goldwyn Rodrigues
2017-02-16 20:21 ` Christoph Hellwig
2017-02-16 20:44 ` Goldwyn Rodrigues
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=20170214074326.GA20629@infradead.org \
--to=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=rgoldwyn@suse.com \
--cc=rgoldwyn@suse.de \
/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).