[PATCH] sheepdog: fine grained locking in write path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Current sheepdog driver has a big write lock section. It harms write
performance significantly. This patch removes a needless big write
lock section with checking submitted requests can cause COW or
not. The write performance can be improved significantly.

In a case of 4k rand write by fio:
 - before: 1144 IOPS
 - after:  19074 IOPS

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@xxxxxxxxxxxxx>
---
 usr/bs_sheepdog.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/usr/bs_sheepdog.c b/usr/bs_sheepdog.c
index 0838009..9b5b259 100644
--- a/usr/bs_sheepdog.c
+++ b/usr/bs_sheepdog.c
@@ -876,6 +876,7 @@ static int sd_io(struct sheepdog_access_info *ai, int write, char *buf, int len,
 	uint16_t flags = 0;
 	int need_update_inode = 0, need_reload_inode;
 	int nr_copies = ai->inode.nr_copies;
+	int need_write_lock, check_idx;
 
 	goto do_req;
 
@@ -891,7 +892,18 @@ reload_in_read_path:
 	pthread_rwlock_unlock(&ai->inode_lock);
 
 do_req:
-	if (write)
+	need_write_lock = 0;
+	vid = ai->inode.vdi_id;
+
+	for (check_idx = idx; check_idx < max; check_idx++) {
+		if (ai->inode.data_vdi_id[check_idx] == vid)
+			continue;
+
+		need_write_lock = 1;
+		break;
+	}
+
+	if (need_write_lock)
 		pthread_rwlock_wrlock(&ai->inode_lock);
 	else
 		pthread_rwlock_rdlock(&ai->inode_lock);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux