Remove atomic from locking ideas, clarify cleaning locks
parent
f05a77755c
commit
403c0a5df6
29
sftl.c
29
sftl.c
|
@ -172,36 +172,47 @@ static void sftl_make_request(struct request_queue *q, struct bio *bio)
|
||||||
// ** Modify translation maps
|
// ** Modify translation maps
|
||||||
// ** Unlock translation maps
|
// ** Unlock translation maps
|
||||||
// * If insufficient:
|
// * If insufficient:
|
||||||
// ** Check if someone is already flushing using an increment of atomic variable
|
// ** Check flush flag (no need for atomic/etc as already within buffer lock)
|
||||||
// ** If yes:
|
// ** If someone is already flushing:
|
||||||
// *** Unlock buffer
|
// *** Unlock buffer
|
||||||
// *** Wait until flushing ends using an event
|
// *** Wait until flushing ends using an event
|
||||||
// *** Goto (Start)
|
// *** Goto (Start)
|
||||||
// ** If not:
|
// ** If no one is flushing yet:
|
||||||
// *** (Flush) Remember current bio and initiate flushing
|
// *** Set flush flag
|
||||||
|
// *** Remember current bio and initiate (Flush) operation
|
||||||
// * Unlock buffer
|
// * Unlock buffer
|
||||||
//
|
//
|
||||||
// After (Flush) operation ends:
|
// 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
|
// * Clear buffer
|
||||||
// * If the free sequence pointer can be moved without cleaning:
|
// * If the free sequence pointer can be moved without cleaning:
|
||||||
// ** Move pointer
|
// ** Move pointer
|
||||||
// ** Perform own remembered write operation
|
// ** Perform own remembered write operation
|
||||||
|
// ** Unset flush flag
|
||||||
// ** Unlock buffer
|
// ** Unlock buffer
|
||||||
// ** Wake up waiting writers
|
// ** Wake up waiting writers
|
||||||
// * If not:
|
// * If not:
|
||||||
// ** Initiate cleaning process
|
// ** Initiate cleaning process
|
||||||
// ** Unlock buffer
|
// ** Unlock buffer
|
||||||
//
|
//
|
||||||
// After cleaning:
|
// After cleaning operation ends:
|
||||||
// * Take write lock on translation maps
|
// * Take write lock on translation maps
|
||||||
// * Modify translation maps
|
// * Modify translation maps
|
||||||
// * Unlock translation maps
|
// * Unlock translation maps
|
||||||
// * Take write lock on the buffer
|
// * Take write lock on the buffer
|
||||||
// * Move free sequence pointer
|
// * Move free sequence pointer
|
||||||
// * Perform own remembered write operation
|
// * If there are no more pending cleaning operations:
|
||||||
// * Unlock buffer
|
// ** Perform own remembered write operation:
|
||||||
// * Wake up waiting writers
|
// *** 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;
|
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);
|
char *buffer = __bio_kmap_atomic(bio, 0, KM_USER0);
|
||||||
memcpy(sftl->buf + clust_sz*sftl->buf_size, buffer, clust_sz);
|
memcpy(sftl->buf + clust_sz*sftl->buf_size, buffer, clust_sz);
|
||||||
|
|
Loading…
Reference in New Issue