From: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
To: stgt@vger.kernel.org
Cc: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>,
Teruaki Ishizaki <ishizaki.teruaki@lab.ntt.co.jp>,
Takashi Menjo <menjo.takashi@lab.ntt.co.jp>
Subject: [PATCH 5/6] sheepdog: don't let ai have min and max dirty data indexes
Date: Tue, 6 Sep 2016 16:37:28 +0900 [thread overview]
Message-ID: <1473147449-29377-6-git-send-email-mitake.hitoshi@lab.ntt.co.jp> (raw)
In-Reply-To: <1473147449-29377-1-git-send-email-mitake.hitoshi@lab.ntt.co.jp>
Like the qemu driver [1], this patch decouples min and dirty data
indexes from access info for avoiding overwriting by parallel
requests.
[1] https://github.com/codyprime/qemu-kvm-jtc/commit/498f21405a286f718a0767c791b7d2db19f4e5bd
Cc: Teruaki Ishizaki <ishizaki.teruaki@lab.ntt.co.jp>
Cc: Takashi Menjo <menjo.takashi@lab.ntt.co.jp>
Tested-by: Takashi Menjo <menjo.takashi@lab.ntt.co.jp>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
---
usr/bs_sheepdog.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/usr/bs_sheepdog.c b/usr/bs_sheepdog.c
index 8f228b5..12bcfd9 100644
--- a/usr/bs_sheepdog.c
+++ b/usr/bs_sheepdog.c
@@ -286,9 +286,6 @@ struct sheepdog_access_info {
struct list_head fd_list_head;
pthread_rwlock_t fd_list_lock;
- uint32_t min_dirty_data_idx;
- uint32_t max_dirty_data_idx;
-
struct sheepdog_inode inode;
pthread_rwlock_t inode_lock;
@@ -734,9 +731,6 @@ static int reload_inode(struct sheepdog_access_info *ai, int is_snapshot)
}
}
- ai->min_dirty_data_idx = UINT32_MAX;
- ai->max_dirty_data_idx = 0;
-
inode_version++;
ai->inode_version = inode_version;
@@ -854,14 +848,11 @@ static int sd_sync(struct sheepdog_access_info *ai)
}
}
-static int update_inode(struct sheepdog_access_info *ai)
+static int update_inode(struct sheepdog_access_info *ai, uint32_t min, uint32_t max)
{
int ret = 0, need_reload_inode = 0;
uint64_t oid = vid_to_vdi_oid(ai->inode.vdi_id);
- uint32_t min, max, offset, data_len;
-
- min = ai->min_dirty_data_idx;
- max = ai->max_dirty_data_idx;
+ uint32_t offset, data_len;
if (max < min)
goto end;
@@ -890,8 +881,6 @@ update:
}
end:
- ai->min_dirty_data_idx = UINT32_MAX;
- ai->max_dirty_data_idx = 0;
return ret;
}
@@ -934,6 +923,7 @@ static int sd_io(struct sheepdog_access_info *ai, int write, char *buf, int len,
int nr_copies = ai->inode.nr_copies;
int need_write_lock, check_idx;
int read_reload_snap = 0;
+ uint32_t min_dirty_data_idx = UINT32_MAX, max_dirty_data_idx = 0;
goto do_req;
@@ -1015,12 +1005,12 @@ retry:
}
if (create) {
- ai->min_dirty_data_idx =
+ min_dirty_data_idx =
min_t(uint32_t, idx,
- ai->min_dirty_data_idx);
- ai->max_dirty_data_idx =
+ min_dirty_data_idx);
+ max_dirty_data_idx =
max_t(uint32_t, idx,
- ai->max_dirty_data_idx);
+ max_dirty_data_idx);
ai->inode.data_vdi_id[idx] = vid;
need_update_inode = 1;
@@ -1066,7 +1056,7 @@ done:
}
if (need_update_inode)
- ret = update_inode(ai);
+ ret = update_inode(ai, min_dirty_data_idx, max_dirty_data_idx);
out:
pthread_rwlock_unlock(&ai->inode_lock);
@@ -1279,9 +1269,6 @@ trans_to_expect_nothing:
if (ret)
goto out;
- ai->min_dirty_data_idx = UINT32_MAX;
- ai->max_dirty_data_idx = 0;
-
ret = read_object(ai, (char *)&ai->inode, vid_to_vdi_oid(vid),
0, SD_INODE_SIZE, 0, &need_reload);
if (ret)
--
2.7.4
next prev parent reply other threads:[~2016-09-06 7:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 7:37 [PATCH 0/6] sheepdog driver cleanup Hitoshi Mitake
2016-09-06 7:37 ` [PATCH 1/6] sheepdog: prevent double locking during inode reload Hitoshi Mitake
2016-09-06 7:37 ` [PATCH 2/6] sheepdog: serialize overwrapping request Hitoshi Mitake
2016-09-06 7:37 ` [PATCH 3/6] sheepdog: pass a correct flag to reload_inode() Hitoshi Mitake
2016-09-06 7:37 ` [PATCH 4/6] sheepdog: handle a case of snapshot -> failover Hitoshi Mitake
2016-09-06 7:37 ` Hitoshi Mitake [this message]
2016-09-06 7:37 ` [PATCH 6/6] sheepdog: handle an inconsistent state of metadata Hitoshi Mitake
2016-09-07 0:24 ` [PATCH 0/6] sheepdog driver cleanup FUJITA Tomonori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473147449-29377-6-git-send-email-mitake.hitoshi@lab.ntt.co.jp \
--to=mitake.hitoshi@lab.ntt.co.jp \
--cc=ishizaki.teruaki@lab.ntt.co.jp \
--cc=menjo.takashi@lab.ntt.co.jp \
--cc=stgt@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.