lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100426235503.GA9703@dastard>
Date:	Tue, 27 Apr 2010 09:55:03 +1000
From:	Dave Chinner <david@...morbit.com>
To:	Dmitry Monakhov <dmonakhov@...nvz.org>
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	jens.axboe@...cle.com
Subject: Re: Direct aio_write/truncate question

On Sat, Apr 24, 2010 at 03:29:36PM +0400, Dmitry Monakhov wrote:
> 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?

The filesystem is supposed to serialise truncate vs write races.
i.e. the truncate will occur either before the write is executed or
after it has completed, not while it is running.

Cheers,

Dave.
-- 
Dave Chinner
david@...morbit.com
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ