mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
9p: Fix v9fs_issue_write() to update i_size and remote_i_size
Fix v9fs_issue_write() to update i_size and remote_i_size to the new size
of the server file if we made it larger, using the start fpos and the count
returned by p9_client_write() to calculate the new minimum file size.
This assumes that if the 9P server makes a short write (say it hits
ENOSPC), a reduced count is returned.
Fixes: 5fb70e7275 ("netfs, 9p: Implement helpers for new write code")
Reported-by: Michael Mulqueen <mike@method-b.uk>
Closes: https://lore.kernel.org/r/fbb9e395-1e07-4212-8f70-23f3cd498074@method-b.uk/
Cc: stable@vger.kernel.org
Signed-off-by: David Howells <dhowells@redhat.com>
Message-ID: <2226525.1789118704@warthog.procyon.org.uk>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
This commit is contained in:
committed by
Dominique Martinet
parent
df2908090c
commit
c60ae98c5a
+27
-1
@@ -54,11 +54,37 @@ static void v9fs_begin_writeback(struct netfs_io_request *wreq)
|
||||
static void v9fs_issue_write(struct netfs_io_subrequest *subreq)
|
||||
{
|
||||
struct p9_fid *fid = subreq->rreq->netfs_priv;
|
||||
struct inode *inode = subreq->rreq->inode;
|
||||
struct netfs_inode *ictx = netfs_inode(inode);
|
||||
int err, len;
|
||||
|
||||
len = p9_client_write(fid, subreq->start, &subreq->io_iter, &err);
|
||||
if (len > 0)
|
||||
if (len > 0) {
|
||||
uoff_t end = subreq->start + len, i_size, remote, zp;
|
||||
bool set = false;
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
|
||||
/* We can read the sizes directly as we hold i_lock. */
|
||||
i_size = inode->i_size;
|
||||
remote = ictx->_remote_i_size;
|
||||
zp = ictx->_zero_point;
|
||||
|
||||
if (end > i_size) {
|
||||
i_size = end;
|
||||
set = true;
|
||||
}
|
||||
if (end > remote) {
|
||||
remote = end;
|
||||
set = true;
|
||||
}
|
||||
|
||||
if (set)
|
||||
netfs_write_sizes(inode, i_size, remote, zp);
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
__set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags);
|
||||
}
|
||||
netfs_write_subrequest_terminated(subreq, len ?: err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user