Skip to content

Commit 326efb4

Browse files
Martin Brandenburggregkh
authored andcommitted
orangefs: fix deadlock; do not write i_size in read_iter
commit 6793f1c 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 <martin@omnibond.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Mike Marshall <hubcap@omnibond.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d529ba9 commit 326efb4

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

fs/orangefs/file.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ ssize_t orangefs_inode_read(struct inode *inode,
446446
static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
447447
{
448448
struct file *file = iocb->ki_filp;
449-
loff_t pos = *(&iocb->ki_pos);
449+
loff_t pos = iocb->ki_pos;
450450
ssize_t rc = 0;
451451

452452
BUG_ON(iocb->private);
@@ -486,9 +486,6 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
486486
}
487487
}
488488

489-
if (file->f_pos > i_size_read(file->f_mapping->host))
490-
orangefs_i_size_write(file->f_mapping->host, file->f_pos);
491-
492489
rc = generic_write_checks(iocb, iter);
493490

494491
if (rc <= 0) {
@@ -502,7 +499,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
502499
* pos to the end of the file, so we will wait till now to set
503500
* pos...
504501
*/
505-
pos = *(&iocb->ki_pos);
502+
pos = iocb->ki_pos;
506503

507504
rc = do_readv_writev(ORANGEFS_IO_WRITE,
508505
file,

fs/orangefs/orangefs-kernel.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -566,17 +566,6 @@ do { \
566566
sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE; \
567567
} while (0)
568568

569-
static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size)
570-
{
571-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
572-
inode_lock(inode);
573-
#endif
574-
i_size_write(inode, i_size);
575-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
576-
inode_unlock(inode);
577-
#endif
578-
}
579-
580569
static inline void orangefs_set_timeout(struct dentry *dentry)
581570
{
582571
unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;

0 commit comments

Comments
 (0)