All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sanidhya Solanki <jpage.lkml@gmail.com>
To: clm@fb.com, jbacik@fb.com, dsterba@suse.com, jpage.lkml@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: [PATCH] BTRFS: Adds the files and options needed for Hybrid Storage
Date: Fri,  1 Jan 2016 22:08:32 -0500	[thread overview]
Message-ID: <1451704112-25463-1-git-send-email-jpage.lkml@gmail.com> (raw)

This patch adds the file required for Hybrid Storage. It contains
the memory, time and size limits for the cache and the statistics that
will be provided while the cache is operating.
It also adds the Makefile changes needed to add the Hybrid Storage.

Signed-off-by: Sanidhya Solanki <jpage.lkml@gmail.com>
---
 fs/btrfs/Makefile |  2 +-
 fs/btrfs/cache.c  | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 fs/btrfs/cache.c

diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 6d1d0b9..dc56ae4 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -9,7 +9,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
 	   export.o tree-log.o free-space-cache.o zlib.o lzo.o \
 	   compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
 	   reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
-	   uuid-tree.o props.o hash.o
+	   uuid-tree.o props.o hash.o cache.o
 
 btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
 btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
diff --git a/fs/btrfs/cache.c b/fs/btrfs/cache.c
new file mode 100644
index 0000000..0ece7a1
--- /dev/null
+++ b/fs/btrfs/cache.c
@@ -0,0 +1,58 @@
+/*
+ * (c) Sanidhya Solanki, 2016
+ *
+ * Licensed under the FSF's GNU Public License v2 or later.
+ */
+#include <linux/types.h>
+
+/* Cache size configuration )in MiB).*/
+#define MAX_CACHE_SIZE = 10000
+#define MIN_CACHE_SIZE = 10
+
+/* Time (in seconds)before retrying to increase the cache size.*/
+#define CACHE_RETRY = 10
+
+/* Space required to be free (in MiB) before increasing the size of the
+ * cache. If cache size is less than cache_grow_limit, a block will be freed
+ * from the cache to allow the cache to continue growning.
+ */
+#define CACHE_GROW_LIMIT = 100
+
+/* Size required to be free (in MiB) after we shrink the cache, so that it
+ * does not grow in size immediately.
+ */
+#define CACHE_SHRINK_FREE_SPACE_LIMIT = 100
+
+/* Age (in seconds) of oldest and newest block in the cache.*/
+#define MAX_AGE_LIMIT = 300	/* Five Minute Rule recommendation,
+				 * optimum size depends on size of data
+				 * blocks.
+				 */
+#define MIN_AGE_LIMIT = 15	/* In case of cache stampede.*/
+
+/* Memory constraints (in percentage) before we stop caching.*/
+#define MIN_MEM_FREE = 10
+
+/* Cache statistics. */
+struct cache_stats {
+	u64		cache_size;
+	u64		maximum_cache_size_attained;
+	int		cache_hit_rate;
+	int		cache_miss_rate;
+	u64		cache_evicted;
+	u64		duplicate_read;
+	u64		duplicate_write;
+	int		stats_update_interval;
+};
+
+#define cache_size	CACHE_SIZE /* Current cache size.*/
+#define max_cache_size	MAX_SIZE /* Max cache limit. */
+#define min_cache_size	MIN_SIZE /* Min cache limit.*/
+#define cache_time	MAX_TIME /* Maximum time to keep data in cache.*/
+#define evicted_csum	EVICTED_CSUM	/* Checksum of the evited data
+					 * (to avoid repeatedly caching
+					 * data that was just evicted.
+					 */
+#define read_csum	READ_CSUM /* Checksum of the read data.*/
+#define write_csum	WRITE_CSUM /* Checksum of the written data.*/
+#define evict_interval	EVICT_INTERVAL /* Time to keep data before eviction.*/
-- 
2.5.0


             reply	other threads:[~2016-01-02  7:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-02  3:08 Sanidhya Solanki [this message]
2016-01-02 11:40 ` [PATCH] BTRFS: Adds the files and options needed for Hybrid Storage Martin Steigerwald
2016-01-02  7:57   ` Sanidhya Solanki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451704112-25463-1-git-send-email-jpage.lkml@gmail.com \
    --to=jpage.lkml@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.