mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kent Overstreet <koverstreet@google.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	dm-devel@redhat.com, agk@redhat.com
Subject: Re: [Bcache v13 11/16] bcache: Core btree code
Date: Wed, 30 May 2012 18:09:41 -0700	[thread overview]
Message-ID: <20120531010940.GB5645@google.com> (raw)
In-Reply-To: <20120530074708.GA32121@google.com>

On Wed, May 30, 2012 at 04:47:08PM +0900, Tejun Heo wrote:
> A couple more comments from this round of reading.
> 
> On Wed, May 09, 2012 at 11:10:48PM -0400, Kent Overstreet wrote:
> > +#define btree_prio		USHRT_MAX
> > +#define initial_prio		32768
> 
> Why are these in lower case?

No good reason. I'll change it.

> 
> > +#define PTR_BUCKET(c, k, n)						\
> > +	(PTR_CACHE(c, k, n)->buckets + PTR_BUCKET_NR(c, k, n))
> 
> PTR_BUCKET(c, k, n)
> 
> Awesome.  I don't know what type it takes or what each single
> character argument stands for.

Yeah, that should be an inline function, along with some others. Fixed -
well, have to convert the rest of the code to the lowercase names:

Maybe ptr_bucket_idx() instead of ptr_bucket_nr()?

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 1011a73..0617885 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -717,15 +717,41 @@ PTR_FIELD(PTR_GEN,		0,  8)
 #define PTR(gen, offset, dev)						\
 	((((uint64_t) dev) << 51) | ((uint64_t) offset) << 8 | gen)
 
-#define sector_to_bucket(c, s)	((long) ((s) >> (c)->bucket_bits))
-#define bucket_to_sector(c, b)	(((sector_t) (b)) << (c)->bucket_bits)
-#define bucket_remainder(c, b)	((b) & ((c)->sb.bucket_size - 1))
+static inline size_t sector_to_bucket(struct cache_set *c, sector_t s)
+{
+	return s >> c->bucket_bits;
+}
+
+static inline sector_t bucket_to_sector(struct cache_set *c, size_t b)
+{
+	return ((sector_t) b) << c->bucket_bits;
+}
 
-#define PTR_CACHE(c, k, n)	((c)->cache[PTR_DEV(k, n)])
-#define PTR_BUCKET_NR(c, k, n)	sector_to_bucket(c, PTR_OFFSET(k, n))
+static inline sector_t bucket_remainder(struct cache_set *c, sector_t s)
+{
+	return s & (c->sb.bucket_size - 1);
+}
 
-#define PTR_BUCKET(c, k, n)						\
-	(PTR_CACHE(c, k, n)->buckets + PTR_BUCKET_NR(c, k, n))
+static inline struct cache *ptr_cache(struct cache_set *c,
+				      struct bkey *k,
+				      unsigned ptr)
+{
+	return c->cache[PTR_DEV(k, ptr)];
+}
+
+static inline size_t ptr_bucket_nr(struct cache_set *c,
+				   struct bkey *k,
+				   unsigned ptr)
+{
+	return sector_to_bucket(c, PTR_OFFSET(k, ptr));
+}
+
+static inline struct bucket *ptr_bucket(struct cache_set *c,
+					struct bkey *k,
+					unsigned ptr)
+{
+	return ptr_cache(c, k, ptr)->buckets + ptr_bucket_nr(c, k, ptr);
+}
 
 /* Btree key macros */
 
> 
> > +static inline bool cached_dev_get(struct cached_dev *d)
> > +{
> > +	if (!atomic_inc_not_zero(&d->count))
> > +		return false;
> > +
> > +	smp_mb__after_atomic_inc();
> 
> What is this mb() paired with?  Whenever using a mb, please specify
> what the mb is paired with.

super.c, cached_dev_attach():

	smp_wmb();
	/* d->c must be set before d->count != 0 */
	atomic_set(&d->count, 1);

I'm improving the comments.

> 
> > +	return true;
> > +}
> 
> Thanks.
> 
> -- 
> tejun

  reply	other threads:[~2012-05-31  1:09 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-10  3:07 [Bcache v13 00/16] Kent Overstreet
2012-05-10  3:08 ` [Bcache v13 01/16] Only clone bio vecs that are in use Kent Overstreet
2012-05-10 21:35   ` [dm-devel] " Vivek Goyal
2012-05-10 21:42     ` Kent Overstreet
2012-05-11 13:29       ` Jeff Moyer
2012-05-11 20:29         ` Kent Overstreet
2012-05-15 16:19   ` Tejun Heo
2012-05-10  3:08 ` [Bcache v13 02/16] Bio pool freeing Kent Overstreet
2012-05-10 21:32   ` [dm-devel] " Vivek Goyal
2012-05-10 21:39     ` Kent Overstreet
2012-05-10 21:52       ` Vivek Goyal
2012-05-10 21:53         ` Kent Overstreet
2012-05-15 16:24   ` Tejun Heo
2012-05-15 16:25   ` Tejun Heo
2012-05-10  3:08 ` [Bcache v13 03/16] Revert "rw_semaphore: remove up/down_read_non_owner" Kent Overstreet
2012-05-15 16:37   ` Tejun Heo
2012-05-15 16:38   ` Tejun Heo
2012-05-10  3:09 ` [Bcache v13 04/16] Fix ratelimit macro to compile in c99 mode Kent Overstreet
2012-05-15 16:43   ` Tejun Heo
2012-05-10  3:09 ` [Bcache v13 05/16] Export get_random_int() Kent Overstreet
2012-05-15 16:44   ` Tejun Heo
2012-05-10  3:09 ` [Bcache v13 06/16] Export blk_fill_rwbs() Kent Overstreet
2012-05-10  3:09 ` [Bcache v13 07/16] Closures Kent Overstreet
2012-05-15 22:41   ` Tejun Heo
2012-05-18  6:29     ` Kent Overstreet
2012-05-18 10:02       ` Alan Cox
2012-05-21 19:40         ` Kent Overstreet
2012-05-10  3:10 ` [Bcache v13 08/16] bcache: Documentation, and changes to generic code Kent Overstreet
2012-05-10  3:10 ` [Bcache v13 09/16] Bcache: generic utility code Kent Overstreet
2012-05-10 19:35   ` Dan Williams
2012-05-10 21:42     ` Kent Overstreet
2012-05-22 21:17   ` Tejun Heo
2012-05-23  3:12     ` Kent Overstreet
2012-05-23  3:36       ` Joe Perches
2012-05-23  4:50         ` [PATCH] Add human-readable units modifier to vsnprintf() Kent Overstreet
2012-05-23  5:10           ` Joe Perches
2012-05-23  5:22             ` Kent Overstreet
2012-05-23  5:42               ` Joe Perches
2012-05-23  6:04                 ` Kent Overstreet
2012-05-23  6:12                   ` Joe Perches
2012-05-23  5:08       ` [Bcache v13 09/16] Bcache: generic utility code Tejun Heo
2012-05-23  5:54         ` Kent Overstreet
2012-05-23 16:51           ` Tejun Heo
2012-05-23 15:15     ` [dm-devel] " Vivek Goyal
2012-05-23 15:33       ` Kent Overstreet
2012-05-22 21:19   ` Tejun Heo
2012-05-10  3:10 ` [Bcache v13 10/16] bcache: Superblock/initialization/sysfs code Kent Overstreet
2012-05-10  3:10 ` [Bcache v13 11/16] bcache: Core btree code Kent Overstreet
2012-05-22 22:12   ` Tejun Heo
2012-05-23  3:45     ` Kent Overstreet
2012-05-23  5:20       ` Tejun Heo
2012-05-23  5:34         ` Kent Overstreet
2012-05-23 17:24           ` Tejun Heo
2012-05-22 22:40   ` Tejun Heo
2012-05-30  7:47   ` Tejun Heo
2012-05-31  1:09     ` Kent Overstreet [this message]
2012-05-10  3:11 ` [Bcache v13 12/16] bcache: Bset code (lookups within a btree node) Kent Overstreet
2012-05-22 22:39   ` Tejun Heo
2012-05-23  4:21     ` Kent Overstreet
2012-05-23 17:55       ` Tejun Heo
2012-05-23 20:49         ` Tejun Heo
2012-05-24 18:11           ` Tejun Heo
2012-05-10  3:11 ` [Bcache v13 13/16] bcache: Journalling Kent Overstreet
2012-05-10  3:11 ` [Bcache v13 14/16] bcache: Request, io and allocation code Kent Overstreet
2012-05-22 22:42   ` Tejun Heo
2012-05-23  1:44     ` Kent Overstreet
2012-05-23  4:24     ` Kent Overstreet
2012-05-22 22:44   ` Tejun Heo
2012-05-30  7:23   ` Tejun Heo
2012-05-31  0:52     ` Kent Overstreet
2012-05-31  2:43       ` Tejun Heo
2012-05-31  5:13         ` Kent Overstreet
2012-05-31  6:45           ` Tejun Heo
2012-06-01  2:37             ` Tejun Heo
2012-05-31  2:45       ` Tejun Heo
2012-05-30  7:32   ` Tejun Heo
2012-05-10  3:11 ` [Bcache v13 15/16] bcache: Writeback Kent Overstreet
2012-05-10  3:11 ` [Bcache v13 16/16] bcache: Debug and tracing code Kent Overstreet
2012-05-10 13:54 ` [dm-devel] [Bcache v13 00/16] Vivek Goyal
2012-05-10 15:03 ` Vivek Goyal
2012-05-10 15:34   ` Kent Overstreet
2012-05-10 18:34 ` Dan Williams
     [not found] ` <1188908028.170.1336674698865.JavaMail.mail@webmail09>
2012-05-10 18:49   ` [Bcache v13 11/16] bcache: Core btree code Joe Perches
2012-05-10 21:48     ` Kent Overstreet
2012-05-18 10:06 ` [Bcache v13 00/16] Arnd Bergmann
2012-05-30  8:29 ` Tejun Heo
2012-05-30  8:54 ` Zhi Yong Wu

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=20120531010940.GB5645@google.com \
    --to=koverstreet@google.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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

Powered by JetHome