]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/ext4/inode.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
[mirror_ubuntu-jammy-kernel.git] / fs / ext4 / inode.c
index 82298c63ea6d6c904cdad8bb32e0f40e801b9785..c7f77c643008558938ed0cf5d23698863d1ca931 100644 (file)
@@ -5625,25 +5625,22 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
                        up_write(&EXT4_I(inode)->i_data_sem);
                        ext4_journal_stop(handle);
                        if (error) {
-                               if (orphan)
+                               if (orphan && inode->i_nlink)
                                        ext4_orphan_del(NULL, inode);
                                goto err_out;
                        }
                }
-               if (!shrink)
+               if (!shrink) {
                        pagecache_isize_extended(inode, oldsize, inode->i_size);
-
-               /*
-                * Blocks are going to be removed from the inode. Wait
-                * for dio in flight.  Temporarily disable
-                * dioread_nolock to prevent livelock.
-                */
-               if (orphan) {
-                       if (!ext4_should_journal_data(inode)) {
-                               inode_dio_wait(inode);
-                       } else
-                               ext4_wait_for_tail_page_commit(inode);
+               } else {
+                       /*
+                        * Blocks are going to be removed from the inode. Wait
+                        * for dio in flight.
+                        */
+                       inode_dio_wait(inode);
                }
+               if (orphan && ext4_should_journal_data(inode))
+                       ext4_wait_for_tail_page_commit(inode);
                down_write(&EXT4_I(inode)->i_mmap_sem);
 
                rc = ext4_break_layouts(inode);