aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/porting18
-rw-r--r--fs/bad_inode.c14
-rw-r--r--include/linux/fs.h1
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
184test and set for you. 184test and set for you.
185 185
186e.g. 186e.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
197Note that if the process of setting up a new inode fails, then iget_failed()
198should be called on the inode to render it dead, and an appropriate error
199should 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
361EXPORT_SYMBOL(is_bad_inode); 361EXPORT_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 */
369void iget_failed(struct inode *inode)
370{
371 make_bad_inode(inode);
372 unlock_new_inode(inode);
373 iput(inode);
374}
375EXPORT_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
1782extern void __iget(struct inode * inode); 1782extern void __iget(struct inode * inode);
1783extern void iget_failed(struct inode *);
1783extern void clear_inode(struct inode *); 1784extern void clear_inode(struct inode *);
1784extern void destroy_inode(struct inode *); 1785extern void destroy_inode(struct inode *);
1785extern struct inode *new_inode(struct super_block *); 1786extern struct inode *new_inode(struct super_block *);