ocfs2: make metadata estimation accurate and clear
authorChangwei Ge <ge.changwei@h3c.com>
Thu, 1 Feb 2018 00:15:02 +0000 (16:15 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Feb 2018 01:18:35 +0000 (17:18 -0800)
Current code assume that ::w_unwritten_list always has only one item on.
This is not right and hard to get understood.  So improve how to count
unwritten item.

Link: http://lkml.kernel.org/r/1515479070-32653-1-git-send-email-ge.changwei@h3c.com
Signed-off-by: Changwei Ge <ge.changwei@h3c.com>
Reported-by: John Lightsey <john@nixnuts.net>
Tested-by: John Lightsey <john@nixnuts.net>
Cc: Mark Fasheh <mfasheh@versity.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Changwei Ge <ge.changwei@h3c.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/aops.c

index d1516327b7875c9ce3e948c66a6620d9b5b8d5da..256986aca8df66b34746b86d70a49af4977157ed 100644 (file)
@@ -797,6 +797,7 @@ struct ocfs2_write_ctxt {
        struct ocfs2_cached_dealloc_ctxt w_dealloc;
 
        struct list_head                w_unwritten_list;
+       unsigned int                    w_unwritten_count;
 };
 
 void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages)
@@ -1386,6 +1387,7 @@ retry:
        desc->c_clear_unwritten = 0;
        list_add_tail(&new->ue_ip_node, &oi->ip_unwritten_list);
        list_add_tail(&new->ue_node, &wc->w_unwritten_list);
+       wc->w_unwritten_count++;
        new = NULL;
 unlock:
        spin_unlock(&oi->ip_lock);
@@ -2256,7 +2258,7 @@ static int ocfs2_dio_wr_get_block(struct inode *inode, sector_t iblock,
                ue->ue_phys = desc->c_phys;
 
                list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list);
-               dwc->dw_zero_count++;
+               dwc->dw_zero_count += wc->w_unwritten_count;
        }
 
        ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc);