From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225fIjL5A1W/xPEOCRy2MptKRuQdKpc1qlWIxp5mQksFU52Dfg5SweaM5oiZf4i9WzCCcUm8 ARC-Seal: i=1; a=rsa-sha256; t=1517257019; cv=none; d=google.com; s=arc-20160816; b=HPG6MDzN0sPGlPW+G6y/nTVjkwB6V+VDgD6ATx4Wl9e4ZLeSj+6vl4oqjF/rkce8ah 8Q3GdltAianR/DjIaq147IX7EiBtB7AiNyo8ZLYsCa+cddLHyBP5CLwckIR3OJs+CXHV uRKnzV+MHIV0v4JeXQsBOwdwJSygqf+acWbCLU76y3QfzqSetkdQ1hFUwyQjjiXJISR3 WbaaC+xK//7znmWha+xj3xY499xvfizjGJjc5W+5vBmjhNtzNGMmkOl/G28tgm6Om8PW ewG9NC/M7h6RKn0tcwYTZD5K06yKZtT6svuPRRVMh5ibqRvZbXdmhl3hcDyHF/RfwJu/ Q3rw== 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=wY8zJBdZ+9VoWdVjOTPBzJD07weN1Nu2PONJv7mxNls=; b=TVzGrl8oMEnzj+MvofhjX1MGC2o/4KyHMrphJknjrjv9UF1GJ4OTEPlpWXbQSN1mUD khM+3TDGluffkkrGxs5xFCgaKxDP4nzxTtY1SEgOMfkdponw7XjqIYiYjitwCcTPiyRL wQbozgHTqPLlL3wnW6gZ+/Tk6UdOI+ozvmpsN9VO0uzsV9LCDNeakviTbykIH2/HBbuj YcvrahhV0u7HkBnnKsECBNO+ljL40gEhLPUmTGIAhwLHlPFO4fXxNfMrbBzWOB41JR81 sla8A4+XI1PG1grq6nb3jXqmtt5ikxv5NM/nUqV56mmWmFREUaTmO1DjIxk9uyhDX2kX +/UQ== 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.14 13/71] orangefs: fix deadlock; do not write i_size in read_iter Date: Mon, 29 Jan 2018 13:56:41 +0100 Message-Id: <20180129123828.172909806@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@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?1590959297102452172?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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); @@ -486,9 +486,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) { @@ -502,7 +499,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 @@ -566,17 +566,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;