linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>, jens.axboe@oracle.com
Subject: Direct aio_write/truncate question
Date: Sat, 24 Apr 2010 15:29:36 +0400	[thread overview]
Message-ID: <87633hdr6n.fsf@openvz.org> (raw)

My be my question appeared to obvious for someone, but still

fd = open("a", O_DIRECT, )
fd2 = open("b", O_DIRECT, )
write(fd, buf ,size) /* allocate blocks for a file */
fsync(fd) /* Now, it is guaranteed that blocks are allocated.*/
/* Submit async rewrite request */ 
io_prep_pwrite(io, fd, io->u.c.buf, size, 0);
io_submit(myctx, 1, io); /* Io is in flight after this */
/* Ok, truncate the file */
ftruncate(fd, 0)
/* Reuse truncated block blocks for a new file */
write(fd2,buf ,size)     /* old a's blocks belongs to b now. */

What protect us from aio request to rewrite content of new file?
Or even corrupt fs because old blocks may be used as metadata now.
Seems unmap_underlying_metadata() can not help us here because async
io context does not dirty or locked any bh because they was already
allocated. Fairly to say. I can not reproduce rewrite effect.
I use ext4 with external journal, so where a io_barriers in fs_dev's
blktrace log.
Seems what rewrite effect no happens only because blklayer does not
reorganized issued requests. But nothing is preventing this right?

             reply	other threads:[~2010-04-24 11:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-24 11:29 Dmitry Monakhov [this message]
2010-04-26 23:55 ` Direct aio_write/truncate question Dave Chinner

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=87633hdr6n.fsf@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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).