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

Commit

Permalink
Fixes for Big endian support
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 May 3, 2013
1 parent eb7a57b commit 7d7221a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
34 changes: 18 additions & 16 deletions Driver/enhanceio/eio.h
Expand Up @@ -309,8 +309,8 @@ union eio_superblock {
* load every block back into cache on a restart.
*/
struct flash_cacheblock {
sector_t dbn; /* Sector number of the cached block */
u_int64_t cache_state;
__le64 dbn; /* Sector number of the cached block */
__le64 cache_state;
};

/* blksize in terms of no. of sectors */
Expand Down Expand Up @@ -504,21 +504,23 @@ typedef void (*eio_notify_fn)(int error, void *context);
*/

#define EIO_MAX_SECTOR (((u_int64_t)1) << 40)

#ifdef __BIG_ENDIAN
struct md4 {
u_int8_t cache_state;
char dbn_bytes[3];
};
#else /* Little Endian */
struct md4 {
u_int16_t bytes1_2;
u_int8_t byte3;
char dbn_bytes[3];
u_int8_t cache_state;
};
#endif

struct cacheblock {
union {
u_int32_t u_i_md4;
struct md4 u_s_md4;
} md4_u;
#ifdef DO_CHECKSUM
u_int64_t checksum;
#endif /* DO_CHECKSUM */
};

#define EIO_MD4_DBN_BITS (32 - 8) /* 8 bits for state */
Expand All @@ -528,22 +530,22 @@ struct cacheblock {
/*
* 8-byte metadata support.
*/

#ifdef __BIG_ENDIAN
struct md8 {
u_int32_t bytes1_4;
u_int16_t bytes5_6;
u_int8_t byte7;
u_int8_t cache_state;
char dbn_bytes[7];
};

#else /* little endian*/
struct md8 {
char dbn_bytes[7];
u_int8_t cache_state;
};
#endif
struct cacheblock_md8 {
union {
u_int64_t u_i_md8;
struct md8 u_s_md8;
} md8_u;
#ifdef DO_CHECKSUM
u_int64_t checksum;
#endif /* DO_CHECKSUM */
};

#define EIO_MD8_DBN_BITS (64 - 8) /* 8 bits for state */
Expand Down
21 changes: 10 additions & 11 deletions Driver/enhanceio/eio_conf.c
Expand Up @@ -426,9 +426,9 @@ int eio_md_store(struct cache_c *dmc)
num_valid++;
if (EIO_CACHE_STATE_GET(dmc, (index_t)i) & DIRTY)
num_dirty++;
next_ptr->dbn = EIO_DBN_GET(dmc, i);
next_ptr->cache_state = EIO_CACHE_STATE_GET(dmc, (index_t)i) &
(INVALID | VALID | DIRTY);
next_ptr->dbn = cpu_to_le64(EIO_DBN_GET(dmc, i));
next_ptr->cache_state = cpu_to_le64(EIO_CACHE_STATE_GET(dmc, (index_t)i) &
(INVALID | VALID | DIRTY));

next_ptr++;
slots_written++;
Expand Down Expand Up @@ -795,11 +795,10 @@ static int eio_md_create(struct cache_c *dmc, int force, int cold)
j = MD_BLOCKS_PER_PAGE;

for (i = 0; i < dmc->size; i++) {
next_ptr->dbn = EIO_DBN_GET(dmc, i);
next_ptr->cache_state =
EIO_CACHE_STATE_GET(dmc,
(index_t)i) & (INVALID | VALID
| DIRTY);
next_ptr->dbn = cpu_to_le64(EIO_DBN_GET(dmc, i));
next_ptr->cache_state =
cpu_to_le64(EIO_CACHE_STATE_GET(dmc,
(index_t)i) & (INVALID | VALID | DIRTY));
next_ptr++;
slots_written++;
j--;
Expand Down Expand Up @@ -1272,16 +1271,16 @@ static int eio_md_load(struct cache_c *dmc)
dirty_loaded++;

EIO_CACHE_STATE_SET(dmc, i,
(u_int8_t)next_ptr->
cache_state & ~QUEUED);
(u_int8_t)le64_to_cpu(next_ptr->
cache_state) & ~QUEUED);

EIO_ASSERT((EIO_CACHE_STATE_GET(dmc, i) &
(VALID | INVALID))
!= (VALID | INVALID));

if (EIO_CACHE_STATE_GET(dmc, i) & VALID)
num_valid++;
EIO_DBN_SET(dmc, i, next_ptr->dbn);
EIO_DBN_SET(dmc, i, le64_to_cpu(next_ptr->dbn));
} else
eio_invalidate_md(dmc, i);
next_ptr++;
Expand Down
14 changes: 7 additions & 7 deletions Driver/enhanceio/eio_main.c
Expand Up @@ -1214,11 +1214,11 @@ static void eio_do_mdupdate(struct work_struct *work)
/* initialize the md blocks to write */
for (i = start_index; i < end_index; i++) {
cstate = EIO_CACHE_STATE_GET(dmc, i);
md_blocks->dbn = EIO_DBN_GET(dmc, i);
md_blocks->dbn = cpu_to_le64(EIO_DBN_GET(dmc, i));
if (cstate == ALREADY_DIRTY)
md_blocks->cache_state = (VALID | DIRTY);
md_blocks->cache_state = cpu_to_le64((VALID | DIRTY));
else
md_blocks->cache_state = INVALID;
md_blocks->cache_state = cpu_to_le64(INVALID);
md_blocks++;
j--;

Expand Down Expand Up @@ -3381,14 +3381,14 @@ eio_clean_set(struct cache_c *dmc, index_t set, int whole, int force)

for (i = start_index; i < end_index; i++) {

md_blocks->dbn = EIO_DBN_GET(dmc, i);
md_blocks->dbn = cpu_to_le64(EIO_DBN_GET(dmc, i));

if (EIO_CACHE_STATE_GET(dmc, i) == CLEAN_INPROG)
md_blocks->cache_state = INVALID;
md_blocks->cache_state = cpu_to_le64(INVALID);
else if (EIO_CACHE_STATE_GET(dmc, i) == ALREADY_DIRTY)
md_blocks->cache_state = (VALID | DIRTY);
md_blocks->cache_state = cpu_to_le64((VALID | DIRTY));
else
md_blocks->cache_state = INVALID;
md_blocks->cache_state = cpu_to_le64(INVALID);

/* This was missing earlier. */
md_blocks++;
Expand Down

0 comments on commit 7d7221a

Please sign in to comment.