From patchwork Sat Apr 9 14:00:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 8788411 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 050F0C0553 for ; Sat, 9 Apr 2016 14:00:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FDB7202B8 for ; Sat, 9 Apr 2016 14:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF6BF202AE for ; Sat, 9 Apr 2016 14:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282AbcDIOAi (ORCPT ); Sat, 9 Apr 2016 10:00:38 -0400 Received: from mail-qg0-f54.google.com ([209.85.192.54]:34597 "EHLO mail-qg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942AbcDIOAh (ORCPT ); Sat, 9 Apr 2016 10:00:37 -0400 Received: by mail-qg0-f54.google.com with SMTP id c6so112221649qga.1 for ; Sat, 09 Apr 2016 07:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ACzjsgichl6XbD+3vITm1OdiGVYUh8QziJp6H7aKnLU=; b=vi7Drp1BJ/Xka1wPbxpinlnS2u4/FF3Q85weqFq8w2oVHrJTMLHIaJ2G3SpRz676zU qwAVAh1vVlx0cai7+NH0a3ttwXa2fvpcs3+44pJtZF89erTVIi174Am4gblG6E5fIenp 6CXku84ARCtLWlTENNpk+v2JPAJRkx0HApAa2H6h7bCL3ieM1ikkz+jCwsozhhZXbW4F oSUIylv8lzVQGoURCulrkRSVT5SW9OAx6SHz7oAsFOlow/cZE3xWAKh3CKcFbiACMuux 5HtTwoRmBti4yubAiSMvnCGnnDYGvKIQvH2AcagADbyY9vRM3Aq+hIL8VltMtml93PQN 9RYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ACzjsgichl6XbD+3vITm1OdiGVYUh8QziJp6H7aKnLU=; b=iKnBJkVLnb/fmpRiai+OFZwl3qzoc5j9wo2OpPe2FiNwZSPosB8CrkHY4fyPMFs9Nw OFZdqM6Cc+uVbuuQYslFCPih4ogM1dhjDfygiwxbflRwPEaaJLYbTS1zY/7kOeUWnFqA RusboF9e6kYJ1DrFxB326wzEPtbknlql7FeuZ6WtEXPCrFj51+QA3X5sVFReXH0bKBH6 OgunK2dmxnMc2Hp6Z0RgX+/ASBKDvPUkYPkhma9jKc/rR8t9R3TQHF3e8y6niwxovQew kFruFbJ3ha0ZzCYrtm0vb1IPW0tsmcaw12NVfiIvCAM1F2rmO5fj0ECZ1PSLzKzA3sqj HMjg== X-Gm-Message-State: AD7BkJL+Mg/oy0mQopzOs/I8kQXW7bv9papmupVuqaHBYvrXQZ5KkgkEHzgeXsH5q0pHMQ== X-Received: by 10.140.44.8 with SMTP id f8mr17681833qga.42.1460210436418; Sat, 09 Apr 2016 07:00:36 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id l33sm7471686qge.11.2016.04.09.07.00.34 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 09 Apr 2016 07:00:35 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfs: don't match flexfiles mirrors that have different creds Date: Sat, 9 Apr 2016 10:00:33 -0400 Message-Id: <1460210433-20435-1-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.5.5 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we're comparing mirrors to avoid adding duplicates to the to the list, we must also consider the creds when comparing them. Otherwise, mirrors that differ only by the credential will be improperly merged. This is a problem if the client does a LAYOUTGET for a READ layout first and then one for a RW, and the server sends a layout with a non-usable uid for the READ layout. The RW mirror entry will get dropped on the second layoutget as the client thinks the mirror is identical to the one from the first. Then, when it goes to do a WRITE, it ends up using the creds from the READ layout and the write fails with EACCES. Another possibility is to allow the RW segment to supersede the READ one. The problem there is that the RW layout is returned, then the client will still end up using the creds in the RW layout, which may not be correct. Signed-off-by: Jeff Layton --- fs/nfs/flexfilelayout/flexfilelayout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 0cb1abd535e3..5d0789a41bc2 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -172,6 +172,8 @@ ff_layout_add_mirror(struct pnfs_layout_hdr *lo, continue; if (!ff_mirror_match_fh(mirror, pos)) continue; + if (mirror->uid != pos->uid || mirror->gid != pos->gid) + continue; if (atomic_inc_not_zero(&pos->ref)) { spin_unlock(&inode->i_lock); return pos;