From patchwork Thu Jul 26 11:55:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1242391 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 57CB4DFFBF for ; Thu, 26 Jul 2012 12:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184Ab2GZMCK (ORCPT ); Thu, 26 Jul 2012 08:02:10 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:53878 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752056Ab2GZLz3 (ORCPT ); Thu, 26 Jul 2012 07:55:29 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so1845569ghr.19 for ; Thu, 26 Jul 2012 04:55:28 -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=Rhbw54cOS9hiY32IvyuMtPIlr/y8ZOgk49/vETak6os=; b=cVnQp5FEUG17TJi6eiqyUY+oUbQ+xL4DPOkYKPbqUh3i2GIW1sjYiyFM71kLlJqkrl m+K7n9ZU60a0jWPTjZjIn7T46Ny2xBF9Uz4nTCMhVJkxpLCaHwZZZlHJZ27Ee210eh4l FLiDDPHve5YCnqkr248hD0yZ9/CR9bx0OzGfQP6ppmT76yuvV+nydBo6kfaMRoH9oZM6 gmxqujh2doOayPCIMvH85/N3bF2y3iEaC/LR187ywgpw6g+GZZwBGn1m059wZtv1wVdM 7BgqypEsYtr6ETZfxGU/X78wEsmnwrI8Z2RBhJtQ6UJNaGeFJPgw6jpIewLcDglOdy0Y NHNA== Received: by 10.236.146.97 with SMTP id q61mr26930125yhj.113.1343303728689; Thu, 26 Jul 2012 04:55:28 -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 l12sm4436364ank.2.2012.07.26.04.55.27 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:55:27 -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 v4 01/17] vfs: add a retry_estale helper function to handle retries on ESTALE Date: Thu, 26 Jul 2012 07:55:04 -0400 Message-Id: <1343303720-11199-2-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1343303720-11199-1-git-send-email-jlayton@redhat.com> References: <1343303720-11199-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQn3mlaakYleCC2Q7hFBpCNpPIfqlbJRKn5cTQ+5ZuEwIMiqBJuOnb7su7czcnz+frvDnCHs 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 8fabb03..138d93a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2072,6 +2072,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);