9 // RunTrashWorker is used by Keepstore to initiate trash worker channel goroutine.
10 // The channel will process trash list.
11 // For each (next) trash request:
12 // Delete the block indicated by the trash request Locator
15 func RunTrashWorker(trashq *WorkQueue) {
16 for item := range trashq.NextItem {
17 trashRequest := item.(TrashRequest)
18 TrashItem(trashRequest)
19 trashq.DoneItem <- struct{}{}
23 // TrashItem deletes the indicated block from every writable volume.
24 func TrashItem(trashRequest TrashRequest) {
25 reqMtime := time.Unix(trashRequest.BlockMtime, 0)
26 if time.Since(reqMtime) < blobSignatureTTL {
27 log.Printf("WARNING: data manager asked to delete a %v old block %v (BlockMtime %d = %v), but my blobSignatureTTL is %v! Skipping.",
30 trashRequest.BlockMtime,
36 for _, volume := range KeepVM.AllWritable() {
37 mtime, err := volume.Mtime(trashRequest.Locator)
39 log.Printf("%v Delete(%v): %v", volume, trashRequest.Locator, err)
42 if trashRequest.BlockMtime != mtime.Unix() {
43 log.Printf("%v Delete(%v): mtime on volume is %v does not match trash list value %v", volume, trashRequest.Locator, mtime.Unix(), trashRequest.BlockMtime)
48 err = errors.New("did not delete block because neverDelete is true")
50 err = volume.Trash(trashRequest.Locator)
54 log.Printf("%v Delete(%v): %v", volume, trashRequest.Locator, err)
56 log.Printf("%v Delete(%v) OK", volume, trashRequest.Locator)