From patchwork Thu Apr 11 04:28:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 10895089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8433717E6 for ; Thu, 11 Apr 2019 04:28:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EFBD28B86 for ; Thu, 11 Apr 2019 04:28:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50C7528C0B; Thu, 11 Apr 2019 04:28:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D69F628B86 for ; Thu, 11 Apr 2019 04:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfDKE2H (ORCPT ); Thu, 11 Apr 2019 00:28:07 -0400 Received: from icp-osb-irony-out4.external.iinet.net.au ([203.59.1.220]:36571 "EHLO icp-osb-irony-out4.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfDKE2H (ORCPT ); Thu, 11 Apr 2019 00:28:07 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AiCQAUwa5c/+g/0HZlHgEGBwaBZYIRgTgzJ4QOk38BAQEBAQEGgRA4a4hIhHCMCyMYAYRAhW0iOBIBAQMBAQEIAQEBAQJtKIV0BFIoDQIYDgJJFhOFCwyrPXwzGgKKEoELJYtHF3iBB4ERM4Iqc4dOglcDjRWFHDuTHgmUBxqCBoloA4hyAS2MQ5RyIYFWTS4KgyeQWTUwgQUBAY9mAQE X-IPAS-Result: A2AiCQAUwa5c/+g/0HZlHgEGBwaBZYIRgTgzJ4QOk38BAQEBAQEGgRA4a4hIhHCMCyMYAYRAhW0iOBIBAQMBAQEIAQEBAQJtKIV0BFIoDQIYDgJJFhOFCwyrPXwzGgKKEoELJYtHF3iBB4ERM4Iqc4dOglcDjRWFHDuTHgmUBxqCBoloA4hyAS2MQ5RyIYFWTS4KgyeQWTUwgQUBAY9mAQE X-IronPort-AV: E=Sophos;i="5.60,336,1549900800"; d="scan'208";a="156305197" Received: from unknown (HELO pluto.themaw.net) ([118.208.63.232]) by icp-osb-irony-out4.iinet.net.au with ESMTP; 11 Apr 2019 12:28:03 +0800 Subject: [PATCH] vfs: update d_make_root() description From: Ian Kent To: Al Viro Cc: Kernel Mailing List , linux-fsdevel Date: Thu, 11 Apr 2019 12:28:02 +0800 Message-ID: <155495688227.8321.9167555170089867027.stgit@pluto.themaw.net> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clearify d_make_root() usage, error handling and cleanup requirements. Signed-off-by: Ian Kent --- Documentation/filesystems/porting | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index cf43bc4dbf31..1ebc1c6eb64b 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting @@ -428,8 +428,19 @@ release it yourself. -- [mandatory] d_alloc_root() is gone, along with a lot of bugs caused by code -misusing it. Replacement: d_make_root(inode). The difference is, -d_make_root() drops the reference to inode if dentry allocation fails. +misusing it. Replacement: d_make_root(inode). On success d_make_root(inode) +allocates and returns a new dentry instantiated with the passed in inode. +On failure NULL is returned and the passed in inode is dropped so failure +handling need not do any cleanup for the inode. If d_make_root(inode) +is passed a NULL inode it returns NULL and also requires no further +error handling. Typical usage is: + + inode = foofs_new_inode(....); + s->s_root = d_make_inode(inode); + if (!s->s_root) + /* Nothing needed for the inode cleanup */ + return -ENOMEM; + ... -- [mandatory]