From patchwork Thu Aug 31 21:10:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Fields X-Patchwork-Id: 9932907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6BE0603B4 for ; Thu, 31 Aug 2017 21:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB91326E56 for ; Thu, 31 Aug 2017 21:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56C1C27D16; Thu, 31 Aug 2017 21:10:56 +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=-6.9 required=2.0 tests=BAYES_00,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 A663923B24 for ; Thu, 31 Aug 2017 21:10:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771AbdHaVKI (ORCPT ); Thu, 31 Aug 2017 17:10:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42930 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbdHaVKF (ORCPT ); Thu, 31 Aug 2017 17:10:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E87B680F79; Thu, 31 Aug 2017 21:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E87B680F79 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bfields@redhat.com Received: from parsley.fieldses.org (unknown [10.17.132.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647CC5D6A2; Thu, 31 Aug 2017 21:10:03 +0000 (UTC) Received: by parsley.fieldses.org (Postfix, from userid 2815) id 6B6A9180E90; Thu, 31 Aug 2017 17:10:02 -0400 (EDT) Date: Thu, 31 Aug 2017 17:10:02 -0400 From: "J. Bruce Fields" To: Jeff Layton Cc: NeilBrown , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Trond Myklebust Subject: Re: [PATCH 1/3] fs: cleanup to hide some details of delegation logic Message-ID: <20170831211002.GG8223@parsley.fieldses.org> References: <1503697958-6122-1-git-send-email-bfields@redhat.com> <1503697958-6122-2-git-send-email-bfields@redhat.com> <87efrwibyz.fsf@notabene.neil.brown.name> <20170829213731.GH8822@parsley.fieldses.org> <1504122659.2845.1.camel@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1504122659.2845.1.camel@redhat.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 31 Aug 2017 21:10:05 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Aug 30, 2017 at 03:50:59PM -0400, Jeff Layton wrote: > ACK, I like that better too. I think a kerneldoc header is probably > warranted here too, since this is a bit of an odd return situation. Am I overdoing it?: --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/include/linux/fs.h b/include/linux/fs.h index 6421feeda4bd..2261728cc900 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2285,6 +2285,25 @@ static inline int break_deleg(struct inode *inode, void *who, unsigned int mode) #define DELEG_NO_WAIT ((struct inode *)1) +/** + * try_break_deleg - initiate a delegation break + * @inode: inode to break the delegation on + * @deleg_break_ctl: delegation state; see below + * + * VFS operations that are incompatible with a delegation call this to + * break any delegations on the inode first. The caller must first lock + * the inode to prevent races with processes granting new delegations. + * + * Delegations may be slow to recall, so we initiate the recall but do + * not wait for it here while holding locks. The caller should instead + * drop locks and call break_deleg_wait() which will wait for a recall, + * if there is one. The inode to wait on will be stored in + * deleg_break_ctl, which also tracks who is breaking the delegation in + * the NFS case. The caller can then retry the operation (possibly on a + * different inode, since a new lookup may have been required after + * reacquiring locks.) + */ + static inline int try_break_deleg(struct inode *inode, struct deleg_break_ctl *deleg_break_ctl) { int ret; @@ -2299,6 +2318,22 @@ static inline int try_break_deleg(struct inode *inode, struct deleg_break_ctl *d return ret; } +/** + * break_deleg_wait - wait on a delegation recall if necessary + * @deleg_break_ctl: delegation state + * @error: error to use if there is no delegation to wait on + * + * This should be called with the deleg_break_ctl previously passed to + * try_break_deleg(). + * + * If the previous try_break_deleg() found no delegation in need of + * breaking, this is a no-op that just returns the given error. + * + * Otherwise it will wait for the delegation recall. If the wait is + * succesful, it will return a positive value to indicate to the caller + * that it should retry the operation that originally prompted the + * break. + */ static inline int break_deleg_wait(struct deleg_break_ctl *deleg_break_ctl, int error) { if (!deleg_break_ctl->delegated_inode)