diff options
author | David Howells <dhowells@redhat.com> | 2008-02-07 03:15:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:29 -0500 |
commit | 12debc4248a4a7f1873e47cda2cdd7faca80b099 (patch) | |
tree | 1ad80b77d213ea09cb746d6e4d50c4316462a452 /Documentation/filesystems/porting | |
parent | 755aedc15900ff7d83dd046f632af9a680b0c28f (diff) |
iget: remove iget() and the read_inode() super op as being obsolete
Remove the old iget() call and the read_inode() superblock operation it uses
as these are really obsolete, and the use of read_inode() does not produce
proper error handling (no distinction between ENOMEM and EIO when marking an
inode bad).
Furthermore, this removes the temptation to use iget() to find an inode by
number in a filesystem from code outside that filesystem.
iget_locked() should be used instead. A new function is added in an earlier
patch (iget_failed) that is to be called to mark an inode as bad, unlock it
and release it should the get routine fail. Mark iget() and read_inode() as
being obsolete and remove references to them from the documentation.
Typically a filesystem will be modified such that the read_inode function
becomes an internal iget function, for example the following:
void thingyfs_read_inode(struct inode *inode)
{
...
}
would be changed into something like:
struct inode *thingyfs_iget(struct super_block *sp, unsigned long ino)
{
struct inode *inode;
int ret;
inode = iget_locked(sb, ino);
if (!inode)
return ERR_PTR(-ENOMEM);
if (!(inode->i_state & I_NEW))
return inode;
...
unlock_new_inode(inode);
return inode;
error:
iget_failed(inode);
return ERR_PTR(ret);
}
and then thingyfs_iget() would be called rather than iget(), for example:
ret = -EINVAL;
inode = iget(sb, ino);
if (!inode || is_bad_inode(inode))
goto error;
becomes:
inode = thingyfs_iget(sb, ino);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
goto error;
}
Note that is_bad_inode() does not need to be called. The error returned by
thingyfs_iget() should render it unnecessary.
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>
Diffstat (limited to 'Documentation/filesystems/porting')
-rw-r--r-- | Documentation/filesystems/porting | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index fbd3815a5f57..92b888d540a6 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -34,8 +34,8 @@ FOO_I(inode) (see in-tree filesystems for examples). | |||
34 | 34 | ||
35 | Make them ->alloc_inode and ->destroy_inode in your super_operations. | 35 | Make them ->alloc_inode and ->destroy_inode in your super_operations. |
36 | 36 | ||
37 | Keep in mind that now you need explicit initialization of private data - | 37 | Keep in mind that now you need explicit initialization of private data |
38 | typically in ->read_inode() and after getting an inode from new_inode(). | 38 | typically between calling iget_locked() and unlocking the inode. |
39 | 39 | ||
40 | At some point that will become mandatory. | 40 | At some point that will become mandatory. |
41 | 41 | ||
@@ -173,10 +173,10 @@ should be a non-blocking function that initializes those parts of a | |||
173 | newly created inode to allow the test function to succeed. 'data' is | 173 | newly created inode to allow the test function to succeed. 'data' is |
174 | passed as an opaque value to both test and set functions. | 174 | passed as an opaque value to both test and set functions. |
175 | 175 | ||
176 | When the inode has been created by iget5_locked(), it will be returned with | 176 | When the inode has been created by iget5_locked(), it will be returned with the |
177 | the I_NEW flag set and will still be locked. read_inode has not been | 177 | I_NEW flag set and will still be locked. The filesystem then needs to finalize |
178 | called so the file system still has to finalize the initialization. Once | 178 | the initialization. Once the inode is initialized it must be unlocked by |
179 | the inode is initialized it must be unlocked by calling unlock_new_inode(). | 179 | calling unlock_new_inode(). |
180 | 180 | ||
181 | The filesystem is responsible for setting (and possibly testing) i_ino | 181 | The filesystem is responsible for setting (and possibly testing) i_ino |
182 | when appropriate. There is also a simpler iget_locked function that | 182 | when appropriate. There is also a simpler iget_locked function that |