NFS: Fix an Oops when truncating a file
Subsystems (2)
PATCH 1/3 NFS: Fix an Oops when truncating a file
The VM/VFS does not allow mapping->a_ops->invalidatepage() to fail. Unfortunately, nfs_wb_page_cancel() may fail if a fatal signal occurs. Since the NFS code assumes that the page stays mapped for as long as the writeback is active, we can end up Oopsing (among other things).
The only safe fix here is to convert nfs_wait_on_request(), so as to make it uninterruptible (as is already the case with wait_on_page_writeback()).
--- fs/nfs/pagelist.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
fs/nfs/pagelist.c +9 -8
@@ -176,6 +176,12 @@ void nfs_release_request(struct nfs_page *req)kref_put (&req->wb_kref, nfs_free_request); } +static int nfs_wait_bit_uninterruptible (void *word) +{ +io_schedule (); +return 0 ; +} +/** * nfs_wait_on_request - Wait for a request to complete. * @req: request to wait upon.
@@ -186,14 +192,9 @@ void nfs_release_request(struct nfs_page *req)int nfs_wait_on_request (struct nfs_page *req) { -int ret =0 ; - -if (!test_bit (PG_BUSY , &req->wb_flags)) - goto out; - ret =out_of_line_wait_on_bit (&req->wb_flags,PG_BUSY , - nfs_wait_bit_killable,TASK_KILLABLE ); -out: -return ret; +return wait_on_bit (&req->wb_flags,PG_BUSY , + nfs_wait_bit_uninterruptible, +TASK_UNINTERRUPTIBLE ); }/**
Signature · 1 line
1.6.6
PATCH 2/3 NFS: Fix a umount race
Ensure that we unregister the bdi before kill_anon_super() calls ida_remove() on our device name.
--- fs/nfs/super.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-)
fs/nfs/super.c +14 -1
@@ -243,6 +243,7 @@ static int nfs_show_stats(struct seq_file *, struct vfsmount *);static int nfs_get_sb (struct file_system_type *,int ,const char *,void *,struct vfsmount *);static int nfs_xdev_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt); +static void nfs_put_super (struct super_block *);static void nfs_kill_super (struct super_block *);static int nfs_remount (struct super_block *sb,int *flags,char *raw_data);
@@ -266,6 +267,7 @@ static const struct super_operations nfs_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, .write_inode = nfs_write_inode, + .put_super = nfs_put_super, .statfs = nfs_statfs, .clear_inode = nfs_clear_inode, .umount_begin = nfs_umount_begin,
@@ -335,6 +337,7 @@ static const struct super_operations nfs4_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode, .write_inode = nfs_write_inode, + .put_super = nfs_put_super, .statfs = nfs_statfs, .clear_inode = nfs4_clear_inode, .umount_begin = nfs_umount_begin,
@@ -2258,6 +2261,17 @@ error_splat_super: }/* +* Ensure that we unregister the bdi before kill_anon_super +* releases the device name +*/ +static void nfs_put_super (struct super_block *s) +{ +struct nfs_server *server =NFS_SB (s); + +bdi_unregister (&server->backing_dev_info); +} + +/* * Destroy an NFS2/3 superblock */ static void nfs_kill_super (struct super_block *s)
@@ -2265,7 +2279,6 @@ static void nfs_kill_super(struct super_block *s)struct nfs_server *server =NFS_SB (s);kill_anon_super (s); -bdi_unregister (&server->backing_dev_info);nfs_fscache_release_super_cookie (s);nfs_free_server (server); }
Signature · 1 line
1.6.6
PATCH 3/3 NFS: Don't clobber the attribute type in nfs_update_inode()
If the NFS_ATTR_FATTR_TYPE field isn't set in fattr->valid, then we should not set the S_IFMT part of inode->i_mode.
--- fs/nfs/inode.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
fs/nfs/inode.c +3 -1
@@ -1261,8 +1261,10 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)if (fattr->valid &NFS_ATTR_FATTR_MODE ) {if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO )) { +umode_t newmode = inode->i_mode &S_IFMT ; + newmode |= fattr->mode &S_IALLUGO ; + inode->i_mode = newmode; invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; - inode->i_mode = fattr->mode; } }else if (server->caps &NFS_CAP_MODE ) invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
Signature · 1 line
1.6.6