From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225tidb3gwRIelZ+fKk/Vqe6HaTw8QC8rxTmXHICcjeuUQO5hrDSjirAQ8etH4KgJNmiif0i ARC-Seal: i=1; a=rsa-sha256; t=1517256713; cv=none; d=google.com; s=arc-20160816; b=kfUD0jhuow2aVR1Bh6pnStvb2xk8Ih/QROyZfM+pVpu6GJrkGhrrCs9FETuT5qXNUO HvU+HuvgNEQ9sNKSlo0ONcrWiCKphq9hhf1E03IQunxn94rR/mMewHplHkrdinGkcRXs 4Qq2yHkAiEnYc2/ZIt/pTEY6gtOF6IjMohEMJ9w2u5BxYPALHwG7XdcXqiJO+bxoD/fg pMY4s1tZWB8sTqCLI3ILK6h26kfToxBJ2G7fYIVDedsdkXJi82q3Q+pCC9J9drHpdq+o lzDamfYWvFolJN/buNbbzCIruGPLfuIdQRmeYKuET7AvPLxpm8VVZj5tBjMVsajcdzsx b9tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=G84IuL2WCvHR63TdLCisCk4ncEDP4gXF7vLapb/gwDo=; b=dms5K3qGBRSDVu7UP/lRQE1QH+kTTEc7lEn+thyIqMVSBEckru4ZMn9Fa2yh2dyJum 5Vzptg/oDDSslZoMIBqJ2GCl1OZIja/dk0+08wrf3w9+f48zxWJE3AzdX3Twiyhql7dZ BLzM8ZUf8kvTqjjkjyRx+lvG3Qoh7yP4MZGUg3wVFA9w/ZLLtUBosd7mwJjvUdp4P9Iq VQKpwXY+2Uetr4lPPoHA7nllWxhPgh5BymqupCl3GV3yYxbOSBme0r88+xyK3163jyqy JHX3V63xhXi9Ye5oL1ddOKlELu+u1BK3pDQIDX7Kua9jT2rFm6/QpPur0jW50IWDsWWr 2l5g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958975009466635?= X-GMAIL-MSGID: =?utf-8?q?1590958975009466635?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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;