[PATCH 1/3] bs_sheepdog.c: partial update of inode object for optimizing COW

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

 



Current bs_sheepdog.c updates whole inode object (metadata of
sheepdog) when COW occurs. This patch reduces the traffic of update.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@xxxxxxxxxxxxx>
---
 usr/bs_sheepdog.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/usr/bs_sheepdog.c b/usr/bs_sheepdog.c
index fcd2557..87c7986 100644
--- a/usr/bs_sheepdog.c
+++ b/usr/bs_sheepdog.c
@@ -604,14 +604,28 @@ static int update_inode(struct sheepdog_access_info *ai)
 {
 	int ret = 0;
 	uint64_t oid = vid_to_vdi_oid(ai->inode.vdi_id);
+	uint32_t min, max, offset, data_len;
 
-	/* todo: optimization with partial update of inode object */
-	ret = write_object(ai->fd, (char *)&ai->inode, oid,
-			   ai->inode.nr_copies, SD_INODE_SIZE, 0,
+	min = ai->min_dirty_data_idx;
+	max = ai->max_dirty_data_idx;
+
+	if (max < min)
+		goto end;
+
+	offset = sizeof(ai->inode) - sizeof(ai->inode.data_vdi_id) +
+		min * sizeof(ai->inode.data_vdi_id[0]);
+	data_len = (max - min + 1) * sizeof(ai->inode.data_vdi_id[0]);
+
+	ret = write_object(ai->fd, (char *)&ai->inode + offset, oid,
+			   ai->inode.nr_copies, data_len, offset,
 			   0, 0, 0, NULL);
 	if (ret < 0)
 		eprintf("sync inode failed\n");
 
+end:
+	ai->min_dirty_data_idx = UINT32_MAX;
+	ai->max_dirty_data_idx = 0;
+
 	return ret;
 }
 
-- 
1.8.1.2

--
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