Skip to content

Commit 8811249

Browse files
raven-auAl Viro
authored andcommitted
vfs: update d_make_root() description
Clearify d_make_root() usage, error handling and cleanup requirements. Signed-off-by: Ian Kent <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent a188339 commit 8811249

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Documentation/filesystems/porting

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,19 @@ release it yourself.
428428
--
429429
[mandatory]
430430
d_alloc_root() is gone, along with a lot of bugs caused by code
431-
misusing it. Replacement: d_make_root(inode). The difference is,
432-
d_make_root() drops the reference to inode if dentry allocation fails.
431+
misusing it. Replacement: d_make_root(inode). On success d_make_root(inode)
432+
allocates and returns a new dentry instantiated with the passed in inode.
433+
On failure NULL is returned and the passed in inode is dropped so the reference
434+
to inode is consumed in all cases and failure handling need not do any cleanup
435+
for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL
436+
and also requires no further error handling. Typical usage is:
437+
438+
inode = foofs_new_inode(....);
439+
s->s_root = d_make_inode(inode);
440+
if (!s->s_root)
441+
/* Nothing needed for the inode cleanup */
442+
return -ENOMEM;
443+
...
433444

434445
--
435446
[mandatory]

0 commit comments

Comments
 (0)