From patchwork Sat Oct 27 12:33:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1655601 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D63E93FD4E for ; Sat, 27 Oct 2012 12:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754420Ab2J0Mny (ORCPT ); Sat, 27 Oct 2012 08:43:54 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:59451 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753337Ab2J0Mdv (ORCPT ); Sat, 27 Oct 2012 08:33:51 -0400 Received: by mail-gg0-f174.google.com with SMTP id k5so690906ggd.19 for ; Sat, 27 Oct 2012 05:33:50 -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=Rw2ZeWDlKI6jEbl6YGj78NakPnmrGGYOpmEt0AwjwOY=; b=H2cUxbqlUSJc8+HlJ8dsM6nLtNMwf4ZLR2lQ1m/viRwoCSu6as3clwg0f3NrH7jcnV GLn36oB3qkTyGvDg5Bagu34AE/PaVfq4HuwHbnwF0CuwXQAeimwVs+GE9uFJo8c3MjwE d9NIvvU6mIoGphQjFHtd9ZNtldsdIJd7ukv1kgVb1wh+UTqsmMpMKMhC+WfKKTcRNImf y6MYYnjOKf16X0X8j78XKBPkU/6q1i9Lq/Txmcl6EoQrubP2uzSznKJisMoqDpsE4Sca o5el3vuH7ZZV1twlZ5C9h/vXxvHF9mXb13cG9UA3pjdvEHBAf6iOu0zGRYeMZtuNBmCT AWjQ== Received: by 10.236.142.135 with SMTP id i7mr24525861yhj.127.1351341230815; Sat, 27 Oct 2012 05:33:50 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id f15sm4124613yhi.11.2012.10.27.05.33.48 (version=SSLv3 cipher=OTHER); Sat, 27 Oct 2012 05:33:49 -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 v8 01/32] vfs: add a retry_estale helper function to handle retries on ESTALE Date: Sat, 27 Oct 2012 08:33:08 -0400 Message-Id: <1351341219-17837-2-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351341219-17837-1-git-send-email-jlayton@redhat.com> References: <1351341219-17837-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQkWGm5AXQcjx0rR7lGAp8XbZORKDDbnOHkWL8/DMD4kIiHZ9xn3ehIGCETnrPHaJYOF6DlQ 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 file changed, 21 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index b33cfc9..01ff902 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2023,6 +2023,27 @@ extern int finish_open(struct file *file, struct dentry *dentry, int *opened); extern int finish_no_open(struct file *file, struct dentry *dentry); +/** + * 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);