[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <7351A815-AA56-45FC-B15F-38F81F140253@lca.pw>
Date: Thu, 20 Feb 2020 23:19:39 -0500
From: Qian Cai <cai@....pw>
To: Marco Elver <elver@...gle.com>
Cc: Al Viro <viro@...iv.linux.org.uk>,
Christoph Hellwig <hch@...radead.org>,
"Darrick J. Wong" <darrick.wong@...cle.com>,
linux-xfs@...r.kernel.org,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] fs: fix a data race in i_size_write/i_size_read
> On Feb 19, 2020, at 4:21 AM, Marco Elver <elver@...gle.com> wrote:
>
> Let's assume the WRITE_ONCE can be dropped.
>
> The load is a different story. While load tearing may not be an issue,
> it's more likely that other optimizations can break the code. For
> example load fusing can break code that expects repeated loads in a
> loop. E.g. I found these uses of i_size_read in loops:
>
> git grep -E '(for|while) \(.*i_size_read'
> fs/ocfs2/dir.c: while (ctx->pos < i_size_read(inode)) {
> fs/ocfs2/dir.c: for (i = 0; i < i_size_read(inode) &&
> i < offset; ) {
> fs/ocfs2/dir.c: while (ctx->pos < i_size_read(inode)) {
> fs/ocfs2/dir.c: while (ctx->pos < i_size_read(inode)
> fs/squashfs/dir.c: while (length < i_size_read(inode)) {
> fs/squashfs/namei.c: while (length < i_size_read(dir)) {
>
> Can i_size writes happen concurrently, and if so will these break if
> the compiler decides to just do i_size_read's load once, and keep the
> result in a register?
Al, is it more acceptable to add READ_ONCE() only then?
Powered by blists - more mailing lists