From patchwork Sat Oct 27 12:33:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1655261 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 765623FD4E for ; Sat, 27 Oct 2012 12:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756235Ab2J0Mi0 (ORCPT ); Sat, 27 Oct 2012 08:38:26 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:65280 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755634Ab2J0Me1 (ORCPT ); Sat, 27 Oct 2012 08:34:27 -0400 Received: by mail-yh0-f46.google.com with SMTP id m54so690985yhm.19 for ; Sat, 27 Oct 2012 05:34:27 -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=8M6CPBsuZBIQILCJbPWZKv3IUEka3ozR3Dn+by9G8r4=; b=EwVXsFlA9Z8qjCHSjbiA7F5lUVBf7V4JxliWMUmaODVMMEUDEKJyOw9YAKckssQtD8 7ji2p7jv0ZRDDt9Zd2fU9Nu+tTMNTKrVo96BALcsIRFRNxFfqHPWqqSaHdTdLKll7/aI L0KNCoknF4tsvNPTMltmtb6fW8dg7gSu61x07+JaOjDukMRcjQN1AgydmrVkaaCsLfVi C8NR8NdEwKS7U2wOU85IZBEKXRt2gFemEVMG7+XwE3qPRVGDqRpCo69zXfJ4FhLJeb7X Jd0R4PZPmyXKtRN4jrOj3cb3AdWKO56sD7LwUuv7f2reXoCrwdh6x0+RC7H9WPCbh8yy XXzQ== Received: by 10.236.92.15 with SMTP id i15mr24702099yhf.85.1351341267635; Sat, 27 Oct 2012 05:34:27 -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.34.26 (version=SSLv3 cipher=OTHER); Sat, 27 Oct 2012 05:34:26 -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 21/32] vfs: allow setxattr to retry once on ESTALE errors Date: Sat, 27 Oct 2012 08:33:28 -0400 Message-Id: <1351341219-17837-22-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: ALoCoQnyp7yw02tG/mAMS2HFS3UtoXb2hqdjsXfoEngtTZSPOmRylLo+at9f4VCVhDsGxU5j+EFj 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/xattr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index f3a2ffa..5b6e48d 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -370,16 +370,21 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname, { struct path path; int error; + unsigned int try = 0; + unsigned int lookup_flags = LOOKUP_FOLLOW; - error = user_path(pathname, &path); - if (error) - return error; - error = mnt_want_write(path.mnt); - if (!error) { - error = setxattr(path.dentry, name, value, size, flags); - mnt_drop_write(path.mnt); - } - path_put(&path); + do { + error = user_path_at(AT_FDCWD, pathname, lookup_flags, &path); + if (error) + break; + error = mnt_want_write(path.mnt); + if (!error) { + error = setxattr(path.dentry, name, value, size, flags); + mnt_drop_write(path.mnt); + } + path_put(&path); + lookup_flags |= LOOKUP_REVAL; + } while (retry_estale(error, try++)); return error; }