Re: [PATCH] 9p: Fix initialisation of netfs_inode for 9p

Dominique Martinet
2024-01-03T13:10:40Z

David Howells wrote on Tue, Jan 02, 2024 at 09:49:39PM +0000:
> This needs a fix that I would fold in. Somehow it gets through xfstests
> without it, but it seems problems can be caused with executables.

Looking at a file without that patch we seem to be reading just zeroes
off pre-existing files; I'm surprised xfstest doesn't have a write
something/umount/mount/check content is identical test...

(You're probably aware of this, but note for others this breaks with the
rest of the patch series even if the big 9p patch isn't applied -- this
is the main reason I'd rather just get the patch in this cycle, as the
new patches got more tests with the full series than with the 9p writes
patch dropped.)

> 9p: Fix initialisation of netfs_inode for 9p
>
> The 9p filesystem is calling netfs_inode_init() in v9fs_init_inode() -
> before the struct inode fields have been initialised from the obtained file
> stats (ie. after v9fs_stat2inode*() has been called), but netfslib wants to
> set a couple of its fields from i_size.

Would it make sense to just always update netfs's ctx->remote_i_size in
the various stat2inode calls instead?
We don't have any cache coherency so if a file changes beneath us
through an edit on the server (or through another client) hell will
break loose anyway, but stat would update the inode's i_size so it'll
likely be weird that the remote_i_size doesn't get updated.

> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Tested-by: Marc Dionne <marc.dionne@auristor.com>
> cc: Eric Van Hensbergen <ericvh@kernel.org>
> cc: Latchesar Ionkov <lucho@ionkov.net>
> cc: Dominique Martinet <asmadeus@codewreck.org>

With that being said, it seems to do the immediate job:
Acked-by: Dominique Martinet <asmadeus@codewreck.org>

--
Dominique Martinet | Asmadeus