public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey Wu <jwu@lkdn.net>
To: linux-btrfs@vger.kernel.org
Cc: jwu@lkdn.net
Subject: [PATCH] Btrfs: improved the BIO_RW_DISCARD function definition
Date: Sun, 30 Aug 2009 11:16:36 +0800	[thread overview]
Message-ID: <20090830031636.GA9959@jwu-desktop> (raw)

(sorry, the last mail is sent by a mistake, resent this time).

The conditional compile func definition shall better not be defined this way:
static int btrfs_issue_discard()
{
#ifdef BIO_RW_DISCARD
	...
#else
	return 0;
#endif
}

instead, can be better done this way:

#ifndef BIO_RW_DISCARD
static int btrfs_issue_discard()
{
	return 0;
}
#endif

#ifdef BIO_RW_DISCARD
static int btrfs_issue_discard()
{ 
	...
}
#endif

Signed-off-by: Jeffrey Wu <jwu@lkdn.net>
---
 fs/btrfs/extent-tree.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 72a2b9c..4ccd94a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -62,6 +62,20 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
 			  struct btrfs_root *extent_root, u64 alloc_bytes,
 			  u64 flags, int force);
 
+#ifndef BIO_RW_DISCARD
+static void btrfs_issue_discard(struct block_device *bdev,
+				u64 start, u64 len)
+{
+	return;
+}
+
+static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
+				u64 num_bytes)
+{
+	return 0;
+}
+#endif
+
 static noinline int
 block_group_cache_done(struct btrfs_block_group_cache *cache)
 {
@@ -1513,12 +1527,10 @@ static void btrfs_issue_discard(struct block_device *bdev,
 {
 	blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
 }
-#endif
 
 static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
 				u64 num_bytes)
 {
-#ifdef BIO_RW_DISCARD
 	int ret;
 	u64 map_length = num_bytes;
 	struct btrfs_multi_bio *multi = NULL;
@@ -1542,10 +1554,8 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
 	}
 
 	return ret;
-#else
-	return 0;
-#endif
 }
+#endif
 
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root,
-- 
1.6.0.4


                 reply	other threads:[~2009-08-30  3:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090830031636.GA9959@jwu-desktop \
    --to=jwu@lkdn.net \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox