Re: [PATCH 1/6] lib: Implement range locks
From: Jan Kara <jack@suse.cz>
Date: 2013-02-04 16:41:42
Also in:
linux-fsdevel, lkml
On Thu 31-01-13 15:57:26, Andrew Morton wrote:
On Thu, 31 Jan 2013 22:49:49 +0100 Jan Kara [off-list ref] wrote:quoted
Implement range locking using interval tree. ... +void range_lock(struct range_lock_tree *tree, struct range_lock *lock) +{ + struct interval_tree_node *node; + unsigned long flags; + + spin_lock_irqsave(&tree->lock, flags); + node = interval_tree_iter_first(&tree->root, lock->node.start, + lock->node.last); + while (node) { + lock->blocking_ranges++; + node = interval_tree_iter_next(node, lock->node.start, + lock->node.last); + } + interval_tree_insert(&lock->node, &tree->root); + /* Do we need to go to sleep? */ + while (lock->blocking_ranges) { + lock->task = current; + __set_current_state(TASK_UNINTERRUPTIBLE); + spin_unlock_irqrestore(&tree->lock, flags); + schedule(); + spin_lock_irqsave(&tree->lock, flags); + } + spin_unlock_irqrestore(&tree->lock, flags); +} ... +void range_unlock(struct range_lock_tree *tree, struct range_lock *lock) +{ + struct interval_tree_node *node; + unsigned long flags; + + spin_lock_irqsave(&tree->lock, flags); + interval_tree_remove(&lock->node, &tree->root); + node = interval_tree_iter_first(&tree->root, lock->node.start, + lock->node.last); + while (node) { + range_lock_unblock((struct range_lock *)node); + node = interval_tree_iter_next(node, lock->node.start, + lock->node.last); + } + spin_unlock_irqrestore(&tree->lock, flags); +}What are the worst-case interrupt-off durations here?
Good question. In theory, it could be relatively long, e.g. when there are lots of DIOs in flight against a range which is locked. I'll do some measurements to get some idea.
I note that the new exported functions in this patchset are refreshingly free of documentation ;)
They are *so* obvious ;) Point taken... Thanks for review. Honza -- Jan Kara [off-list ref] SUSE Labs, CR -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>