Skip to content

Commit

Permalink
[CIFS] cifs truncate missing a fix for private map COW race
Browse files Browse the repository at this point in the history
vmtruncate had added the same fix to handle the case of private pages
being Copy on writed while truncate_inode_pages is going on

Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Steve French committed Aug 22, 2007
1 parent cb00e99 commit 8064ab4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,17 @@ static int cifs_vmtruncate(struct inode *inode, loff_t offset)
}
i_size_write(inode, offset);
spin_unlock(&inode->i_lock);
/*
* unmap_mapping_range is called twice, first simply for efficiency
* so that truncate_inode_pages does fewer single-page unmaps. However
* after this first call, and before truncate_inode_pages finishes,
* it is possible for private pages to be COWed, which remain after
* truncate_inode_pages finishes, hence the second unmap_mapping_range
* call must be made for correctness.
*/
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
truncate_inode_pages(mapping, offset);
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
goto out_truncate;

do_expand:
Expand Down

0 comments on commit 8064ab4

Please sign in to comment.