From patchwork Fri Sep 7 14:18: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: 1422821 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 5AB5EDF283 for ; Fri, 7 Sep 2012 14:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760749Ab2IGOTB (ORCPT ); Fri, 7 Sep 2012 10:19:01 -0400 Received: from mail-vb0-f46.google.com ([209.85.212.46]:42139 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760685Ab2IGOSp (ORCPT ); Fri, 7 Sep 2012 10:18:45 -0400 Received: by vbbff1 with SMTP id ff1so3363913vbb.19 for ; Fri, 07 Sep 2012 07:18:45 -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=DWRgQiAfcRokQ9HgiT9TvRmSjZSwF069+96u3LeMWUA=; b=kF0CDXCiFez0566whnIvpChOShkWQVQ/uUy11VSUDHAN/WnCQMplVIE2gUgpTdKgAL ceC9fs/Y/YmFXui4Wuln7DdQw3nyKwOr94V6qOkqPXw/au/66cHRpssmrNVogmtB6Sja vOP9lDCehAdIie2mVhDggT9zN3XCsfw6EXQXrwrM6KHCyUX6OJ/GqQkRQeiGOLyGuGNM 2TObDt3otfP2W4860FWFN3MritHHfCniTnNgYFdbdE4pFRhhFZIXFTfQAGVF9V4iZ56w ZtNnC1X4XlHDTXBoiTKDu0nLyQdveiCAIq7YfP3TvCcLbv/iUJjCB/HcHkaBRKznODI4 uw1A== Received: by 10.52.98.67 with SMTP id eg3mr6041458vdb.5.1347027516375; Fri, 07 Sep 2012 07:18:36 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-069-134-145-027.nc.res.rr.com. [69.134.145.27]) by mx.google.com with ESMTPS id v9sm3207113ves.8.2012.09.07.07.18.34 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 07:18:35 -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 v6 01/20] vfs: add a retry_estale helper function to handle retries on ESTALE Date: Fri, 7 Sep 2012 10:18:08 -0400 Message-Id: <1347027507-20956-2-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1347027507-20956-1-git-send-email-jlayton@redhat.com> References: <1347027507-20956-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQkMYDT8zBDk3SAQGoRfjietWhuvdO8r9mzI7/j3V12xT5kfiwUprbp7iQWSe9s8L3QyMFme 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 a3c2c17..78e8639 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2221,6 +2221,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);