Skip to content

Commit 6793f1c

Browse files
Martin Brandenburgtorvalds
authored andcommitted
orangefs: fix deadlock; do not write i_size in read_iter
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> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6e20630 commit 6793f1c

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
@@ -452,7 +452,7 @@ ssize_t orangefs_inode_read(struct inode *inode,
452452
static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
453453
{
454454
struct file *file = iocb->ki_filp;
455-
loff_t pos = *(&iocb->ki_pos);
455+
loff_t pos = iocb->ki_pos;
456456
ssize_t rc = 0;
457457

458458
BUG_ON(iocb->private);
@@ -492,9 +492,6 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
492492
}
493493
}
494494

495-
if (file->f_pos > i_size_read(file->f_mapping->host))
496-
orangefs_i_size_write(file->f_mapping->host, file->f_pos);
497-
498495
rc = generic_write_checks(iocb, iter);
499496

500497
if (rc <= 0) {
@@ -508,7 +505,7 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
508505
* pos to the end of the file, so we will wait till now to set
509506
* pos...
510507
*/
511-
pos = *(&iocb->ki_pos);
508+
pos = iocb->ki_pos;
512509

513510
rc = do_readv_writev(ORANGEFS_IO_WRITE,
514511
file,

fs/orangefs/orangefs-kernel.h

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

536-
static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size)
537-
{
538-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
539-
inode_lock(inode);
540-
#endif
541-
i_size_write(inode, i_size);
542-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
543-
inode_unlock(inode);
544-
#endif
545-
}
546-
547536
static inline void orangefs_set_timeout(struct dentry *dentry)
548537
{
549538
unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;

0 commit comments

Comments
 (0)