diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-07-18 17:51:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:48:48 -0400 |
commit | 1b9474635e21eef0f3e69fd1c7b1b9598ffdddd3 (patch) | |
tree | 89c63dc57f7c197a8f48633c5e05d9c1f3b87679 /fs/cifs | |
parent | e566d48c9bd56f57e25e855a21e06ca2c2525795 (diff) |
cifs: truncate fallout
Remove the calls to inode_newsize_ok given that we already did it as
part of inode_change_ok in the beginning of cifs_setattr_(no)unix.
No need to call ->truncate if cifs doesn't have one, so remove the
explicit call in cifs_vmtruncate, and replace the calls to vmtruncate
with truncate_setsize which is vmtruncate minus inode_newsize_ok
and the call to ->truncate.
Rename cifs_vmtruncate to cifs_setsize to match the new calling conventions.
Question 1: why does cifs do the pagecache munging and i_size update twice
for each setattr call, once opencoded in cifs_vmtruncate, and once
using the VFS helpers?
Question 2: what is supposed to be protected by i_lock in cifs_vmtruncate?
Do we need it around the call to inode_change_ok?
[AV: fixed build breakage]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/inode.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index b95f4a5af013..ddbe8a84c51d 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1679,26 +1679,16 @@ static int cifs_truncate_page(struct address_space *mapping, loff_t from) | |||
1679 | return rc; | 1679 | return rc; |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | static int cifs_vmtruncate(struct inode *inode, loff_t offset) | 1682 | static void cifs_setsize(struct inode *inode, loff_t offset) |
1683 | { | 1683 | { |
1684 | loff_t oldsize; | 1684 | loff_t oldsize; |
1685 | int err; | ||
1686 | 1685 | ||
1687 | spin_lock(&inode->i_lock); | 1686 | spin_lock(&inode->i_lock); |
1688 | err = inode_newsize_ok(inode, offset); | ||
1689 | if (err) { | ||
1690 | spin_unlock(&inode->i_lock); | ||
1691 | goto out; | ||
1692 | } | ||
1693 | |||
1694 | oldsize = inode->i_size; | 1687 | oldsize = inode->i_size; |
1695 | i_size_write(inode, offset); | 1688 | i_size_write(inode, offset); |
1696 | spin_unlock(&inode->i_lock); | 1689 | spin_unlock(&inode->i_lock); |
1690 | |||
1697 | truncate_pagecache(inode, oldsize, offset); | 1691 | truncate_pagecache(inode, oldsize, offset); |
1698 | if (inode->i_op->truncate) | ||
1699 | inode->i_op->truncate(inode); | ||
1700 | out: | ||
1701 | return err; | ||
1702 | } | 1692 | } |
1703 | 1693 | ||
1704 | static int | 1694 | static int |
@@ -1771,7 +1761,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, | |||
1771 | 1761 | ||
1772 | if (rc == 0) { | 1762 | if (rc == 0) { |
1773 | cifsInode->server_eof = attrs->ia_size; | 1763 | cifsInode->server_eof = attrs->ia_size; |
1774 | rc = cifs_vmtruncate(inode, attrs->ia_size); | 1764 | cifs_setsize(inode, attrs->ia_size); |
1775 | cifs_truncate_page(inode->i_mapping, inode->i_size); | 1765 | cifs_truncate_page(inode->i_mapping, inode->i_size); |
1776 | } | 1766 | } |
1777 | 1767 | ||
@@ -1891,11 +1881,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) | |||
1891 | goto out; | 1881 | goto out; |
1892 | 1882 | ||
1893 | if ((attrs->ia_valid & ATTR_SIZE) && | 1883 | if ((attrs->ia_valid & ATTR_SIZE) && |
1894 | attrs->ia_size != i_size_read(inode)) { | 1884 | attrs->ia_size != i_size_read(inode)) |
1895 | rc = vmtruncate(inode, attrs->ia_size); | 1885 | truncate_setsize(inode, attrs->ia_size); |
1896 | if (rc) | ||
1897 | goto out; | ||
1898 | } | ||
1899 | 1886 | ||
1900 | setattr_copy(inode, attrs); | 1887 | setattr_copy(inode, attrs); |
1901 | mark_inode_dirty(inode); | 1888 | mark_inode_dirty(inode); |
@@ -2050,11 +2037,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) | |||
2050 | goto cifs_setattr_exit; | 2037 | goto cifs_setattr_exit; |
2051 | 2038 | ||
2052 | if ((attrs->ia_valid & ATTR_SIZE) && | 2039 | if ((attrs->ia_valid & ATTR_SIZE) && |
2053 | attrs->ia_size != i_size_read(inode)) { | 2040 | attrs->ia_size != i_size_read(inode)) |
2054 | rc = vmtruncate(inode, attrs->ia_size); | 2041 | truncate_setsize(inode, attrs->ia_size); |
2055 | if (rc) | ||
2056 | goto cifs_setattr_exit; | ||
2057 | } | ||
2058 | 2042 | ||
2059 | setattr_copy(inode, attrs); | 2043 | setattr_copy(inode, attrs); |
2060 | mark_inode_dirty(inode); | 2044 | mark_inode_dirty(inode); |