[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87633hdr6n.fsf@openvz.org>
Date: Sat, 24 Apr 2010 15:29:36 +0400
From: Dmitry Monakhov <dmonakhov@...nvz.org>
To: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
CC: Andrew Morton <akpm@...ux-foundation.org>, jens.axboe@...cle.com
Subject: Direct aio_write/truncate question
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?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists