Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Coding style fixes
Browse files Browse the repository at this point in the history
Signed-off-by: sanoj <sunnikrishnan@stec-inc.com>
  • Loading branch information
sanoj-stec committed Apr 25, 2013
1 parent af1cba7 commit eb7a57b
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 183 deletions.
16 changes: 5 additions & 11 deletions Driver/enhanceio/eio.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ struct eio_policy_and_name {


static const struct eio_policy_and_name eio_policy_names[] = {
{ CACHE_REPL_FIFO, "fifo" },
{ CACHE_REPL_LRU, "lru" },
{ CACHE_REPL_RANDOM, "rand" },
{ CACHE_REPL_FIFO, "fifo" },
{ CACHE_REPL_LRU, "lru" },
{ CACHE_REPL_RANDOM, "rand" },
};


Expand Down Expand Up @@ -1112,10 +1112,7 @@ extern sector_t eio_get_device_size(struct eio_bdev *);
extern sector_t eio_get_device_start_sect(struct eio_bdev *);
#endif /* __KERNEL__ */

#define EIO_INIT_EVENT(ev) \
do { \
(ev)->process = NULL; \
} while (0)
#define EIO_INIT_EVENT(ev) ((ev)->process = NULL)

/*Assumes that the macro gets called under the same spinlock as in wait event*/
#define EIO_SET_EVENT_AND_UNLOCK(ev, sl, flags) \
Expand All @@ -1142,10 +1139,7 @@ extern sector_t eio_get_device_start_sect(struct eio_bdev *);
(ev)->process = NULL; \
} while (0)

#define EIO_CLEAR_EVENT(ev) \
do { \
(ev)->process = NULL; \
} while (0)
#define EIO_CLEAR_EVENT(ev) ((ev)->process = NULL)

#include "eio_setlru.h"
#include "eio_policy.h"
Expand Down
45 changes: 21 additions & 24 deletions Driver/enhanceio/eio_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define KMEM_DMC_BIO_PAIR "eio-dmc-bio-pair"
/* #define KMEM_CACHE_PENDING_JOB "eio-pending-jobs" */

static struct cache_c *cache_list_head = NULL;
static struct cache_c *cache_list_head;
struct work_struct _kcached_wq;

static struct kmem_cache *_job_cache;
Expand Down Expand Up @@ -80,7 +80,7 @@ static int eio_notify_ssd_rm(struct notifier_block *nb, unsigned long action,
static struct notifier_block eio_reboot_notifier = {
.notifier_call = eio_notify_reboot,
.next = NULL,
.priority = INT_MAX, /* should be > ssd pri's and disk dev pri's */
.priority = INT_MAX, /* should be > ssd pri's and disk dev pri's */
};

static struct notifier_block eio_ssd_rm_notifier = {
Expand Down Expand Up @@ -662,7 +662,8 @@ static int eio_md_create(struct cache_c *dmc, int force, int cold)
dmc->md_sectors +=
EIO_EXTRA_SECTORS(dmc->cache_dev_start_sect, dmc->md_sectors);

if ((error = eio_mem_init(dmc)) == -1) {
error = eio_mem_init(dmc);
if (error == -1) {
ret = -EINVAL;
goto free_header;
}
Expand Down Expand Up @@ -711,11 +712,9 @@ static int eio_md_create(struct cache_c *dmc, int force, int cold)
*/
if (!CACHE_SSD_ADD_INPROG_IS_SET(dmc)) {
if (EIO_MD8(dmc))
dmc->cache_md8 =
(struct cacheblock_md8 *)vmalloc((size_t)order);
dmc->cache_md8 = vmalloc((size_t)order);
else
dmc->cache =
(struct cacheblock *)vmalloc((size_t)order);
dmc->cache = vmalloc((size_t)order);
if ((EIO_MD8(dmc) && !dmc->cache_md8)
|| (!EIO_MD8(dmc) && !dmc->cache)) {
pr_err
Expand Down Expand Up @@ -1148,7 +1147,8 @@ static int eio_md_load(struct cache_c *dmc)
dmc->sysctl_active.autoclean_threshold =
le32_to_cpu(header->sbf.autoclean_threshold);

if ((i = eio_mem_init(dmc)) == -1) {
i = eio_mem_init(dmc);
if (i == -1) {
pr_err("eio_md_load: Failed to initialize memory.");
ret = -EINVAL;
goto free_header;
Expand All @@ -1171,10 +1171,9 @@ static int eio_md_load(struct cache_c *dmc)
dmc->assoc, dmc->block_size << SECTOR_SHIFT);

if (EIO_MD8(dmc))
dmc->cache_md8 =
(struct cacheblock_md8 *)vmalloc((size_t)order);
dmc->cache_md8 = vmalloc((size_t)order);
else
dmc->cache = (struct cacheblock *)vmalloc((size_t)order);
dmc->cache = vmalloc((size_t)order);

if ((EIO_MD8(dmc) && !dmc->cache_md8) || (!EIO_MD8(dmc) && !dmc->cache)) {
pr_err("md_load: Unable to allocate memory");
Expand Down Expand Up @@ -1472,7 +1471,7 @@ int eio_cache_create(struct cache_rec_short *cache)
fmode_t mode = (FMODE_READ | FMODE_WRITE);
char *strerr = NULL;

dmc = (struct cache_c *)kzalloc(sizeof(*dmc), GFP_KERNEL);
dmc = kzalloc(sizeof(*dmc), GFP_KERNEL);
if (dmc == NULL) {
strerr = "Failed to allocate memory for cache context";
error = -ENOMEM;
Expand All @@ -1493,8 +1492,8 @@ int eio_cache_create(struct cache_rec_short *cache)
strerr = "Failed to lookup source device";
goto bad1;
}
if ((dmc->disk_size =
eio_to_sector(eio_get_device_size(dmc->disk_dev))) >= EIO_MAX_SECTOR) {
dmc->disk_size = eio_to_sector(eio_get_device_size(dmc->disk_dev));
if (dmc->disk_size >= EIO_MAX_SECTOR) {
strerr = "Source device too big to support";
error = -EFBIG;
goto bad2;
Expand Down Expand Up @@ -1794,7 +1793,7 @@ int eio_cache_create(struct cache_rec_short *cache)
goto bad5;
}

dmc->cache_sets = (struct cache_set *)vmalloc((size_t)order);
dmc->cache_sets = vmalloc((size_t)order);
if (!dmc->cache_sets) {
strerr = "Failed to allocate memory";
error = -ENOMEM;
Expand Down Expand Up @@ -2255,9 +2254,8 @@ int eio_allocate_wb_resources(struct cache_c *dmc)
/* Data page allocations are done in terms of "bio_vec" structures */
iosize = (dmc->block_size * dmc->assoc) << SECTOR_SHIFT;
nr_bvecs = IO_BVEC_COUNT(iosize, dmc->block_size);
dmc->clean_dbvecs =
(struct bio_vec *)kmalloc(sizeof(struct bio_vec) * nr_bvecs,
GFP_KERNEL);
dmc->clean_dbvecs = kmalloc(sizeof(struct bio_vec) * nr_bvecs,
GFP_KERNEL);
if (dmc->clean_dbvecs == NULL) {
pr_err("cache_create: Failed to allocated memory.\n");
ret = -ENOMEM;
Expand All @@ -2273,9 +2271,8 @@ int eio_allocate_wb_resources(struct cache_c *dmc)
/* Metadata page allocations are done in terms of pages only */
iosize = dmc->assoc * sizeof(struct flash_cacheblock);
nr_pages = IO_PAGE_COUNT(iosize);
dmc->clean_mdpages =
(struct page **)kmalloc(sizeof(struct page *) * nr_pages,
GFP_KERNEL);
dmc->clean_mdpages = kmalloc(sizeof(struct page *) * nr_pages,
GFP_KERNEL);
if (dmc->clean_mdpages == NULL) {
pr_err("cache_create: Failed to allocated memory.\n");
ret = -ENOMEM;
Expand Down Expand Up @@ -2481,8 +2478,8 @@ eio_notify_ssd_rm(struct notifier_block *nb, unsigned long action, void *data)

if (!scsi_is_sdev_device(dev))
return 0;

if ((device_name = dev_name(dev)) == NULL)
device_name = dev_name(dev);
if (device_name == NULL)
return 0;
len = strlen(device_name);

Expand Down Expand Up @@ -2562,7 +2559,7 @@ static int __init eio_init(void)
INIT_WORK(&_kcached_wq, eio_do_work);

eio_module_procfs_init();
eio_control = kmalloc(sizeof *eio_control, GFP_KERNEL);
eio_control = kmalloc(sizeof(*eio_control), GFP_KERNEL);
if (eio_control == NULL) {
pr_err("init: Cannot allocate memory for eio_control");
(void)eio_delete_misc_device();
Expand Down
5 changes: 2 additions & 3 deletions Driver/enhanceio/eio_fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ int eio_fifo_cache_sets_init(struct eio_policy *p_ops)
order = (dmc->size >> dmc->consecutive_shift) *
sizeof(struct eio_fifo_cache_set);

dmc->sp_cache_set =
(struct eio_fifo_cache_set *)vmalloc((size_t)order);
dmc->sp_cache_set = vmalloc((size_t)order);
if (dmc->sp_cache_set == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -178,7 +177,7 @@ struct eio_policy *eio_fifo_instance_init(void)
{
struct eio_policy *new_instance;

new_instance = (struct eio_policy *)vmalloc(sizeof(struct eio_policy));
new_instance = vmalloc(sizeof(struct eio_policy));
if (new_instance == NULL) {
pr_err("ssdscache_fifo_instance_init: vmalloc failed");
return NULL;
Expand Down
7 changes: 3 additions & 4 deletions Driver/enhanceio/eio_lru.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int eio_lru_cache_sets_init(struct eio_policy *p_ops)
(dmc->size >> dmc->consecutive_shift) *
sizeof(struct eio_lru_cache_set);

dmc->sp_cache_set = (struct eio_lru_cache_set *)vmalloc((size_t)order);
dmc->sp_cache_set = vmalloc((size_t)order);
if (dmc->sp_cache_set == NULL)
return -ENOMEM;

Expand All @@ -115,8 +115,7 @@ int eio_lru_cache_blk_init(struct eio_policy *p_ops)

order = dmc->size * sizeof(struct eio_lru_cache_block);

dmc->sp_cache_blk =
(struct eio_lru_cache_block *)vmalloc((size_t)order);
dmc->sp_cache_blk = vmalloc((size_t)order);
if (dmc->sp_cache_blk == NULL)
return -ENOMEM;

Expand All @@ -130,7 +129,7 @@ struct eio_policy *eio_lru_instance_init(void)
{
struct eio_policy *new_instance;

new_instance = (struct eio_policy *)vmalloc(sizeof(struct eio_policy));
new_instance = vmalloc(sizeof(struct eio_policy));
if (new_instance == NULL) {
pr_err("eio_lru_instance_init: vmalloc failed");
return NULL;
Expand Down
67 changes: 14 additions & 53 deletions Driver/enhanceio/eio_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ eio_io_async_bvec(struct cache_c *dmc, struct eio_io_region *where, int rw,
struct eio_io_request req;
int error = 0;

memset((char *)&req, 0, sizeof req);
memset((char *)&req, 0, sizeof(req));

if (unlikely(CACHE_DEGRADED_IS_SET(dmc))) {
if (where->bdev != dmc->disk_dev->bdev) {
Expand Down Expand Up @@ -462,9 +462,9 @@ static void eio_post_io_callback(struct work_struct *work)
if (unlikely(error))
dmc->eio_errors.ssd_write_errors++;
if (!(EIO_CACHE_STATE_GET(dmc, index) & CACHEWRITEINPROG)) {
printk(KERN_DEBUG
"DISKWRITEINPROG absent in READFILL sector %llu io size %u\n",
(unsigned long long)ebio->eb_sector,
pr_debug("DISKWRITEINPROG absent in READFILL \
sector %llu io size %u\n",
(unsigned long long)ebio->eb_sector,
ebio->eb_size);
}
callendio = 1;
Expand Down Expand Up @@ -1772,42 +1772,6 @@ eio_invalidate_sanity_check(struct cache_c *dmc, u_int64_t iosector,
return 0;
}

#if defined (VMCACHE)
int
eio_invalidate_sector_range(char *cache_name, u_int64_t iosector,
u_int64_t num_sectors)
{
struct cache_c *dmc;
int ret;

dmc = eio_find_cache(cache_name);

if (dmc == NULL) {
pr_err
("invalidate_sector_range: cache object with name=%s does not exist.",
cache_name);
return -EINVAL;
}

ret = eio_invalidate_sanity_check(dmc, iosector, &num_sectors);

if (ret == 0)
eio_inval_range(dmc, iosector, (unsigned)to_bytes(num_sectors));
else
return ret;

if (CACHE_VERBOSE_IS_SET(dmc)) {
pr_info
("eio_inval_range: Invalidated sector range from sector=%lu to sector=%lu",
(long unsigned int)iosector,
(long unsigned int)num_sectors);
}

return ret;
}
EXPORT_SYMBOL(eio_invalidate_sector_range);
#endif /* VMCACHE */

void eio_inval_range(struct cache_c *dmc, sector_t iosector, unsigned iosize)
{
u_int32_t bset;
Expand Down Expand Up @@ -2510,7 +2474,7 @@ int eio_map(struct cache_c *dmc, struct request_queue *rq, struct bio *bio)

EIO_ASSERT(bio->bi_idx == 0);

pr_debug("this needs to be removed immediately \n");
pr_debug("this needs to be removed immediately\n");

if (bio_rw_flagged(bio, REQ_DISCARD)) {
pr_debug
Expand Down Expand Up @@ -2599,7 +2563,8 @@ int eio_map(struct cache_c *dmc, struct request_queue *rq, struct bio *bio)
* lock on the cache set for app I/Os and exclusive
* lock on the cache set for clean I/Os.
*/
if ((ret = eio_acquire_set_locks(dmc, bc)) != 0) {
ret = eio_acquire_set_locks(dmc, bc);
if (ret) {
bio_endio(bio, ret);
kfree(bc);
return DM_MAPIO_SUBMITTED;
Expand All @@ -2620,13 +2585,9 @@ int eio_map(struct cache_c *dmc, struct request_queue *rq, struct bio *bio)
else {
while (biosize) {
iosize = eio_get_iosize(dmc, snum, biosize);

if (IS_ERR
(ebio =
eio_new_ebio(dmc, bio,
&residual_biovec, snum,
iosize, bc,
EB_SUBORDINATE_IO))) {
ebio = eio_new_ebio(dmc, bio, &residual_biovec, snum,
iosize, bc, EB_SUBORDINATE_IO);
if (IS_ERR(ebio)) {
bc->bc_error = -ENOMEM;
break;
}
Expand Down Expand Up @@ -3098,7 +3059,7 @@ void eio_clean_all(struct cache_c *dmc)
}

eio_clean_set(dmc, (index_t)(atomic_read(&dmc->clean_index)),
/* whole */ 1, /* force */ 1);
/* whole */ 1, /* force */ 1);
}

spin_lock_irqsave(&dmc->cache_spin_lock, flags);
Expand Down Expand Up @@ -3301,9 +3262,9 @@ eio_clean_set(struct cache_c *dmc, index_t set, int whole, int force)
for (i = start_index; i < end_index; i++) {
if (EIO_CACHE_STATE_GET(dmc, i) == CLEAN_INPROG) {

for (j = i; (j < end_index) &&
(EIO_CACHE_STATE_GET(dmc, j) == CLEAN_INPROG);
j++) ;
for (j = i; ((j < end_index) &&
(EIO_CACHE_STATE_GET(dmc, j) == CLEAN_INPROG));
j++);

blkindex = (i - start_index);
total = (j - i);
Expand Down
5 changes: 2 additions & 3 deletions Driver/enhanceio/eio_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ int eio_mem_init(struct cache_c *dmc)
* its corresponding mask value.
*/
dmc->num_sets = (u_int32_t)num_sets_64;
for (dmc->num_sets_bits = 0;
(dmc->num_sets >> dmc->num_sets_bits) != 0;
dmc->num_sets_bits++) ;
for (dmc->num_sets_bits = 0; (dmc->num_sets >> dmc->num_sets_bits);
dmc->num_sets_bits++);

dmc->num_sets_mask = ULLONG_MAX >> (64 - dmc->num_sets_bits);

Expand Down

0 comments on commit eb7a57b

Please sign in to comment.