remove inode_setattr

Replace inode_setattr with opencoded variants of it in all callers.  This
moves the remaining call to vmtruncate into the filesystem methods where it
can be replaced with the proper truncate sequence.

In a few cases it was obvious that we would never end up calling vmtruncate
so it was left out in the opencoded variant:

 spufs: explicitly checks for ATTR_SIZE earlier
 btrfs,hugetlbfs,logfs,dlmfs: explicitly clears ATTR_SIZE earlier
 ufs: contains an opencoded simple_seattr + truncate that sets the filesize just above

In addition to that ncpfs called inode_setattr with handcrafted iattrs,
which allowed to trim down the opencoded variant.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Christoph Hellwig 2010-06-04 11:30:02 +02:00 committed by Al Viro
parent eef2380c18
commit 1025774ce4
35 changed files with 416 additions and 194 deletions

View file

@ -3134,55 +3134,62 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
}
error = inode_change_ok(inode, attr);
if (!error) {
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
error = reiserfs_chown_xattrs(inode, attr);
if (error)
goto out;
if (!error) {
struct reiserfs_transaction_handle th;
int jbegin_count =
2 *
(REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb) +
REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)) +
2;
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
struct reiserfs_transaction_handle th;
int jbegin_count =
2 *
(REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb) +
REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)) +
2;
/* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
error =
journal_begin(&th, inode->i_sb,
jbegin_count);
if (error)
goto out;
error = dquot_transfer(inode, attr);
if (error) {
journal_end(&th, inode->i_sb,
jbegin_count);
goto out;
}
/* Update corresponding info in inode so that everything is in
* one transaction */
if (attr->ia_valid & ATTR_UID)
inode->i_uid = attr->ia_uid;
if (attr->ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
mark_inode_dirty(inode);
error =
journal_end(&th, inode->i_sb, jbegin_count);
}
}
if (!error) {
/*
* Relax the lock here, as it might truncate the
* inode pages and wait for inode pages locks.
* To release such page lock, the owner needs the
* reiserfs lock
*/
reiserfs_write_unlock_once(inode->i_sb, depth);
error = inode_setattr(inode, attr);
depth = reiserfs_write_lock_once(inode->i_sb);
error = reiserfs_chown_xattrs(inode, attr);
if (error)
return error;
/* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
error = journal_begin(&th, inode->i_sb, jbegin_count);
if (error)
goto out;
error = dquot_transfer(inode, attr);
if (error) {
journal_end(&th, inode->i_sb, jbegin_count);
goto out;
}
/* Update corresponding info in inode so that everything is in
* one transaction */
if (attr->ia_valid & ATTR_UID)
inode->i_uid = attr->ia_uid;
if (attr->ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
mark_inode_dirty(inode);
error = journal_end(&th, inode->i_sb, jbegin_count);
if (error)
goto out;
}
/*
* Relax the lock here, as it might truncate the
* inode pages and wait for inode pages locks.
* To release such page lock, the owner needs the
* reiserfs lock
*/
reiserfs_write_unlock_once(inode->i_sb, depth);
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode))
error = vmtruncate(inode, attr->ia_size);
if (!error) {
setattr_copy(inode, attr);
mark_inode_dirty(inode);
}
depth = reiserfs_write_lock_once(inode->i_sb);
if (!error && reiserfs_posixacl(inode->i_sb)) {
if (attr->ia_valid & ATTR_MODE)
error = reiserfs_acl_chmod(inode);