Merge tag 'fs_for_v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack...
[platform/kernel/linux-starfive.git] / fs / fs-writeback.c
index 00e4813..a21d8f1 100644 (file)
@@ -1712,6 +1712,10 @@ static int writeback_single_inode(struct inode *inode,
         */
        if (!(inode->i_state & I_DIRTY_ALL))
                inode_cgwb_move_to_attached(inode, wb);
+       else if (!(inode->i_state & I_SYNC_QUEUED) &&
+                (inode->i_state & I_DIRTY))
+               redirty_tail_locked(inode, wb);
+
        spin_unlock(&wb->list_lock);
        inode_sync_complete(inode);
 out:
@@ -1775,11 +1779,12 @@ static long writeback_sb_inodes(struct super_block *sb,
        };
        unsigned long start_time = jiffies;
        long write_chunk;
-       long wrote = 0;  /* count both pages and inodes */
+       long total_wrote = 0;  /* count both pages and inodes */
 
        while (!list_empty(&wb->b_io)) {
                struct inode *inode = wb_inode(wb->b_io.prev);
                struct bdi_writeback *tmp_wb;
+               long wrote;
 
                if (inode->i_sb != sb) {
                        if (work->sb) {
@@ -1855,7 +1860,9 @@ static long writeback_sb_inodes(struct super_block *sb,
 
                wbc_detach_inode(&wbc);
                work->nr_pages -= write_chunk - wbc.nr_to_write;
-               wrote += write_chunk - wbc.nr_to_write;
+               wrote = write_chunk - wbc.nr_to_write - wbc.pages_skipped;
+               wrote = wrote < 0 ? 0 : wrote;
+               total_wrote += wrote;
 
                if (need_resched()) {
                        /*
@@ -1877,7 +1884,7 @@ static long writeback_sb_inodes(struct super_block *sb,
                tmp_wb = inode_to_wb_and_lock_list(inode);
                spin_lock(&inode->i_lock);
                if (!(inode->i_state & I_DIRTY_ALL))
-                       wrote++;
+                       total_wrote++;
                requeue_inode(inode, tmp_wb, &wbc);
                inode_sync_complete(inode);
                spin_unlock(&inode->i_lock);
@@ -1891,14 +1898,14 @@ static long writeback_sb_inodes(struct super_block *sb,
                 * bail out to wb_writeback() often enough to check
                 * background threshold and other termination conditions.
                 */
-               if (wrote) {
+               if (total_wrote) {
                        if (time_is_before_jiffies(start_time + HZ / 10UL))
                                break;
                        if (work->nr_pages <= 0)
                                break;
                }
        }
-       return wrote;
+       return total_wrote;
 }
 
 static long __writeback_inodes_wb(struct bdi_writeback *wb,