]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
afs: afs_write_end() should change i_size under the right lock
authorDavid Howells <dhowells@redhat.com>
Fri, 12 Jun 2020 22:58:51 +0000 (23:58 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 15 Jun 2020 14:41:02 +0000 (15:41 +0100)
Fix afs_write_end() to change i_size under vnode->cb_lock rather than
->wb_lock so that it doesn't race with afs_vnode_commit_status() and
afs_getattr().

The ->wb_lock is only meant to guard access to ->wb_keys which isn't
accessed by that piece of code.

Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/write.c

index 9270bb01be67fefb51623702e83389bfe4a2bb06..a55cb73e044916844dcf85dd37a2412e5143487f 100644 (file)
@@ -194,11 +194,11 @@ int afs_write_end(struct file *file, struct address_space *mapping,
 
        i_size = i_size_read(&vnode->vfs_inode);
        if (maybe_i_size > i_size) {
-               spin_lock(&vnode->wb_lock);
+               write_seqlock(&vnode->cb_lock);
                i_size = i_size_read(&vnode->vfs_inode);
                if (maybe_i_size > i_size)
                        i_size_write(&vnode->vfs_inode, maybe_i_size);
-               spin_unlock(&vnode->wb_lock);
+               write_sequnlock(&vnode->cb_lock);
        }
 
        if (!PageUptodate(page)) {