From patchwork Thu Jul 26 11:55:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1242341 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 47BED4025E for ; Thu, 26 Jul 2012 12:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752813Ab2GZMA5 (ORCPT ); Thu, 26 Jul 2012 08:00:57 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:52185 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752235Ab2GZLzd (ORCPT ); Thu, 26 Jul 2012 07:55:33 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so1826946yen.19 for ; Thu, 26 Jul 2012 04:55:33 -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=OEzgfhKr75Q8DXD+6sdNT3n7eplkRZBtcwyuuQ9J+VI=; b=C64cu6SWUXg02Qijhn72qigSJJQTQ5VeFw1o1PJfuzeQSETpLLAA3igEthVwkDtHOL S6C9BpVDApGi7/KpSjDzg15BA/K+p31D0p8bqdtJLafDa+Bf/xqWM2ymSKaEkTpOWf+/ 2hPRWuzmFeZ9hMaxwDvxQMX2f4wyDd5sdXZFD2wjcQ7ISVFGlfQdmQ6H40BI0VfujzvG dutIo62dHwI5wiH9WQziklhnIcQJJlA3GZTwWY6Tn57tCeFG8QLkXWxw7eq9xsgzlNdh LSyzds5yX2lHS+1xD7XQaH/gEWvFWbl1HVVkUqYMWGapAQZkNshVkPt4XLxqSGaf6MhA 79IA== Received: by 10.236.151.110 with SMTP id a74mr26983400yhk.35.1343303733377; Thu, 26 Jul 2012 04:55:33 -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.31 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:55:32 -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 04/17] vfs: fix readlinkat to retry on ESTALE Date: Thu, 26 Jul 2012 07:55:07 -0400 Message-Id: <1343303720-11199-5-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: ALoCoQnBfAOwlBKrvewNjxX0ClJAmzzXn8+HV+m3KaVObvfblOHWSMRA4P8S/Qv+vGoNZWDMLNth Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Jeff Layton --- fs/stat.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 5afeb37..c9d88f7 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -307,14 +307,25 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname, struct path path; int error; int empty = 0; + char *name; + unsigned int try = 0; + unsigned int lookup_flags = LOOKUP_EMPTY; if (bufsiz <= 0) return -EINVAL; - error = user_path_at_empty(dfd, pathname, LOOKUP_EMPTY, &path, &empty); - if (!error) { - struct inode *inode = path.dentry->d_inode; + name = getname_flags(pathname, lookup_flags, &empty); + if (IS_ERR(name)) + return PTR_ERR(name); + + do { + struct inode *inode; + + error = kern_path_at(dfd, name, lookup_flags, &path); + if (error) + break; + inode = path.dentry->d_inode; error = empty ? -ENOENT : -EINVAL; if (inode->i_op->readlink) { error = security_inode_readlink(path.dentry); @@ -325,7 +336,9 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname, } } path_put(&path); - } + lookup_flags |= LOOKUP_REVAL; + } while (retry_estale(error, try++)); + putname(name); return error; }