Skip to content

Commit db298e1

Browse files
committed
md/raid5: convert to macros into inline functions.
More type-safety. Easier to read. Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 0fc280f commit db298e1

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎drivers/md/raid5.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,29 @@
7070
#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head))
7171
#define HASH_MASK (NR_HASH - 1)
7272

73-
#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]))
73+
static 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+
}
7478

7579
/* bio's attached to a stripe+device for I/O are linked together in bi_sector
7680
* order without overlap. There may be several bio's per stripe+device, and
7781
* a bio could span several devices.
7882
* When walking this list for a particular stripe+device, we must never proceed
7983
* beyond a bio that extends past this device, as the next bio might no longer
8084
* 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
8286
* of the current stripe+device
8387
*/
84-
#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL)
88+
static 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+
}
8596
/*
8697
* The following can be used to debug the driver
8798
*/

0 commit comments

Comments
 (0)