You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2012/03/20 03:29:52 UTC
git commit: TS-1114: ensure that all accesses via
CacheVC::write_vector are protected by the vol lock as this vector is shared.
Updated Branches:
refs/heads/master b1f2e9843 -> f51778f70
TS-1114: ensure that all accesses via CacheVC::write_vector are protected by
the vol lock as this vector is shared.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f51778f7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f51778f7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f51778f7
Branch: refs/heads/master
Commit: f51778f70df68271b5073a1c5fbb8cd384784999
Parents: b1f2e98
Author: John Plevyak <jp...@apache.org>
Authored: Mon Mar 19 19:28:29 2012 -0700
Committer: John Plevyak <jp...@acm.org>
Committed: Mon Mar 19 19:28:29 2012 -0700
----------------------------------------------------------------------
iocore/cache/CacheWrite.cc | 105 ++++++++++++++++++++-------------------
1 files changed, 53 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f51778f7/iocore/cache/CacheWrite.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index 06a71d1..2ffee33 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -1491,67 +1491,68 @@ CacheVC::openWriteStartDone(int event, Event *e)
return EVENT_CONT;
set_io_not_in_progress();
}
- if (_action.cancelled && (!od || !od->has_multiple_writers()))
- goto Lcancel;
+ {
+ CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
+ if (!lock)
+ VC_LOCK_RETRY_EVENT();
- if (event == AIO_EVENT_DONE) { // vector read done
- Doc *doc = (Doc *) buf->data();
- if (!io.ok()) {
- err = ECACHE_READ_FAIL;
- goto Lfailure;
- }
+ if (_action.cancelled && (!od || !od->has_multiple_writers()))
+ goto Lcancel;
- /* INKqa07123.
- A directory entry which is nolonger valid may have been overwritten.
- We need to start afresh from the beginning by setting last_collision
- to NULL.
- */
- if (!dir_valid(vol, &dir)) {
- DDebug("cache_write",
- "OpenReadStartDone: Dir not valid: Write Head: %lld, Dir: %"PRId64,
- (long long)offset_to_vol_offset(vol, vol->header->write_pos), dir_offset(&dir));
- last_collision = NULL;
- goto Lcollision;
- }
- if (!(doc->first_key == first_key))
- goto Lcollision;
- if (doc->magic != DOC_MAGIC) {
- err = ECACHE_BAD_META_DATA;
- goto Lfailure;
- }
- if (!doc->hlen) {
- err = ECACHE_BAD_META_DATA;
- goto Lfailure;
- }
- ink_assert((((uintptr_t) &doc->hdr()[0]) & HDR_PTR_ALIGNMENT_MASK) == 0);
+ if (event == AIO_EVENT_DONE) { // vector read done
+ Doc *doc = (Doc *) buf->data();
+ if (!io.ok()) {
+ err = ECACHE_READ_FAIL;
+ goto Lfailure;
+ }
- if (write_vector->get_handles(doc->hdr(), doc->hlen, buf) != doc->hlen) {
- err = ECACHE_BAD_META_DATA;
- goto Lfailure;
- }
- ink_debug_assert(write_vector->count() > 0);
- od->first_dir = dir;
- first_dir = dir;
- if (doc->single_fragment()) {
- // fragment is tied to the vector
- od->move_resident_alt = 1;
- od->single_doc_key = doc->key;
- dir_assign(&od->single_doc_dir, &dir);
- dir_set_tag(&od->single_doc_dir, od->single_doc_key.word(2));
+ /* INKqa07123.
+ A directory entry which is nolonger valid may have been overwritten.
+ We need to start afresh from the beginning by setting last_collision
+ to NULL.
+ */
+ if (!dir_valid(vol, &dir)) {
+ DDebug("cache_write",
+ "OpenReadStartDone: Dir not valid: Write Head: %lld, Dir: %"PRId64,
+ (long long)offset_to_vol_offset(vol, vol->header->write_pos), dir_offset(&dir));
+ last_collision = NULL;
+ goto Lcollision;
+ }
+ if (!(doc->first_key == first_key))
+ goto Lcollision;
+ if (doc->magic != DOC_MAGIC) {
+ err = ECACHE_BAD_META_DATA;
+ goto Lfailure;
+ }
+ if (!doc->hlen) {
+ err = ECACHE_BAD_META_DATA;
+ goto Lfailure;
+ }
+ ink_assert((((uintptr_t) &doc->hdr()[0]) & HDR_PTR_ALIGNMENT_MASK) == 0);
+
+ if (write_vector->get_handles(doc->hdr(), doc->hlen, buf) != doc->hlen) {
+ err = ECACHE_BAD_META_DATA;
+ goto Lfailure;
+ }
+ ink_debug_assert(write_vector->count() > 0);
+ od->first_dir = dir;
+ first_dir = dir;
+ if (doc->single_fragment()) {
+ // fragment is tied to the vector
+ od->move_resident_alt = 1;
+ od->single_doc_key = doc->key;
+ dir_assign(&od->single_doc_dir, &dir);
+ dir_set_tag(&od->single_doc_dir, od->single_doc_key.word(2));
+ }
+ first_buf = buf;
+ goto Lsuccess;
}
- first_buf = buf;
- goto Lsuccess;
- }
Lcollision:
- {
int if_writers = ((uintptr_t) info == CACHE_ALLOW_MULTIPLE_WRITES);
- CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding);
- if (!lock)
- VC_LOCK_RETRY_EVENT();
if (!od) {
if ((err = vol->open_write(
- this, if_writers, cache_config_http_max_alts > 1 ? cache_config_http_max_alts : 0)) > 0)
+ this, if_writers, cache_config_http_max_alts > 1 ? cache_config_http_max_alts : 0)) > 0)
goto Lfailure;
if (od->has_multiple_writers()) {
MUTEX_RELEASE(lock);