vfs: Introduce one root structure hot_info

   One root structure hot_info is defined, is hooked
up in super_block, and will be used to hold rb trees
root, hash list root and some other information, etc.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Introduce 2 rb trees

  Define two new new red-black trees
hot_inode_tree and hot_range_tree which are keyed
by {inode, offset} or {inode, offset, length}
and are used to keep track of fs-wide collected
raw access frequencies for the files or its ranges.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: introduce 2 rb tree items - inode and range

  Define two items hot_inode_item and hot_range_item,
one of them represents one tracked file
to keep track of its access frequency and the tree of
ranges in this file, while the latter represents
a file range of one inode.
  Each of the two structures contains a freq_data struct
with its frequency of access metrics (number of
{reads, writes}, last {read,write} time, frequency of
{reads,writes}).
  Also, since it isn't entirely obvious, the "frequency"
or reads or writes is determined by taking a kind of
generalized average of the last few (2^N for some tunable N)
reads or writes.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Initialize 2 kmem caches for rb tree items

  Initialize kmem caches for hot_inode_item
and hot_range_item and add their initialization
 utils helpers.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Initialize 2 rb trees for inode and range items

  Adds hot_inode_tree and hot_range_tree structs to keep track of
frequently accessed files and ranges within files. Trees contain
hot_{inode,range}_items representing those files and ranges.
  Having these trees means that vfs can quickly determine the
temperature of some data by doing some calculations on the
req_data struct that hangs off of the tree item.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Add support for updating frequency numbers

  Add some utils helpers to update access frequencies
for one file or its range.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Built-in core hot tracking files

  Built-in hot_track, hot_map and hot_hash files.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Add parsing support for new mount option -o hottrack

  Introduce one new mount option '-o hottrack',
and add its parsing support.
  Its usage looks like:
   mount -o hottrack
   mount -o nouser,hottrack
   mount -o nouser,hottrack,loop
   mount -o hottrack,nouser

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Add init and exit support

  Add initialization function to create some
key data structures when hot tracking is enabled;
Clean up them when hot tracking is disabled.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Introduce hash head structure

  Adds a hash table structure to efficiently lookup
the data temperature of a file or its range.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Introduce hash node structure

  Define one hash list node, it will keep track of
temperature info and be stored in each hash list
of hash table.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Initialize kmem cache for hash node

  Initialize kmem cache for hot_hash_node
and its initialization utils helpers.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Initialize rwlock for each hash list

  Initialize rwlock for each hash list of hash table.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Enable hot data tracking

  Miscellaneous features that implement hot data tracking
and generally make the hot data functions a bit more friendly.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Fork one kthread to update temperature info

  Fork and run one kernel kthread to calculate
that temperature based on some metrics kept
in custom frequency data structs, and store
the info in the hash table.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Add support for 3 new ioctl interfaces

  FS_IOC_GET_HEAT_INFO: return a struct containing the various
metrics collected in btrfs_freq_data structs, and also return a
calculated data temperature based on those metrics. Optionally, retrieve
the temperature from the hot data hash list instead of recalculating it.

  FS_IOC_GET_HEAT_OPTS: return an integer representing the current
state of hot data tracking and migration:

0 = do nothing
1 = track frequency of access

FS_IOC_SET_HEAT_OPTS: change the state of hot data tracking and
migration, as described above.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vfs: Add debugfs support

  Add a /sys/kernel/debug/hot_track/<device_name>/ directory for each
volume that contains two files. The first, `inode_data', contains the
heat information for inodes that have been brought into the hot data map
structures. The second, `range_data', contains similar information for
subfile ranges.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>