From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton 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> References: <1343303720-11199-1-git-send-email-jlayton@redhat.com> 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 To: viro@ZenIV.linux.org.uk Return-path: Received: from mail-yw0-f46.google.com ([209.85.213.46]:40861 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143Ab2GZLz3 (ORCPT ); Thu, 26 Jul 2012 07:55:29 -0400 Received: by yhmm54 with SMTP id m54so1830328yhm.19 for ; Thu, 26 Jul 2012 04:55:28 -0700 (PDT) In-Reply-To: <1343303720-11199-1-git-send-email-jlayton@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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); -- 1.7.11.2