Received: by 10.223.176.5 with SMTP id f5csp3410159wra; Mon, 29 Jan 2018 12:46:52 -0800 (PST) X-Google-Smtp-Source: AH8x225WF1zVpSmh3o/0Iah1KGxc4j/rhJJpn3DSknXnHesR/uUHk1U/BIOQghvbyaW5SNjmepBK X-Received: by 10.98.46.2 with SMTP id u2mr28037575pfu.30.1517258812039; Mon, 29 Jan 2018 12:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517258812; cv=none; d=google.com; s=arc-20160816; b=NAaZLz4p8Fg761Od90028sRT8MfuHP1ml2AT2JvKcMMXmJOCtdB6o9L4jjDpul1w5p jJHBPJimQ6QmFT7qZQMgDiPtmNMF0OrnsAWJaC/N6Z4Bm1yGVAVg/N7L+lENHD3DkbSP NbfVjNRF/py61a2SJUOcUDiKp4l5z+VtEWSDCX3jCqmnM5eM4qmcoSul/pLfZN2J4yhy EkbONLiYe3Ow4LydRYNjp+3AYetqOFt1TYK8hRX68aPnRhNEu66m+5hjqwXRAR1WBSKy woaqrQPzIDK1T7wSgfW+5kZSVBpaifzhJUVirxRj3FrKJjZnMX01FyB97XODum1MbDq3 XJDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=G84IuL2WCvHR63TdLCisCk4ncEDP4gXF7vLapb/gwDo=; b=ZbDN1WI+r8udOOC9kXyHMWq11ZDz3X6bp3TdIyh8FlI1Dpywjucn244u0crJ58tml1 BALIyLPMtBkZqpJfHPq/3+atPltfk/kM/3dMP98r+loBFB/mMW13r4HykTBxJ3I46ApM hWNEY0G4D97y5jhjuEBUi9Htmx/C0sWMc5FIoTgghq/00UHNDX7gSIK44uZuXfhFhX38 Pk4gp/vbr3I2NhNstYVms9jXSPkVio5pLkviuqzCrZ7o1k8inSnblk03yl94UnrxRjaX S6bZyIuvAVXFb9o6A1QPN+nU7ctYyycgsMYdNkoY4upAUiVlEfMpy3iD/yo6UyrywO6F /58Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j91-v6si9892482pld.479.2018.01.29.12.46.37; Mon, 29 Jan 2018 12:46:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753865AbeA2UL6 (ORCPT + 99 others); Mon, 29 Jan 2018 15:11:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33438 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753796AbeA2ULw (ORCPT ); Mon, 29 Jan 2018 15:11:52 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 14CB62F82; Mon, 29 Jan 2018 13:05:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Brandenburg , Al Viro , Mike Marshall , Linus Torvalds Subject: [PATCH 4.9 29/66] orangefs: fix deadlock; do not write i_size in read_iter Date: Mon, 29 Jan 2018 13:56:53 +0100 Message-Id: <20180129123841.360857019@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Brandenburg commit 6793f1c450b1533a5e9c2493490de771d38b24f9 upstream. After do_readv_writev, the inode cache is invalidated anyway, so i_size will never be read. It will be fetched from the server which will also know about updates from other machines. Fixes deadlock on 32-bit SMP. See https://marc.info/?l=linux-fsdevel&m=151268557427760&w=2 Signed-off-by: Martin Brandenburg Cc: Al Viro Cc: Mike Marshall Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/orangefs/file.c | 7 ++----- fs/orangefs/orangefs-kernel.h | 11 ----------- 2 files changed, 2 insertions(+), 16 deletions(-) --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -446,7 +446,7 @@ ssize_t orangefs_inode_read(struct inode static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; - loff_t pos = *(&iocb->ki_pos); + loff_t pos = iocb->ki_pos; ssize_t rc = 0; BUG_ON(iocb->private); @@ -485,9 +485,6 @@ static ssize_t orangefs_file_write_iter( } } - if (file->f_pos > i_size_read(file->f_mapping->host)) - orangefs_i_size_write(file->f_mapping->host, file->f_pos); - rc = generic_write_checks(iocb, iter); if (rc <= 0) { @@ -501,7 +498,7 @@ static ssize_t orangefs_file_write_iter( * pos to the end of the file, so we will wait till now to set * pos... */ - pos = *(&iocb->ki_pos); + pos = iocb->ki_pos; rc = do_readv_writev(ORANGEFS_IO_WRITE, file, --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h @@ -570,17 +570,6 @@ do { \ sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE; \ } while (0) -static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size) -{ -#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) - inode_lock(inode); -#endif - i_size_write(inode, i_size); -#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) - inode_unlock(inode); -#endif -} - static inline void orangefs_set_timeout(struct dentry *dentry) { unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;