Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iget: introduce a function to register iget failure

Introduce a function to register failure in an inode construction path. This
includes marking the inode under construction as bad, unlocking it and
releasing it.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Howells and committed by
Linus Torvalds
b46980fe e231c2ee

+28 -5
+13 -5
Documentation/filesystems/porting
··· 184 184 test and set for you. 185 185 186 186 e.g. 187 - inode = iget_locked(sb, ino); 188 - if (inode->i_state & I_NEW) { 189 - read_inode_from_disk(inode); 190 - unlock_new_inode(inode); 191 - } 187 + inode = iget_locked(sb, ino); 188 + if (inode->i_state & I_NEW) { 189 + err = read_inode_from_disk(inode); 190 + if (err < 0) { 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 202 [recommended]
+14
fs/bad_inode.c
··· 359 359 } 360 360 361 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);
+1
include/linux/fs.h
··· 1780 1780 } 1781 1781 1782 1782 extern void __iget(struct inode * inode); 1783 + extern void iget_failed(struct inode *); 1783 1784 extern void clear_inode(struct inode *); 1784 1785 extern void destroy_inode(struct inode *); 1785 1786 extern struct inode *new_inode(struct super_block *);