int f2fs_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; struct f2fs_inode_info *fi = F2FS_I(inode); int err; err = inode_change_ok(inode, attr); if (err) return err; if (attr->ia_valid & ATTR_SIZE) { if (f2fs_encrypted_inode(inode) && f2fs_get_encryption_info(inode)) return -EACCES; if (attr->ia_size <= i_size_read(inode)) { truncate_setsize(inode, attr->ia_size); err = f2fs_truncate(inode, true); if (err) return err; f2fs_balance_fs(F2FS_I_SB(inode)); } else { /* * do not trim all blocks after i_size if target size is * larger than i_size. */ truncate_setsize(inode, attr->ia_size); inode->i_mtime = inode->i_ctime = CURRENT_TIME; } } __setattr_copy(inode, attr); if (attr->ia_valid & ATTR_MODE) { err = f2fs_acl_chmod(inode); if (err || is_inode_flag_set(fi, FI_ACL_MODE)) { inode->i_mode = fi->i_acl_mode; clear_inode_flag(fi, FI_ACL_MODE); } } mark_inode_dirty(inode); return err; }
int f2fs_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; struct f2fs_inode_info *fi = F2FS_I(inode); int err; err = inode_change_ok(inode, attr); if (err) return err; if (attr->ia_valid & ATTR_SIZE) { if (f2fs_encrypted_inode(inode) && f2fs_get_encryption_info(inode)) return -EACCES; if (attr->ia_size != i_size_read(inode)) { truncate_setsize(inode, attr->ia_size); f2fs_truncate(inode); f2fs_balance_fs(F2FS_I_SB(inode)); } else { /* * giving a chance to truncate blocks past EOF which * are fallocated with FALLOC_FL_KEEP_SIZE. */ f2fs_truncate(inode); } } __setattr_copy(inode, attr); if (attr->ia_valid & ATTR_MODE) { err = f2fs_acl_chmod(inode); if (err || is_inode_flag_set(fi, FI_ACL_MODE)) { inode->i_mode = fi->i_acl_mode; clear_inode_flag(fi, FI_ACL_MODE); } } mark_inode_dirty(inode); return err; }