From fec93a4844b806c2b612a8036dfea6bb65b11107 Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Wed, 27 Oct 2010 22:08:46 -0400 Subject: [PATCH] --- yaml --- r: 218900 b: refs/heads/master c: 3d287de3b828226e5a450c7fd5bf4283792dc2b0 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ext4/inode.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index a2fb31486b15..8249a3e23e20 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: beed5ecbaa377fa8bb6a54a6608e8725a21efdbc +refs/heads/master: 3d287de3b828226e5a450c7fd5bf4283792dc2b0 diff --git a/trunk/fs/ext4/inode.c b/trunk/fs/ext4/inode.c index 9e60d0b8fa75..3ba237b0b2aa 100644 --- a/trunk/fs/ext4/inode.c +++ b/trunk/fs/ext4/inode.c @@ -5281,6 +5281,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; int error, rc = 0; + int orphan = 0; const unsigned int ia_valid = attr->ia_valid; error = inode_change_ok(inode, attr); @@ -5336,8 +5337,10 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) error = PTR_ERR(handle); goto err_out; } - - error = ext4_orphan_add(handle, inode); + if (ext4_handle_valid(handle)) { + error = ext4_orphan_add(handle, inode); + orphan = 1; + } EXT4_I(inode)->i_disksize = attr->ia_size; rc = ext4_mark_inode_dirty(handle, inode); if (!error) @@ -5355,6 +5358,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) goto err_out; } ext4_orphan_del(handle, inode); + orphan = 0; ext4_journal_stop(handle); goto err_out; } @@ -5377,7 +5381,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) * If the call to ext4_truncate failed to get a transaction handle at * all, we need to clean up the in-core orphan list manually. */ - if (inode->i_nlink) + if (orphan && inode->i_nlink) ext4_orphan_del(NULL, inode); if (!rc && (ia_valid & ATTR_MODE))