diff options
-rw-r--r-- | Documentation/filesystems/porting | 18 | ||||
-rw-r--r-- | fs/bad_inode.c | 14 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
3 files changed, 28 insertions, 5 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 0f33c77bc14b..fbd3815a5f57 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -184,11 +184,19 @@ just takes the superblock and inode number as arguments and does the | |||
184 | test and set for you. | 184 | test and set for you. |
185 | 185 | ||
186 | e.g. | 186 | e.g. |
187 | inode = iget_locked(sb, ino); | 187 | inode = iget_locked(sb, ino); |
188 | if (inode->i_state & I_NEW) { | 188 | if (inode->i_state & I_NEW) { |
189 | read_inode_from_disk(inode); | 189 | err = read_inode_from_disk(inode); |
190 | unlock_new_inode(inode); | 190 | if (err < 0) { |
191 | } | 191 | iget_failed(inode); |
192 | return err; | ||
193 | } | ||
194 | unlock_new_inode(inode); | ||
195 | } | ||
196 | |||
197 | Note that if the process of setting up a new inode fails, then iget_failed() | ||
198 | should be called on the inode to render it dead, and an appropriate error | ||
199 | should be passed back to the caller. | ||
192 | 200 | ||
193 | --- | 201 | --- |
194 | [recommended] | 202 | [recommended] |
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 521ff7caadbd..f1c2ea8342f5 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
@@ -359,3 +359,17 @@ int is_bad_inode(struct inode *inode) | |||
359 | } | 359 | } |
360 | 360 | ||
361 | EXPORT_SYMBOL(is_bad_inode); | 361 | EXPORT_SYMBOL(is_bad_inode); |
362 | |||
363 | /** | ||
364 | * iget_failed - Mark an under-construction inode as dead and release it | ||
365 | * @inode: The inode to discard | ||
366 | * | ||
367 | * Mark an under-construction inode as dead and release it. | ||
368 | */ | ||
369 | void iget_failed(struct inode *inode) | ||
370 | { | ||
371 | make_bad_inode(inode); | ||
372 | unlock_new_inode(inode); | ||
373 | iput(inode); | ||
374 | } | ||
375 | EXPORT_SYMBOL(iget_failed); | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 2925f7011ece..d202600d36bd 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1780,6 +1780,7 @@ static inline struct inode *iget(struct super_block *sb, unsigned long ino) | |||
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | extern void __iget(struct inode * inode); | 1782 | extern void __iget(struct inode * inode); |
1783 | extern void iget_failed(struct inode *); | ||
1783 | extern void clear_inode(struct inode *); | 1784 | extern void clear_inode(struct inode *); |
1784 | extern void destroy_inode(struct inode *); | 1785 | extern void destroy_inode(struct inode *); |
1785 | extern struct inode *new_inode(struct super_block *); | 1786 | extern struct inode *new_inode(struct super_block *); |