Remove atomic from locking ideas, clarify cleaning locks

master
Vitaliy Filippov 2013-05-31 18:40:25 +04:00
parent f05a77755c
commit 403c0a5df6
1 changed files with 20 additions and 9 deletions

29
sftl.c
View File

@ -172,36 +172,47 @@ static void sftl_make_request(struct request_queue *q, struct bio *bio)
// ** Modify translation maps
// ** Unlock translation maps
// * If insufficient:
// ** Check if someone is already flushing using an increment of atomic variable
// ** If yes:
// ** Check flush flag (no need for atomic/etc as already within buffer lock)
// ** If someone is already flushing:
// *** Unlock buffer
// *** Wait until flushing ends using an event
// *** Goto (Start)
// ** If not:
// *** (Flush) Remember current bio and initiate flushing
// ** If no one is flushing yet:
// *** Set flush flag
// *** Remember current bio and initiate (Flush) operation
// * Unlock buffer
//
// After (Flush) operation ends:
// * Take write lock on the buffer (writers are already blocked, this is for readers)
// * Take write lock on the buffer (writers are already blocked, this is to block readers)
// * Clear buffer
// * If the free sequence pointer can be moved without cleaning:
// ** Move pointer
// ** Perform own remembered write operation
// ** Unset flush flag
// ** Unlock buffer
// ** Wake up waiting writers
// * If not:
// ** Initiate cleaning process
// ** Unlock buffer
//
// After cleaning:
// After cleaning operation ends:
// * Take write lock on translation maps
// * Modify translation maps
// * Unlock translation maps
// * Take write lock on the buffer
// * Move free sequence pointer
// * Perform own remembered write operation
// * Unlock buffer
// * Wake up waiting writers
// * If there are no more pending cleaning operations:
// ** Perform own remembered write operation:
// *** Take write lock on translation maps so readers won't get them partially modified
// *** Write current bio into buffer
// *** Modify translation maps
// *** Unlock translation maps
// ** Unset flush flag
// ** Unlock buffer
// ** Wake up waiting writers
// * Else:
// ** Initiate next cleaning operation
// ** Unlock buffer
struct sftl_map *buf_map = (struct sftl_map *)(sftl->buf + seg_clust*clust_sz) + sftl->buf_size;
char *buffer = __bio_kmap_atomic(bio, 0, KM_USER0);
memcpy(sftl->buf + clust_sz*sftl->buf_size, buffer, clust_sz);