From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/7] nonblocking aio: xfs
Date: Wed, 15 Feb 2017 10:11:38 -0600 [thread overview]
Message-ID: <be95fe38-ddbe-427e-df7f-7b54fe3b02a6@suse.de> (raw)
In-Reply-To: <9859c328-263a-e4eb-22f6-20cdda821654@suse.de>
On 02/15/2017 09:30 AM, Goldwyn Rodrigues wrote:
>
>
> On 02/14/2017 01:43 AM, Christoph Hellwig wrote:
>> 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?
>
> A mistake. It does not mean anything besides bullets.
>
>>
>>> -static inline void
>>> +static inline int
>>> xfs_rw_ilock(
>>
>> This function has been removed a while ago.
>
> And thanks for putting in xfs_ilock_nowait(). This can't be done in a
> cleaner way. I was very skeptical of adding yet another flag.
>
>>
>>>
>>> + 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.
>
> I assume this will be covered by xfs_bmapi_write().
>
>>
>>> + /* 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.
>
> So in xfs_bmapi_write (and referring to), I would need a new flag, say
> XFS_BMAPI_NOALLOC which would bail to error0, setting error=-EAGAIN if
> need_alloc or was_delay is set. This flag XFS_BMAPI_NOALLOC is set in
> xfs_iomap_write_direct(). I did not understand short writes. Where can I
> get a short write?
>
> If I understand correctly, we do add the flag.
Replying to myself to correct myself.
On reading a bit more, I figured that we perform
xfs_file_iomap_begin->xfs_iomap_write_direct. At this point we have
already performed xfs_bmapi_read(). So, a check in xfs_file_iomap_begin
should be good enough. So, the flag required would be with iomap flags,
say IOMAP_NONBLOCKING. IOW, we don't need to go all the way to
xfs_bmap_write() and return when imap.br_startblock == HOLESTARTBLOCK.
>
>>
>>> 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.
>>
>
--
Goldwyn
next prev parent reply other threads:[~2017-02-15 16:11 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
2017-02-15 15:30 ` Goldwyn Rodrigues
2017-02-15 16:11 ` Goldwyn Rodrigues [this message]
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=be95fe38-ddbe-427e-df7f-7b54fe3b02a6@suse.de \
--to=rgoldwyn@suse.de \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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).