From patchwork Tue Aug 13 14:28:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11092343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C828614F7 for ; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9BBF286A4 for ; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE46D286A1; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 319E728613 for ; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbfHMOaQ (ORCPT ); Tue, 13 Aug 2019 10:30:16 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:32785 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728227AbfHMOaQ (ORCPT ); Tue, 13 Aug 2019 10:30:16 -0400 Received: by mail-ot1-f65.google.com with SMTP id q20so20302901otl.0 for ; Tue, 13 Aug 2019 07:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=dodPeBHiTvXQpNHuEhbNlONL9Drrpvmy/8YMtOGC/4E=; b=ORA9DuNIXC3zPuUm1/0HhV3KegzLJGzA2q0tprr3zARJ4vWYGMrEcA7ozf3C3GmA+5 vxBbaCrlh2dd4yykKOK2/YO89S3e5QUjgxN9uf1EWj2xy4Mo281M2dYSxe5abyLr5g1m uV2jG1YiIt81/yLwPg1M+UHnsSzV6rLuAqGiy8BEpNi/IJHZWwRDu5bv4ehRRigBco33 bHpNkUSjD4fept7dmEODnTsOcaqG3Lsg/DD/ZYGKjG2/2KT7s4u8YXMdyb7Yjq2XJuD3 62qbANrJjPjvPRHH3jS7VlbBuXPWhklmUt91M+806rsIctWk9jpjk2gPkWrse10zDxfe sf6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=dodPeBHiTvXQpNHuEhbNlONL9Drrpvmy/8YMtOGC/4E=; b=fhUyPwtgLPyfizSUy4UOJigWgJVwqh/CcGI0DRC5TXW7LVi9bw62DPfYitM/FA+Mt4 QYe+mkNVKBcM7KQX+nKclFOEvafnhwxKBlX5xMGcI7ISKYVKKx1IcS1UL+63w72VWl6s qgnLTNp6rFLJ8Y3fbfeGj2dV/Sdjc1MUcKRvd8rbpu0YxXlFkw3/f7Z+o+ATGNXwiBOX jMcaFrsYsolzx1FxNeQ42z7Ufg97KRRtFSS8Oq3PiCjLGpqNRMNyD1XXPcHz66P4xt8K fXXQvLm+3vBFwa0MlssTc93sOPUDVXVEGGdXPrDX1fO5Yw66NarhbkBXYBEsmypazdck C6DA== X-Gm-Message-State: APjAAAWOS3wJJLNyPhMLWoq+y+oAuljtACXLzKmqzsbmkgSw/kxVb5QE imi1hjxTurTwDq3FugElOvZo7xg= X-Google-Smtp-Source: APXvYqw325CEAjBNw8aQXAQFUqP4+xvF8Y8TWqsiQFDf8d0iOGzGBerIqYfEAwRaXxgyOMD1MiCwxQ== X-Received: by 2002:a02:c916:: with SMTP id t22mr42779652jao.24.1565706614624; Tue, 13 Aug 2019 07:30:14 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o6sm9429161ioh.22.2019.08.13.07.30.13 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 07:30:14 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 1/5] NFS: Don't refresh attributes with mounted-on-file information Date: Tue, 13 Aug 2019 10:28:02 -0400 Message-Id: <20190813142806.123268-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we've been given the attributes of the mounted-on-file, then do not use those to check or update the attributes on the application-visible inode. Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 8a1758200b57..c764cfe456e5 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1403,12 +1403,21 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) return 0; + /* No fileid? Just exit */ + if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) + return 0; /* Has the inode gone and changed behind our back? */ - if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid) + if (nfsi->fileid != fattr->fileid) { + /* Is this perhaps the mounted-on fileid? */ + if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) && + nfsi->fileid == fattr->mounted_on_fileid) + return 0; return -ESTALE; + } if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) return -ESTALE; + if (!nfs_file_has_buffered_writers(nfsi)) { /* Verify a few of the more important attributes */ if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && !inode_eq_iversion_raw(inode, fattr->change_attr)) @@ -1768,18 +1777,6 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc); -static inline bool nfs_fileid_valid(struct nfs_inode *nfsi, - struct nfs_fattr *fattr) -{ - bool ret1 = true, ret2 = true; - - if (fattr->valid & NFS_ATTR_FATTR_FILEID) - ret1 = (nfsi->fileid == fattr->fileid); - if (fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) - ret2 = (nfsi->fileid == fattr->mounted_on_fileid); - return ret1 || ret2; -} - /* * Many nfs protocol calls return the new file attributes after * an operation. Here we update the inode to reflect the state @@ -1810,7 +1807,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfs_display_fhandle_hash(NFS_FH(inode)), atomic_read(&inode->i_count), fattr->valid); - if (!nfs_fileid_valid(nfsi, fattr)) { + /* No fileid? Just exit */ + if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) + return 0; + /* Has the inode gone and changed behind our back? */ + if (nfsi->fileid != fattr->fileid) { + /* Is this perhaps the mounted-on fileid? */ + if ((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) && + nfsi->fileid == fattr->mounted_on_fileid) + return 0; printk(KERN_ERR "NFS: server %s error: fileid changed\n" "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n", NFS_SERVER(inode)->nfs_client->cl_hostname, From patchwork Tue Aug 13 14:28:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11092345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 057E31395 for ; Tue, 13 Aug 2019 14:30:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8C0D286A0 for ; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCC57286A1; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61AAE2869F for ; Tue, 13 Aug 2019 14:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728227AbfHMOaQ (ORCPT ); Tue, 13 Aug 2019 10:30:16 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40141 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729151AbfHMOaQ (ORCPT ); Tue, 13 Aug 2019 10:30:16 -0400 Received: by mail-ot1-f65.google.com with SMTP id c34so33195957otb.7 for ; Tue, 13 Aug 2019 07:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NDJE5CZ+uCjqNTTP+cuonA/hlMWMDmWKmwaE8OcBxbQ=; b=mZgTtvlqQk/GEbUI6yc4ktldB0mxqblGsNZ05qBCOubzSdeZqQVCwbumH40ISuv55J X88v0Yw7TUQkmEtpzcYv7hLrqFrDDiowY7//P9Kv1e20+SdFkKK8S9trG1WxEJ4wRpl5 0E/Q8HgIAC3Sy3EQQxNXNEF3vgUUEIlhy8QFE6DZ4q6Lw1xF0pCCMpxC6++qImpeHAPm wEL3xtpCYpo0zypNlWL6fSaWGRghCRJZGSc9DI2rL8ArZfF9XGv8Vl78Efoekmz9mqSN Ml0otJwa6LDIWAmwoak4xVnfLAjxskpXEki9Epnxa6ANPsmxoAxMdhH35BnEWhxYWyrB phbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NDJE5CZ+uCjqNTTP+cuonA/hlMWMDmWKmwaE8OcBxbQ=; b=EAUUJKE3nj3kM9/mqtT2VCSHFdyDRjkgvFENaiXPz5gnjtjLq/ApX7GZJnqTNZglHV HUHCr2YtGLUBs76aJ6dfcwFq5j6vx2F83m5YCry8u+OGDr/9+JOomEdQrJLBjaOMWhX1 pU9/D1qKAtwLh9ylG7VPAGZFhn1T1LPdyxc/Ey/oVFUZqJzG53jrJlV1bCjpyYYHjodY yFZfetEOEFh9aKy/oSYq4fgjpcJfeUWd3pRU5OgyhZgY81BqKDT8Nl3v/te8rJki1sW/ 62bmDV0c3ADBBzUEc3fe8gj5VSUf7GdroVR1AtdwpbKXPsKLgKY8bTv5zrHI5Uxq0zs2 uXpA== X-Gm-Message-State: APjAAAXLjgIICSS1ojGNeJR0YJtF6PvO1vQAUYLBKiF+yfstV0/ASj9+ G9FsK4msmw8wwdfVDwfjzJkTtp0= X-Google-Smtp-Source: APXvYqwI9slPQqMy/iSI7Txz103yIZHxXRoKp17NI2TtGnrZwMy2faay9NYpiCNNvWICW0HkJTOkZw== X-Received: by 2002:a5d:8f8a:: with SMTP id l10mr14561070iol.306.1565706615299; Tue, 13 Aug 2019 07:30:15 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o6sm9429161ioh.22.2019.08.13.07.30.14 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 07:30:14 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 2/5] NFSv4: Fix return values for nfs4_file_open() Date: Tue, 13 Aug 2019 10:28:03 -0400 Message-Id: <20190813142806.123268-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190813142806.123268-1-trond.myklebust@hammerspace.com> References: <20190813142806.123268-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we are translating RPC level errors such as timeouts, as well as interrupts etc into EOPENSTALE, which forces a single replay of the open attempt. What we actually want to do is force the replay only in the cases where the returned error indicates that the file may have changed on the server. So the fix is to spell out the exact set of errors where we want to return EOPENSTALE. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 96db471ca2e5..339663d04bf8 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -73,13 +73,13 @@ nfs4_file_open(struct inode *inode, struct file *filp) if (IS_ERR(inode)) { err = PTR_ERR(inode); switch (err) { - case -EPERM: - case -EACCES: - case -EDQUOT: - case -ENOSPC: - case -EROFS: - goto out_put_ctx; default: + goto out_put_ctx; + case -ENOENT: + case -ESTALE: + case -EISDIR: + case -ENOTDIR: + case -ELOOP: goto out_drop; } } From patchwork Tue Aug 13 14:28:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11092347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01C8B14F7 for ; Tue, 13 Aug 2019 14:30:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B3E28681 for ; Tue, 13 Aug 2019 14:30:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC3AE286A4; Tue, 13 Aug 2019 14:30:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9870C2869F for ; Tue, 13 Aug 2019 14:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbfHMOaS (ORCPT ); Tue, 13 Aug 2019 10:30:18 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:45704 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729151AbfHMOaR (ORCPT ); Tue, 13 Aug 2019 10:30:17 -0400 Received: by mail-ot1-f65.google.com with SMTP id m24so20201154otp.12 for ; Tue, 13 Aug 2019 07:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=POup7bPke7kznuQqaIq7NKUgApio1QYHx8UAmRlyVl8=; b=WePIN+Hk4Gwz71QB16Ruof9OXPbGTs9ort47eBiQCqcsZI7bNG/WYdUYs8zb5e1YCS +A3XmR/BUO2nbxHABBaFqL/+AhnEnBE6m2ChkvAWNcAnzRuV/XXhNwfygS3G2/I7AX2r aiolAQPZLfH/XSOwUYoktbfoGIe6xNqDwych+nhqAXYAulLuyHeToFLL4VYmPXVBkQtJ Oc5YMABkQSJs8c4EEtzEyBluyjao/Jh9NgA8+84gQpl80UIpyGSoofgZpfopr2EbGRrJ 3Tm5g0k68Wcwv96X9CrhMqraYF3SeC/2Yj6sbC7zKDucLRVGE+95/KM3fhJ7APHAtQGr dHmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=POup7bPke7kznuQqaIq7NKUgApio1QYHx8UAmRlyVl8=; b=VL61iJOqZPPAp9Oo5DkB9SoMi6lfe7e1G/uI5UlcYXkI14p7xR0Exi/lvoubVh4t9X NNpNz/4H6iItSLZYDyIG9BJFrd8uEuqSQx5ov0TQIRJiu3JjPxaA0SAF+fEiYVAV+u9k fKc1tpO1pD/qsa1yL0RCT22xg3yw9eWNrWx2NarBfppVE+ORWdtVsVtXoIsrQbQBq2sN 9Ybzgyd0jyqtM2Dk3qvaMstJk+xJ7VUYO7lZKSsSgcycWxC7ofM41AjLbVSEdtXdnwva dQFaD5iOYTryGzhaeU8r0zPDjQRgYpr0I3P+OfTdBHJ2I32x6vmlmkbW6/8Zq/XJTyzc Y8nw== X-Gm-Message-State: APjAAAXQJs7Ypew6FMKlIx/dtAN48Wc6RNiLsUvNyHaYqE8V1UeasrWU ZCes9MTN7T9fi1FZKVIW/MxLvG4= X-Google-Smtp-Source: APXvYqwhuBJfppnQP8z3p4iPtvGB61iYoybkXdI5TE3MIcml+r3h/Re5iOHYizELO1zONiYW+84O0g== X-Received: by 2002:a6b:7619:: with SMTP id g25mr1510634iom.92.1565706616317; Tue, 13 Aug 2019 07:30:16 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o6sm9429161ioh.22.2019.08.13.07.30.15 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 07:30:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 3/5] NFSv4: Fix return value in nfs_finish_open() Date: Tue, 13 Aug 2019 10:28:04 -0400 Message-Id: <20190813142806.123268-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190813142806.123268-2-trond.myklebust@hammerspace.com> References: <20190813142806.123268-1-trond.myklebust@hammerspace.com> <20190813142806.123268-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the file turns out to be of the wrong type after opening, we want to revalidate the path and retry, so return EOPENSTALE rather than ESTALE. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 8d501093660f..0adfd8840110 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1487,7 +1487,7 @@ static int nfs_finish_open(struct nfs_open_context *ctx, if (S_ISREG(file->f_path.dentry->d_inode->i_mode)) nfs_file_set_open_context(file, ctx); else - err = -ESTALE; + err = -EOPENSTALE; out: return err; } From patchwork Tue Aug 13 14:28:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11092349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6490614F7 for ; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 566B4286A1 for ; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B0EE286B5; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDD71286A1 for ; Tue, 13 Aug 2019 14:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729331AbfHMOaT (ORCPT ); Tue, 13 Aug 2019 10:30:19 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:40156 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729151AbfHMOaT (ORCPT ); Tue, 13 Aug 2019 10:30:19 -0400 Received: by mail-ot1-f68.google.com with SMTP id c34so33196526otb.7 for ; Tue, 13 Aug 2019 07:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=JghjEh3a0dlK8vQPtuVSZDHMvcywHIeqQMVlMe6XsHs=; b=IbqUw0j8V1j2Qcbi+/Zazhr2BoR8DPkUL5MYR4husAfsAip8l0NC3GcQ3jztxiKZaS URPoNakrfNDNztWhiJlWiKU0AUs2GzGRizrGraYuFad/gbYwBet+zn3KA3kls6LBX6cA Hc8pQrsOtV+hEZ66F4oL2L2xLBjbFWU4Ds7HDzA8RsjwLe0pLIQ5TDEanbFTV0vlcEqf /zUIGMVcCqod9aX1N0ZaRXazrbC/yioTBcrzHZL0625rdIlC3Pf2z2wHZ5aaAAG5l7Mf Sg3660Q03b1Jdsci11m8y2CYWipeNXbT9vNMM16ciy1ywtnMxxBdnFT/wZ/p52IdCEvO ib4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JghjEh3a0dlK8vQPtuVSZDHMvcywHIeqQMVlMe6XsHs=; b=qWdrQbGHSJ08MxNWPD4qf2lTbD63d77Wxuymz4qgprGRZo8GFJvDQ+rZnQDM17hcSB CQszZSm5ba7Asucxd1d8hc65IqSpKwd4zjNGrRqYX3FsIF8kB1yW8wuNTZwBnna2IE2E NQKI/ezzCaeUvb1PYusU57TKdhxB/Rt/TQLGVyRb1OuFf4OlAN+SQ4kOcdnobgh4280i 9n9ouBDD9JUrRW92wa4NZyowVsmb7d7chhT1bn+LhQf0KWQopgHxxQ0zS3NEX0+vKJKn eoI8OqF++KoCNwnabMGac1Is/Y5ar/gCXp16tmn/VbCM61P6Y8LmDkpnmf0Q6Q8Cxopi ExPg== X-Gm-Message-State: APjAAAV46GpaqRx1efX3/pknxGGLA8Fn+knxGV6ORtyd/FE29aucFahw 4JmiXP3WbGLJ26mbBER+YLPamJY= X-Google-Smtp-Source: APXvYqyG0KB8WUu/sB5V57IPZY0XkhwEfLyAZSo3A43gs8ZnXU7IATtjXzNIFM5s31cZtx6IYBfPTw== X-Received: by 2002:a5d:9747:: with SMTP id c7mr7477131ioo.244.1565706617562; Tue, 13 Aug 2019 07:30:17 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o6sm9429161ioh.22.2019.08.13.07.30.16 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 07:30:16 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 4/5] NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend() Date: Tue, 13 Aug 2019 10:28:05 -0400 Message-Id: <20190813142806.123268-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190813142806.123268-3-trond.myklebust@hammerspace.com> References: <20190813142806.123268-1-trond.myklebust@hammerspace.com> <20190813142806.123268-2-trond.myklebust@hammerspace.com> <20190813142806.123268-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the attempt to resend the pages fails, we need to ensure that we clean up those pages that were not transmitted. Fixes: d600ad1f2bdb ("NFS41: pop some layoutget errors to application") Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.5+ --- fs/nfs/pagelist.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index ed4e1b07447b..15c254753f88 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1251,20 +1251,22 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc, int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr) { - LIST_HEAD(failed); + LIST_HEAD(pages); desc->pg_io_completion = hdr->io_completion; desc->pg_dreq = hdr->dreq; - while (!list_empty(&hdr->pages)) { - struct nfs_page *req = nfs_list_entry(hdr->pages.next); + list_splice_init(&hdr->pages, &pages); + while (!list_empty(&pages)) { + struct nfs_page *req = nfs_list_entry(pages.next); if (!nfs_pageio_add_request(desc, req)) - nfs_list_move_request(req, &failed); + break; } nfs_pageio_complete(desc); - if (!list_empty(&failed)) { - list_move(&failed, &hdr->pages); - return desc->pg_error < 0 ? desc->pg_error : -EIO; + if (!list_empty(&pages)) { + int err = desc->pg_error < 0 ? desc->pg_error : -EIO; + hdr->completion_ops->error_cleanup(&pages, err); + return err; } return 0; } From patchwork Tue Aug 13 14:28:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11092351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8FF91395 for ; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7E72286AE for ; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC931286AA; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 715522869F for ; Tue, 13 Aug 2019 14:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729151AbfHMOaT (ORCPT ); Tue, 13 Aug 2019 10:30:19 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45724 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729304AbfHMOaT (ORCPT ); Tue, 13 Aug 2019 10:30:19 -0400 Received: by mail-ot1-f66.google.com with SMTP id m24so20201652otp.12 for ; Tue, 13 Aug 2019 07:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SiL+a7lRBWw/WXuYuTmPPutdryUa+IHhCb6r6X2Z8Z4=; b=LVlvTGVLGFmcnZ2trCrIFNFC3W7iPwFqtLt4S2xvUoAq1Vcb+SuM7phbi+XNdBh5Pw SVzjGMM3Pr8AgjTFUkA+0DosYN5WUiu7RID3AH1a34qXYtTNTj3FGhBfZFlbjangmf4z nyhRi1OG6NPL2ghR90sjhqjkHMOrmERlzrI7Qzs0e3OaAwBd04ijJTL6aQ5QFkMYd4FL WErKjj5arFybyTmMMTxYmTyOrca5ogiqHn42F84jpaoAzMMJa6EbdPF86mobLA2p1gaj ZaTG4tTc85laodWImaPS6rPy+we9Q2WO5QGH2TTPWnDkPmzGOYiq004xpFv6qQau7TAU 6/Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SiL+a7lRBWw/WXuYuTmPPutdryUa+IHhCb6r6X2Z8Z4=; b=qaTcgdtiqGXQhQ7PwvmaIEJkqJcS0pg2CLCmW8Z6n4Yhk7Grt7L1DeBGlQbL/DQ/Jy ZSRPJl5OsD77h8dzoLxg/FSzGDCV2s6fS4gmEw6gKDE5F3fqV4vl5fBvcwBOxZz4vTwC LD57z0TmLTXsiosRSDqPIZkYJF9gs/eqW2sQIQu0k5Xax7qeJkaD9gVvbEuHKaNakODH fq73mCjJtvNie9jRdAPz/IjQCG2VAoZUHhyK5GoOsPaLe02lLElbSflC6XnZ0rvO9p+B Q+xMBZLbyDhlfmGFQ8aqEyiO8gBEekUJsOkLiVco3hV8y28ESLYsNWEmrPJZBlrztQlj 0BeQ== X-Gm-Message-State: APjAAAU/TZrXYxPIhbLyHhJbzivsgZ7lJoD89MJDmQ6a6ydnlCEyDHN2 bf7426aldVwY2O2SKBaRSfKPKRM= X-Google-Smtp-Source: APXvYqyzSKQxkMcsSg7EAntzsbBbQEj3xKhZcuqah7INX+5Koe8L4X/v6FWUTA5N00X2T/LRvJ7uTQ== X-Received: by 2002:a02:cc6c:: with SMTP id j12mr15419354jaq.29.1565706618360; Tue, 13 Aug 2019 07:30:18 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o6sm9429161ioh.22.2019.08.13.07.30.17 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 07:30:17 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 5/5] NFS: Ensure O_DIRECT reports an error if the bytes read/written is 0 Date: Tue, 13 Aug 2019 10:28:06 -0400 Message-Id: <20190813142806.123268-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190813142806.123268-4-trond.myklebust@hammerspace.com> References: <20190813142806.123268-1-trond.myklebust@hammerspace.com> <20190813142806.123268-2-trond.myklebust@hammerspace.com> <20190813142806.123268-3-trond.myklebust@hammerspace.com> <20190813142806.123268-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the attempt to resend the I/O results in no bytes being read/written, we must ensure that we report the error. Signed-off-by: Trond Myklebust Fixes: 0a00b77b331a ("nfs: mirroring support for direct io") Cc: stable@vger.kernel.org # v3.20+ --- fs/nfs/direct.c | 27 ++++++++++++++++++--------- fs/nfs/pagelist.c | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 0cb442406168..222d7115db71 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -401,15 +401,21 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) unsigned long bytes = 0; struct nfs_direct_req *dreq = hdr->dreq; - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - spin_lock(&dreq->lock); - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && (hdr->good_bytes == 0)) + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - else + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) nfs_direct_good_bytes(dreq, hdr); + if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) + dreq->error = 0; + spin_unlock(&dreq->lock); while (!list_empty(&hdr->pages)) { @@ -782,16 +788,19 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) bool request_commit = false; struct nfs_page *req = nfs_list_entry(hdr->pages.next); - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - nfs_init_cinfo_from_dreq(&cinfo, dreq); spin_lock(&dreq->lock); if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - if (dreq->error == 0) { + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) { nfs_direct_good_bytes(dreq, hdr); if (nfs_write_need_commit(hdr)) { if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 15c254753f88..56cefa0ab804 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1266,6 +1266,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, if (!list_empty(&pages)) { int err = desc->pg_error < 0 ? desc->pg_error : -EIO; hdr->completion_ops->error_cleanup(&pages, err); + nfs_set_pgio_error(hdr, err, hdr->io_start); return err; } return 0;