diff options
| -rw-r--r-- | fs/ext2/ext2.h | 1 | ||||
| -rw-r--r-- | fs/ext2/inode.c | 13 | ||||
| -rw-r--r-- | fs/ext2/super.c | 4 |
3 files changed, 15 insertions, 3 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 9f1a40e7945c..8f0fd726c3f1 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
| @@ -116,6 +116,7 @@ extern unsigned long ext2_count_free (struct buffer_head *, unsigned); | |||
| 116 | /* inode.c */ | 116 | /* inode.c */ |
| 117 | extern void ext2_read_inode (struct inode *); | 117 | extern void ext2_read_inode (struct inode *); |
| 118 | extern int ext2_write_inode (struct inode *, int); | 118 | extern int ext2_write_inode (struct inode *, int); |
| 119 | extern void ext2_put_inode (struct inode *); | ||
| 119 | extern void ext2_delete_inode (struct inode *); | 120 | extern void ext2_delete_inode (struct inode *); |
| 120 | extern int ext2_sync_inode (struct inode *); | 121 | extern int ext2_sync_inode (struct inode *); |
| 121 | extern void ext2_discard_prealloc (struct inode *); | 122 | extern void ext2_discard_prealloc (struct inode *); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index b890be022496..a50d9db4b6e4 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
| @@ -53,6 +53,19 @@ static inline int ext2_inode_is_fast_symlink(struct inode *inode) | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /* | 55 | /* |
| 56 | * Called at each iput(). | ||
| 57 | * | ||
| 58 | * The inode may be "bad" if ext2_read_inode() saw an error from | ||
| 59 | * ext2_get_inode(), so we need to check that to avoid freeing random disk | ||
| 60 | * blocks. | ||
| 61 | */ | ||
| 62 | void ext2_put_inode(struct inode *inode) | ||
| 63 | { | ||
| 64 | if (!is_bad_inode(inode)) | ||
| 65 | ext2_discard_prealloc(inode); | ||
| 66 | } | ||
| 67 | |||
| 68 | /* | ||
| 56 | * Called at the last iput() if i_nlink is zero. | 69 | * Called at the last iput() if i_nlink is zero. |
| 57 | */ | 70 | */ |
| 58 | void ext2_delete_inode (struct inode * inode) | 71 | void ext2_delete_inode (struct inode * inode) |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 37ca77a157ba..661c3d98d946 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
| @@ -198,11 +198,8 @@ static void ext2_clear_inode(struct inode *inode) | |||
| 198 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; | 198 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; |
| 199 | } | 199 | } |
| 200 | #endif | 200 | #endif |
| 201 | if (!is_bad_inode(inode)) | ||
| 202 | ext2_discard_prealloc(inode); | ||
| 203 | } | 201 | } |
| 204 | 202 | ||
| 205 | |||
| 206 | #ifdef CONFIG_QUOTA | 203 | #ifdef CONFIG_QUOTA |
| 207 | static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off); | 204 | static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off); |
| 208 | static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off); | 205 | static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off); |
| @@ -213,6 +210,7 @@ static struct super_operations ext2_sops = { | |||
| 213 | .destroy_inode = ext2_destroy_inode, | 210 | .destroy_inode = ext2_destroy_inode, |
| 214 | .read_inode = ext2_read_inode, | 211 | .read_inode = ext2_read_inode, |
| 215 | .write_inode = ext2_write_inode, | 212 | .write_inode = ext2_write_inode, |
| 213 | .put_inode = ext2_put_inode, | ||
| 216 | .delete_inode = ext2_delete_inode, | 214 | .delete_inode = ext2_delete_inode, |
| 217 | .put_super = ext2_put_super, | 215 | .put_super = ext2_put_super, |
| 218 | .write_super = ext2_write_super, | 216 | .write_super = ext2_write_super, |
