From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750914AbeFGUpc (ORCPT ); Thu, 7 Jun 2018 16:45:32 -0400 From: David Howells In-Reply-To: <1917614e-97dc-c911-c2d1-cc5d002d2071@suse.de> References: <1917614e-97dc-c911-c2d1-cc5d002d2071@suse.de> <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> <152720689245.9073.17300569813645143102.stgit@warthog.procyon.org.uk> To: Goldwyn Rodrigues Cc: dhowells@redhat.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 26/32] afs: Use fs_context to pass parameters over automount [ver #8] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14466.1528404329.1@warthog.procyon.org.uk> Date: Thu, 07 Jun 2018 21:45:29 +0100 Message-ID: <14467.1528404329@warthog.procyon.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Goldwyn Rodrigues wrote: Goldwyn Rodrigues wrote: > > +static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) > > +{ > > + struct fs_context *fc; > > + struct vfsmount *mnt; > > + int ret; > > + > > + BUG_ON(!d_inode(mntpt)); > > + > > + fc = vfs_new_fs_context(&afs_fs_type, mntpt, 0, > > + FS_CONTEXT_FOR_SUBMOUNT); > > + if (IS_ERR(fc)) > > + return ERR_CAST(fc); > > + > > + ret = afs_mntpt_set_params(fc, mntpt); > > + if (ret < 0) > > + goto error_fc; > > + > > + ret = vfs_get_tree(fc); > > + if (ret < 0) > > + goto error_fc; > > + > > + mnt = vfs_create_mount(fc, 0); > > + if (IS_ERR(mnt)) { > > + ret = PTR_ERR(mnt); > > + goto error_fc; > > + } > > > > - free_page((unsigned long) devname); > > - free_page((unsigned long) options); > > - _leave(" = %p", mnt); > > + put_fs_context(fc); > > return mnt; > > > Why are you performing a put_fs_context(fc) in the success code path? Do > we not need a reference of fc anymore? No. This is the ->d_automount() hook. The context is created at the top of the function, configuration is done, the superblock is obtained, a mount object is created (for which we get a ref returned). After that point, we don't need the context any more and no one else is going to clean it up for us. David