All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Avati <avati@redhat.com>
To: Brian Foster <bfoster@redhat.com>
Cc: Maxim Patlasov <MPatlasov@parallels.com>,
	miklos@szeredi.hu, fuse-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, devel@openvz.org
Subject: Re: [PATCH] fuse: hold i_mutex in fuse_file_fallocate()
Date: Wed, 12 Jun 2013 11:56:23 -0700	[thread overview]
Message-ID: <51B8C457.5050502@redhat.com> (raw)
In-Reply-To: <51B85E26.8000303@redhat.com>

On 6/12/13 4:40 AM, Brian Foster wrote:
> On 06/11/2013 06:59 AM, Maxim Patlasov wrote:
>> Changing size of a file on server and local update (fuse_write_update_size)
>> should be always protected by inode->i_mutex. Otherwise a race like this is
>> possible:
>>
>> 1. Process 'A' calls fallocate(2) to extend file (~FALLOC_FL_KEEP_SIZE).
>> fuse_file_fallocate() sends FUSE_FALLOCATE request to the server.
>> 2. Process 'B' performs ordinary buffered write(2) with a length big enough
>> to extend the file beyond "offset + length" of fallocate call.
>> 3. Process 'A' resumes execution of fuse_file_fallocate() and calls
>> fuse_write_update_size(inode, offset + length). But 'offset + length' was
>> obsoleted by write from previous step.
>>
>
> Hi Maxim,
>
> Doesn't fuse_write_update_size() already handle this particular case by
> only ever extending the size?
>


As you say, fuse_write_update_size() does seem to protect against the 
case Maxim writes in the commit log.

However, there is still an issue with with truncate(shrinking_offset) 
and fallocate(growing_offset,~FALLOC_FL_KEEP_SIZE) racing, and changing 
inode size in opposing order between file server and in core ->i_size. 
Therefore, grabbing i_mutex is making fallocate and truncate atomic 
against each other.

I guess we just need an updated commit log, and same code change?

Avati



  reply	other threads:[~2013-06-12 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-11 10:59 [PATCH] fuse: hold i_mutex in fuse_file_fallocate() Maxim Patlasov
2013-06-12 11:40 ` Brian Foster
2013-06-12 18:56   ` Anand Avati [this message]
2013-06-12 19:04 ` Anand Avati
2013-06-13  7:15   ` 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=51B8C457.5050502@redhat.com \
    --to=avati@redhat.com \
    --cc=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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.