From patchwork Fri Jun 29 18:57:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1133411 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C6742DFF34 for ; Fri, 29 Jun 2012 19:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932505Ab2F2TD4 (ORCPT ); Fri, 29 Jun 2012 15:03:56 -0400 Received: from mail-yw0-f42.google.com ([209.85.213.42]:40749 "EHLO mail-yw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932285Ab2F2S6I (ORCPT ); Fri, 29 Jun 2012 14:58:08 -0400 Received: by yhfq11 with SMTP id q11so4407178yhf.1 for ; Fri, 29 Jun 2012 11:58:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=fXsMxlSqhYIckQxYz4g22nKI04lv4NW4mq4Bs7nof+c=; b=l+qPxZ7XgYW9yD0FDTzedTVqsS0jfIt1jdNoQx2I1GH46BHbJym+kenojSQsL1jPx/ tnX2WNPKx7g3Bsf8Kb9Q/Qz8TlJpglKqLk9hDysueB+ZX6ai6HLsSWbMCbyKLekB/zXm NvgXRx6UfZY4SM8ChBAUhF4SoFej/gagp+sDH1WZakOYNrZdSc687i7vg4+TXicAipy2 IzdTr75yPLhuik34uoeFCmn/cursMMtw+z+a1+E3dEbx4IkHHA0Fq0M3eDnMPFN2sJ+Q CSghjmQPrLIkCwxf+/GW8KwqTLNzaaqlZxsmXO9S8AkuAsNIjKGnD/tfr44F4wYrYw67 3BMQ== Received: by 10.236.190.138 with SMTP id e10mr4527205yhn.131.1340996287468; Fri, 29 Jun 2012 11:58:07 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id l13sm3936309ann.2.2012.06.29.11.58.06 (version=SSLv3 cipher=OTHER); Fri, 29 Jun 2012 11:58:06 -0700 (PDT) From: Jeff Layton To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, michael.brantley@deshaw.com, hch@infradead.org, miklos@szeredi.hu, pstaubach@exagrid.com Subject: [PATCH v3 01/17] vfs: add a retry_estale helper function to handle retries on ESTALE Date: Fri, 29 Jun 2012 14:57:44 -0400 Message-Id: <1340996280-27123-2-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1340996280-27123-1-git-send-email-jlayton@redhat.com> References: <1340996280-27123-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQmgnidbWf517/1bNDKwF6CAFba3o4j3bmV4QNi4LOwqHPq9IkyPPvjKEFv1vyy0ZCFEoAHp Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This function is expected to be called from path-based syscalls to help them decide whether to try the lookup and call again in the event that they got an -ESTALE return back on an earier try. Currently, we only retry the call once on an ESTALE error, but in the event that we decide that that's not enough in the future, we should be able to change the logic in this helper without too much effort. Signed-off-by: Jeff Layton --- include/linux/fs.h | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 17fd887..4a2aa04 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2062,6 +2062,27 @@ extern struct file * dentry_open(struct dentry *, struct vfsmount *, int, extern int filp_close(struct file *, fl_owner_t id); extern char * getname(const char __user *); +/** + * retry_estale - determine whether the caller should retry an operation + * + * @error: the error we'll be returning + * @try: number of retries already performed + * + * Check to see if the error code was -ESTALE, and then determine whether + * to retry the call based on the number of retries so far. Currently, we only + * retry the call once. + * + * Returns true if the caller should try again. + */ +static inline bool +retry_estale(const long error, const unsigned int try) +{ + if (likely(error != -ESTALE)) + return false; + + return !try; +} + /* fs/ioctl.c */ extern int ioctl_preallocate(struct file *filp, void __user *argp);