Add volatile range management code
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/5 Add volatile range management code
This patch provides the volatile range management code that filesystems can utilize when implementing FALLOC_FL_MARK_VOLATILE.
It tracks a collection of page ranges against a mapping stored in an interval-tree. This code handles coalescing overlapping and adjacent ranges, as well as splitting ranges when sub-chunks are removed.
The ranges can be marked purged or unpurged. And there is a per-fs lru list that tracks all the unpurged ranges for that fs.
v2:
* Fix bug in volatile_ranges_get_last_used returning bad start,end values
* Rework for intervaltree renaming
* Optimize volatile_range_lru_size to avoid running through lru list each time.
v3:
* Improve function name to make it clear what the volatile_ranges_pluck_lru() code does.
* Drop volatile_range_lru_size and unpurged_page_count mangement as its now unused
v4:
* Re-add volatile_range_lru_size and unpruged_page_count
* Fix bug in range_remove when we split ranges, we add an overlapping range before resizing the existing range.
v5:
* Drop intervaltree for prio_tree usage per Michel & Dmitry's suggestions.
* Cleanups
--- include/linux/volatile.h | 45 ++++ mm/Makefile | 2 +- mm/volatile.c | 509 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 555 insertions(+), 1 deletion(-) create mode 100644 include/linux/volatile.h create mode 100644 mm/volatile.c
include/linux/volatile.h new file +45 -0
@@ -0,0 +1,45 @@ +#ifndef _LINUX_VOLATILE_H +#define _LINUX_VOLATILE_H + +#include <linux/fs.h> + +struct volatile_fs_head { +struct mutex lock; +struct list_head lru_head; +s64 unpurged_page_count; +}; + + +#define DEFINE_VOLATILE_FS_HEAD (name) struct volatile_fs_head name = { \ + .lock = __MUTEX_INITIALIZER(name.lock), \ + .lru_head = LIST_HEAD_INIT(name.lru_head), \ + .unpurged_page_count = 0, \ +} + + +static inline void volatile_range_lock (struct volatile_fs_head *head) +{ +mutex_lock (&head->lock); +} + +static inline void volatile_range_unlock (struct volatile_fs_head *head) +{ +mutex_unlock (&head->lock); +} + +extern long volatile_range_add (struct volatile_fs_head *head, +struct address_space *mapping, +pgoff_t start_index,pgoff_t end_index); +extern long volatile_range_remove (struct volatile_fs_head *head, +struct address_space *mapping, +pgoff_t start_index,pgoff_t end_index); + +extern s64 volatile_range_lru_size (struct volatile_fs_head *head); + +extern void volatile_range_clear (struct volatile_fs_head *head, +struct address_space *mapping); + +extern s64 volatile_ranges_pluck_lru (struct volatile_fs_head *head, +struct address_space **mapping, +pgoff_t *start,pgoff_t *end); +#endif /* _LINUX_VOLATILE_H */
mm/Makefile +1 -1
@@ -16,7 +16,7 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ readahead.o swap.o truncate.o vmscan.o shmem.o \ prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \ page_isolation.o mm_init.o mmu_context.o percpu.o \ - compaction.o $(mmu-y) + compaction.o volatile.o $(mmu-y) obj-y += init-mm.o ifdef CONFIG_NO_BOOTMEM
mm/volatile.c new file +509 -0
509 lines not on this page · raw message
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · John Stultz
This patch provides the volatile range management code that filesystems can utilize when implementing
FALLOC_FL_MARK_VOLATILE.
Bah. Sorry for the noise here. Wanted Dave's thoughts on an unfinished patchset and forgot I had Cc's in some of the patches.
Ignore for now, hopefully I'll have something real I can send out soon.
thanks
-john
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>