tags 841144 + patch
thanks

I'm attaching the patch we used at cPanel to fix this issue with the
4.9 Debian Stable kernel.

I forwarded a version of this patch to the ocfs2-devel mailing list
already.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: John Lightsey <j...@cpanel.net>
Date: Mon, 20 Nov 2017 13:55:05 -0600
Subject: [PATCH] Fix OCFS2 extent split estimation for dio allocators locking.

The dw_zero_count tracking was assuming that w_unwritten_list would
always contain one element. The actual count is now tracked whenever
the list is extended.
---
 fs/ocfs2/aops.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index f2961b1..18a311d 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -775,6 +775,8 @@ 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)
@@ -864,6 +866,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp,
 
 	ocfs2_init_dealloc_ctxt(&wc->w_dealloc);
 	INIT_LIST_HEAD(&wc->w_unwritten_list);
+	wc->w_unwritten_count = 0;
 
 	*wcp = wc;
 
@@ -1364,6 +1367,7 @@ static int ocfs2_unwritten_check(struct inode *inode,
 	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);
@@ -2238,7 +2242,7 @@ static int ocfs2_dio_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, NULL, wc);
-- 
2.11.0

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to