From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K. V" Subject: Re: [PATCH -V3 3/5] vfs: Add open by file handle support Date: Fri, 23 Apr 2010 17:10:20 +0530 Message-ID: <87mxwujt23.fsf@linux.vnet.ibm.com> References: <1271960133-16414-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <1271960133-16414-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <45C46CC8-0877-43F9-8A59-E0C94A0CF5AF@sun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: hch@infradead.org, viro@zeniv.linux.org.uk, corbet@lwn.net, linux-fsdevel@vger.kernel.org, sfrench@us.ibm.com To: Andreas Dilger Return-path: Received: from e23smtp06.au.ibm.com ([202.81.31.148]:53387 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757221Ab0DWLke (ORCPT ); Fri, 23 Apr 2010 07:40:34 -0400 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp06.au.ibm.com (8.14.3/8.13.1) with ESMTP id o3NBePC1017373 for ; Fri, 23 Apr 2010 21:40:25 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3NBeTVB237576 for ; Fri, 23 Apr 2010 21:40:29 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3NBeSbB008177 for ; Fri, 23 Apr 2010 21:40:29 +1000 In-Reply-To: <45C46CC8-0877-43F9-8A59-E0C94A0CF5AF@sun.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, 22 Apr 2010 13:22:32 -0600, Andreas Dilger wrote: > On 2010-04-22, at 12:15, Aneesh Kumar K.V wrote: > > +long do_sys_open_by_handle(struct file_handle *fh, int flags) > > +{ > > Note this is inconsistent with the patch description that says that > the syscall is open_by_handle_at(). While the syscall is still using > the "_at()" suffix, it is no longer passing any directory. Fixed. > > > + sb = fs_get_sb(&fh->fsid); > > + if (!sb) > > + return -ESTALE; > > I was going to say that it would be nice to allow a fallback to the "_at" directory of the filesystem, but since the handle is specific to the exact filesystem it was created on anyway (inode number+generation, not even an rsync would be enough) the only way the handle is useful on another node is if the filesystem was cloned at the block device level (or is a shared filesystem identical on all nodes) so the UUID should be identical too. > > > + * Find the vfsmount for this superblock in the > > + * current namespace > > + */ > > + mnt = fs_get_vfsmount(current, sb); > > + if (!mnt) { > > + deactivate_super(sb); > > + return -ESTALE; > > + } > > + > > + dentry = handle_to_dentry(mnt, fh); > > + if (IS_ERR(dentry)) { > > + mntput(mnt); > > + deactivate_super(sb); > > + return PTR_ERR(dentry); > > + } > > Why is this code doing "manual" cleanup instead of setting retval and > goto out_sb: or out_mnt: type labels that only do partial cleanup? Fixed > > > + fsnotify_open(filp->f_path.dentry); > > + fd_install(fd, filp); > > + mntput(mnt); > > + deactivate_super(sb); > > + return fd; > > This could set retval = fd and goto out_mnt: (skipping dput(dentry)) in conjunction with the change proposed below. > > > +err_out: > > + mntput(mnt); > > + deactivate_super(sb); > > + dput(dentry); > > + return retval; > > +} > > I think it makes sense to do the dput(dentry) first, since it will be holding a reference on the sb and vfsmnt, and it also allows code simplification: > > out_err: > dput(dentry); > out_mnt: > mntput(mnt); > out_sb: > deactivate_super(sb); > > return retval; > } > Fixed I sent a V4 version of the patch with compat syscall support. -aneesh