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
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sanidhya Solanki <jpage.lkml@gmail.com>
Subject: [PATCH] BTRFS: Adds an option to select RAID Stripe size
Date: Mon, 28 Dec 2015 07:24:11 -0500	[thread overview]
Message-ID: <1451305451-31222-1-git-send-email-jpage.lkml@gmail.com> (raw)

An option to select the RAID Stripe size is made
available in the BTRFS Filesystem, via an option
in the BTRFS Config setup, with minimal change
to the existing code base.

Signed-off-by: Sanidhya Solanki <jpage.lkml@gmail.com>
---
 fs/btrfs/Kconfig   | 42 ++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/Makefile  |  2 ++
 fs/btrfs/scrub.c   |  4 ++++
 fs/btrfs/super.c   |  4 ++++
 fs/btrfs/volumes.c |  2 +-
 fs/btrfs/volumes.h |  4 +++-
 6 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
index 80e9c18..1454d21 100644
--- a/fs/btrfs/Kconfig
+++ b/fs/btrfs/Kconfig
@@ -28,6 +28,48 @@ config BTRFS_FS
 
 	  If unsure, say N.
 
+choice
+         prompt "Choose Stripe Size"
+         default RS_1024
+         help
+           Allows you to select the size of the stripe, which is the smallest sized
+           data block to be replicated.
+           Selecting a larger size than your physical block size may lead to data
+           fragmentation in some cases.
+
+        config RS_512
+                 bool "512 bytes"
+
+        config RS_1024
+                 bool "1024 bytes"
+
+        config RS_2048
+                 bool "2048 bytes"
+
+        config RS_4096
+                 bool "4096 bytes"
+
+        config RS_8192
+                 bool "8192 bytes"
+
+        config RS_16384
+                 bool "16384 bytes"
+
+        config RS_32768
+                 bool "32768 bytes"
+
+endchoice
+
+config BTRFS_RAID_STRIPE
+        int
+        default 512 if RS_512
+        default 1024 if RS_1024
+        default 2048 if RS_2048
+        default 4096 if RS_4096
+        default 8192 if RS_8192
+        default 16384 if RS_16384
+        default 32768 if RS_32768
+
 config BTRFS_FS_POSIX_ACL
 	bool "Btrfs POSIX Access Control Lists"
 	depends on BTRFS_FS
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 6d1d0b9..1c4e384 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -17,3 +17,5 @@ btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
 btrfs-$(CONFIG_BTRFS_FS_RUN_SANITY_TESTS) += tests/free-space-tests.o \
 	tests/extent-buffer-tests.o tests/btrfs-tests.o \
 	tests/extent-io-tests.o tests/inode-tests.o tests/qgroup-tests.o
+
+btrfs-$(CONFIG_BTRFS_RAID_STRIPE) += scrub.o super.o volumes.o
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b091d94..4d0f802 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -63,6 +63,10 @@ struct scrub_ctx;
  */
 #define SCRUB_MAX_PAGES_PER_BLOCK	16	/* 64k per node/leaf/sector */
 
+#define STRIPE_LENGTH CONFIG_BTRFS_RAID_STRIPE
+
+#define BTRFS_STRIPE_LEN	(64 * STRIPE_LENGTH)
+
 struct scrub_recover {
 	atomic_t		refs;
 	struct btrfs_bio	*bbio;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 24154e4..3d91f8d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -64,6 +64,10 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/btrfs.h>
 
+#define STRIPE_LENGTH CONFIG_BTRFS_RAID_STRIPE
+
+#define BTRFS_STRIPE_LEN	(64 * STRIPE_LENGTH)
+
 static const struct super_operations btrfs_super_ops;
 static struct file_system_type btrfs_fs_type;
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 4564522..e1b2e5c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4461,7 +4461,7 @@ static int btrfs_cmp_device_info(const void *a, const void *b)
 static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)
 {
 	/* TODO allow them to set a preferred stripe size */
-	return 64 * 1024;
+	return BTRFS_STRIPE_LEN;
 }
 
 static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index d5c84f6..9115a80 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -26,7 +26,9 @@
 
 extern struct mutex uuid_mutex;
 
-#define BTRFS_STRIPE_LEN	(64 * 1024)
+#define STRIPE_LENGTH CONFIG_BTRFS_RAID_STRIPE
+
+#define BTRFS_STRIPE_LEN	(64 * STRIPE_LENGTH)
 
 struct buffer_head;
 struct btrfs_pending_bios {
-- 
2.5.0


             reply	other threads:[~2015-12-28 16:26 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-28 12:24 Sanidhya Solanki [this message]
2015-12-28 22:19 ` [PATCH] BTRFS: Adds an option to select RAID Stripe size Christoph Anton Mitterer
2015-12-28 20:38   ` Sanidhya Solanki
2015-12-29  1:21     ` Christoph Anton Mitterer
2015-12-28 21:43       ` Sanidhya Solanki
2015-12-29  3:42         ` Christoph Anton Mitterer
2015-12-29  0:03           ` Sanidhya Solanki
2015-12-29  4:26             ` Christoph Anton Mitterer
2015-12-29  1:31               ` Sanidhya Solanki
2015-12-29  6:03                 ` Christoph Anton Mitterer
2015-12-29  2:23                   ` Sanidhya Solanki
2015-12-29 15:32                     ` Christoph Anton Mitterer
2015-12-29 16:44                       ` Duncan
2015-12-30  2:56                         ` Christoph Anton Mitterer
2015-12-29 18:06               ` David Sterba
2015-12-30 20:00                 ` Christoph Anton Mitterer
2015-12-30 21:02                   ` Duncan
2015-12-30 21:13                     ` Christoph Anton Mitterer
2016-01-02 11:52                 ` Sanidhya Solanki
2016-01-03  1:37                   ` Qu Wenruo
2016-01-03  2:26                     ` Christoph Anton Mitterer
2016-01-05 10:44                       ` David Sterba
2016-01-05 18:48                         ` Christoph Anton Mitterer
2016-01-10  3:11                     ` Sanidhya Solanki
2016-01-11  1:29                       ` Qu Wenruo
2016-01-11 15:43                       ` Christoph Anton Mitterer
2016-01-11 11:49                         ` Sanidhya Solanki
2016-01-11 15:57                           ` Christoph Anton Mitterer
2016-01-11 16:01                             ` Hugo Mills
2016-01-12 12:23                             ` Austin S. Hemmelgarn
2016-01-12 12:07                               ` Sanidhya Solanki
2015-12-29 13:39 ` David Sterba
2015-12-29 11:15   ` Sanidhya Solanki
2015-12-29 17:06     ` David Sterba
2015-12-29 21:32       ` Sanidhya Solanki
2015-12-30  6:39       ` Sanidhya Solanki
2015-12-30 11:59         ` Qu Wenruo
2015-12-30  9:54           ` Sanidhya Solanki
2015-12-30 14:10             ` Qu Wenruo
2015-12-30 11:15               ` Sanidhya Solanki
2015-12-30 15:58                 ` David Sterba
2015-12-30 21:19                   ` Sanidhya Solanki
2015-12-30 16:17               ` David Sterba
2015-12-30 21:21                 ` Sanidhya Solanki
2016-01-05 10:33                   ` David Sterba
2015-12-31  0:46                 ` Qu Wenruo
2016-01-05 10:16                   ` David Sterba
2015-12-30 19:48               ` Christoph Anton Mitterer

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=1451305451-31222-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.