From: Maxim Patlasov <mpatlasov@parallels.com>
To: Brian Foster <bfoster@redhat.com>
Cc: <miklos@szeredi.hu>, <fuse-devel@lists.sourceforge.net>,
<linux-kernel@vger.kernel.org>, <devel@openvz.org>,
<xemul@parallels.com>
Subject: Re: [PATCH 2/2] fuse: wait for writeback in fuse_file_fallocate()
Date: Tue, 13 Aug 2013 17:45:47 +0400 [thread overview]
Message-ID: <520A388B.7030001@parallels.com> (raw)
In-Reply-To: <520A3352.5070709@redhat.com>
08/13/2013 05:23 PM, Brian Foster пишет:
> On 08/13/2013 08:56 AM, Maxim Patlasov wrote:
>> Hi,
>>
>> 08/13/2013 04:05 PM, Brian Foster пишет:
>>> ...
>>> @@ -2478,8 +2516,11 @@ static long fuse_file_fallocate(struct file
>>> *file, int mode, loff_t offset,
>>> if (lock_inode) {
>>> mutex_lock(&inode->i_mutex);
>>> - if (mode & FALLOC_FL_PUNCH_HOLE)
>>> - fuse_set_nowrite(inode);
>>> + if (mode & FALLOC_FL_PUNCH_HOLE) {
>>> + truncate_pagecache_range(inode, offset,
>>> + offset + length - 1);
>>> + fuse_wait_on_writeback(inode, offset, length);
>>> + }
>>> If this happens to be the first attempt on an fs that doesn't support
>>> fallocate, we'll return -EOPNOTSUPP after having already punched out the
>>> data in the pagecache.
>> Yes, this is unpleasant, but it's not critical, imo. We're returning an
>> error code (even though equal to -EOPNOTSUPP) and a sane application
>> should not make any assumption about current state of the punched
>> region. Also, the application intended to discard given region of the
>> file, so why should it pay care for its content afterwards?
>>
> I agree, though most users probably wouldn't expect that a blatant error
> like EOPNOTSUPP leave the range in a weird state. What's more, it only
> does so if it's the first attempt and behaves more appropriately after
> that.
>
>>> What about replacing the nowrite logic with a
>>> flush (and still followed by your new writeback wait logic) rather than
>>> moving the pagecache truncate?
>> The "flush" you mentioned should firstly flush page cache.
>> invalidate_inode_pages2_range() seems to be a candidate. We definitely
>> cannot ignore error code from it because it can be fuse_launder_page()
>> who got -ENOMEM from fuse_writepage_locked(). In case of err == -ENOMEM,
>> we could safely fail fallocate, but what should we do if it's -EBUSY?
>> Any ideas?
>>
> I was referring to something like filemap_write_and_wait_range(), for
> example. Then continue to use truncate_pagecache_range() as we do today.
> Thoughts
Looks nice. I'll send updated patch after some testing. Thanks a lot for
the suggestion!
Maxim
next prev parent reply other threads:[~2013-08-13 13:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 16:39 [PATCH 0/2] fuse: fix races related to fuse writeback Maxim Patlasov
2013-08-12 16:39 ` [PATCH 1/2] fuse: postpone end_page_writeback() in fuse_writepage_locked() Maxim Patlasov
2013-08-29 16:27 ` Miklos Szeredi
2013-08-12 16:39 ` [PATCH 2/2] fuse: wait for writeback in fuse_file_fallocate() Maxim Patlasov
2013-08-13 12:05 ` Brian Foster
2013-08-13 12:56 ` Maxim Patlasov
2013-08-13 13:23 ` Brian Foster
2013-08-13 13:45 ` Maxim Patlasov [this message]
2013-08-16 11:30 ` [PATCH 2/2] fuse: wait for writeback in fuse_file_fallocate() -v2 Maxim Patlasov
2013-08-23 13:02 ` Brian Foster
2013-08-29 15:41 ` Miklos Szeredi
2013-08-29 16:27 ` Maxim Patlasov
2013-08-29 16:37 ` Miklos Szeredi
2013-08-29 16:41 ` Miklos Szeredi
2013-08-30 9:13 ` Miklos Szeredi
2013-08-30 11:33 ` Maxim Patlasov
2013-09-11 10:12 ` Miklos Szeredi
2013-09-11 12:21 ` Maxim Patlasov
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=520A388B.7030001@parallels.com \
--to=mpatlasov@parallels.com \
--cc=bfoster@redhat.com \
--cc=devel@openvz.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=xemul@parallels.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox