aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-10-06 23:23:00 -0400
committerNeilBrown <neilb@suse.de>2011-10-06 23:23:00 -0400
commitdb298e1946c074c83d97f1c959fbc0def2af2c86 (patch)
tree1fb0ff7c0d6b85216d391e82b84af07b032fb987 /drivers/md/raid5.c
parent0fc280f606742e8a2969776b2ab11cf6a614d9e1 (diff)
md/raid5: convert to macros into inline functions.
More type-safety. Easier to read. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6ab3434b235..01163c81e74 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -70,7 +70,11 @@
70#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) 70#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head))
71#define HASH_MASK (NR_HASH - 1) 71#define HASH_MASK (NR_HASH - 1)
72 72
73#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK])) 73static inline struct hlist_head *stripe_hash(raid5_conf_t *conf, sector_t sect)
74{
75 int hash = (sect >> STRIPE_SHIFT) & HASH_MASK;
76 return &conf->stripe_hashtbl[hash];
77}
74 78
75/* bio's attached to a stripe+device for I/O are linked together in bi_sector 79/* bio's attached to a stripe+device for I/O are linked together in bi_sector
76 * order without overlap. There may be several bio's per stripe+device, and 80 * order without overlap. There may be several bio's per stripe+device, and
@@ -78,10 +82,17 @@
78 * When walking this list for a particular stripe+device, we must never proceed 82 * When walking this list for a particular stripe+device, we must never proceed
79 * beyond a bio that extends past this device, as the next bio might no longer 83 * beyond a bio that extends past this device, as the next bio might no longer
80 * be valid. 84 * be valid.
81 * This macro is used to determine the 'next' bio in the list, given the sector 85 * This function is used to determine the 'next' bio in the list, given the sector
82 * of the current stripe+device 86 * of the current stripe+device
83 */ 87 */
84#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL) 88static inline struct bio *r5_next_bio(struct bio *bio, sector_t sector)
89{
90 int sectors = bio->bi_size >> 9;
91 if (bio->bi_sector + sectors < sector + STRIPE_SECTORS)
92 return bio->bi_next;
93 else
94 return NULL;
95}
85/* 96/*
86 * The following can be used to debug the driver 97 * The following can be used to debug the driver
87 */ 98 */