From patchwork Tue Jul 9 15:58:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Bruce Fields" X-Patchwork-Id: 2825362 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9C5D9F756 for ; Tue, 9 Jul 2013 15:58:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9244E201F5 for ; Tue, 9 Jul 2013 15:58:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61742201F6 for ; Tue, 9 Jul 2013 15:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752688Ab3GIP6p (ORCPT ); Tue, 9 Jul 2013 11:58:45 -0400 Received: from fieldses.org ([174.143.236.118]:45960 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751999Ab3GIP6p (ORCPT ); Tue, 9 Jul 2013 11:58:45 -0400 Received: from bfields by fieldses.org with local (Exim 4.76) (envelope-from ) id 1UwaJP-0002pJ-4Y; Tue, 09 Jul 2013 11:58:43 -0400 Date: Tue, 9 Jul 2013 11:58:43 -0400 To: Jeff Layton Cc: "J. Bruce Fields" , Al Viro , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Howells , Tyler Hicks , Dustin Kirkland Subject: Re: [PATCH 08/12] locks: break delegations on unlink Message-ID: <20130709155842.GC8281@fieldses.org> References: <1372882356-14168-1-git-send-email-bfields@redhat.com> <1372882356-14168-9-git-send-email-bfields@redhat.com> <20130709090506.71c96841@tlielax.poochiereds.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130709090506.71c96841@tlielax.poochiereds.net> User-Agent: Mutt/1.5.21 (2010-09-15) From: "J. Bruce Fields" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Jul 09, 2013 at 09:05:06AM -0400, Jeff Layton wrote: > On Wed, 3 Jul 2013 16:12:32 -0400 > "J. Bruce Fields" wrote: > > > From: "J. Bruce Fields" > > > > We need to break delegations on any operation that changes the set of > > links pointing to an inode. Start with unlink. > > > > Such operations also hold the i_mutex on a parent directory. Breaking a > > delegation may require waiting for a timeout (by default 90 seconds) in > > the case of a unresponsive NFS client. To avoid blocking all directory > > operations, we therefore drop locks before waiting for the delegation. > > The logic then looks like: > > > > acquire locks > > ... > > test for delegation; if found: > > take reference on inode > > release locks > > wait for delegation break > > drop reference on inode > > retry > > > > It is possible this could never terminate. (Even if we take precautions > > to prevent another delegation being acquired on the same inode, we could > > get a different inode on each retry.) But this seems very unlikely. > > > > The initial test for a delegation happens after the lock on the target > > inode is acquired, but the directory inode may have been acquired > > further up the call stack. We therefore add a "struct inode **" > > argument to any intervening functions, which we use to pass the inode > > back up to the caller in the case it needs a delegation synchronously > > broken. ... > > -int vfs_unlink(struct inode *dir, struct dentry *dentry) > > +int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode) > > nit: this might be a good time to add a kerneldoc header on this > function. The delegated_inode thing might not be clear to the > uninitiated. Something like this? --b. --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/namei.c b/fs/namei.c index cba3db1..7c6e244 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3384,6 +3384,24 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname) return do_rmdir(AT_FDCWD, pathname); } +/** + * vfs_unlink - unlink a filesystem object + * @dir: parent directory + * @dentry: victim + * @delegated_inode: returns victim inode, if the inode is delegated. + * + * The caller must hold dir->i_mutex. + * + * If vfs_unlink discovers a delegation, it will return -EWOULDBLOCK and + * return a reference to the inode in delegated_inode. The caller + * should then break the delegation on that inode and retry. Because + * breaking a delegation may take a long time, the caller should drop + * dir->i_mutex before doing so. + * + * Alternatively, a caller may pass NULL for delegated_inode. This may + * be appropriate for callers that expect the underlying filesystem not + * to be NFS exported. + */ int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode) { struct inode *target = dentry->d_inode;