Skip to content

Commit

Permalink
Support exfat capacity more than 2TB
Browse files Browse the repository at this point in the history
- Change the size of num_sectors in memory to 64 bits as it is in on-disk
  structure.
- Use type 'sector_t' for all sector variables.
- Fix overflow issue of macro START_SECTOR(x)

Reviewed-by: Peter Huang <[email protected]>
Signed-off-by: Chung-Chiang Cheng <[email protected]>
  • Loading branch information
ethanwu-syno authored and cccheng committed Dec 18, 2016
1 parent a877c79 commit 557527e
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 95 deletions.
4 changes: 2 additions & 2 deletions exfat_blkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ s32 bdev_close(struct super_block *sb)
return FFS_SUCCESS;
}

s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read)
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read)
{
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down Expand Up @@ -126,7 +126,7 @@ s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 nu
return FFS_MEDIAERR;
}

s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync)
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync)
{
s32 count;
struct buffer_head *bh2;
Expand Down
4 changes: 2 additions & 2 deletions exfat_blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ s32 bdev_init(void);
s32 bdev_shutdown(void);
s32 bdev_open(struct super_block *sb);
s32 bdev_close(struct super_block *sb);
s32 bdev_read(struct super_block *sb, u32 secno, struct buffer_head **bh, u32 num_secs, s32 read);
s32 bdev_write(struct super_block *sb, u32 secno, struct buffer_head *bh, u32 num_secs, s32 sync);
s32 bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, s32 read);
s32 bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, s32 sync);
s32 bdev_sync(struct super_block *sb);

#endif /* _EXFAT_BLKDEV_H */
48 changes: 26 additions & 22 deletions exfat_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content);
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content);

static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec);
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, u32 sec);
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec);
static void FAT_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void FAT_cache_remove_hash(BUF_CACHE_T *bp);

static u8 *__buf_getblk(struct super_block *sb, u32 sec);
static u8 *__buf_getblk(struct super_block *sb, sector_t sec);

static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec);
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, u32 sec);
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec);
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec);
static void buf_cache_insert_hash(struct super_block *sb, BUF_CACHE_T *bp);
static void buf_cache_remove_hash(BUF_CACHE_T *bp);

Expand Down Expand Up @@ -165,7 +165,8 @@ s32 FAT_write(struct super_block *sb, u32 loc, u32 content)
static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content)
{
s32 off;
u32 sec, _content;
u32 _content;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
Expand Down Expand Up @@ -276,7 +277,7 @@ static s32 __FAT_read(struct super_block *sb, u32 loc, u32 *content)
static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content)
{
s32 off;
u32 sec;
sector_t sec;
u8 *fat_sector, *fat_entry;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
BD_INFO_T *p_bd = &(EXFAT_SB(sb)->bd_info);
Expand Down Expand Up @@ -381,7 +382,7 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content)
return 0;
} /* end of __FAT_write */

u8 *FAT_getblk(struct super_block *sb, u32 sec)
u8 *FAT_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down Expand Up @@ -416,7 +417,7 @@ u8 *FAT_getblk(struct super_block *sb, u32 sec)
return bp->buf_bh->b_data;
} /* end of FAT_getblk */

void FAT_modify(struct super_block *sb, u32 sec)
void FAT_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;

Expand Down Expand Up @@ -469,7 +470,7 @@ void FAT_sync(struct super_block *sb)
sm_V(&f_sem);
} /* end of FAT_sync */

static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec)
static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
Expand All @@ -491,7 +492,7 @@ static BUF_CACHE_T *FAT_cache_find(struct super_block *sb, u32 sec)
return NULL;
} /* end of FAT_cache_find */

static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, u32 sec)
static BUF_CACHE_T *FAT_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down Expand Up @@ -529,7 +530,7 @@ static void FAT_cache_remove_hash(BUF_CACHE_T *bp)
/* Buffer Read/Write Functions */
/*======================================================================*/

u8 *buf_getblk(struct super_block *sb, u32 sec)
u8 *buf_getblk(struct super_block *sb, sector_t sec)
{
u8 *buf;

Expand All @@ -542,7 +543,7 @@ u8 *buf_getblk(struct super_block *sb, u32 sec)
return buf;
} /* end of buf_getblk */

static u8 *__buf_getblk(struct super_block *sb, u32 sec)
static u8 *__buf_getblk(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down Expand Up @@ -578,7 +579,7 @@ static u8 *__buf_getblk(struct super_block *sb, u32 sec)

} /* end of __buf_getblk */

void buf_modify(struct super_block *sb, u32 sec)
void buf_modify(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;

Expand All @@ -588,12 +589,13 @@ void buf_modify(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
sector_write(sb, sec, bp->buf_bh, 0);

WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);

sm_V(&b_sem);
} /* end of buf_modify */

void buf_lock(struct super_block *sb, u32 sec)
void buf_lock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;

Expand All @@ -603,12 +605,13 @@ void buf_lock(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
bp->flag |= LOCKBIT;

WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);

sm_V(&b_sem);
} /* end of buf_lock */

void buf_unlock(struct super_block *sb, u32 sec)
void buf_unlock(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;

Expand All @@ -618,12 +621,13 @@ void buf_unlock(struct super_block *sb, u32 sec)
if (likely(bp != NULL))
bp->flag &= ~(LOCKBIT);

WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%u).\n", sec);
WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n",
(unsigned long long)sec);

sm_V(&b_sem);
} /* end of buf_unlock */

void buf_release(struct super_block *sb, u32 sec)
void buf_release(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down Expand Up @@ -691,7 +695,7 @@ void buf_sync(struct super_block *sb)
sm_V(&b_sem);
} /* end of buf_sync */

static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec)
static BUF_CACHE_T *buf_cache_find(struct super_block *sb, sector_t sec)
{
s32 off;
BUF_CACHE_T *bp, *hp;
Expand All @@ -709,7 +713,7 @@ static BUF_CACHE_T *buf_cache_find(struct super_block *sb, u32 sec)
return NULL;
} /* end of buf_cache_find */

static BUF_CACHE_T *buf_cache_get(struct super_block *sb, u32 sec)
static BUF_CACHE_T *buf_cache_get(struct super_block *sb, sector_t sec)
{
BUF_CACHE_T *bp;
FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info);
Expand Down
16 changes: 8 additions & 8 deletions exfat_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct __BUF_CACHE_T {
struct __BUF_CACHE_T *hash_next;
struct __BUF_CACHE_T *hash_prev;
s32 drv;
u32 sec;
sector_t sec;
u32 flag;
struct buffer_head *buf_bh;
} BUF_CACHE_T;
Expand All @@ -70,15 +70,15 @@ s32 buf_init(struct super_block *sb);
s32 buf_shutdown(struct super_block *sb);
s32 FAT_read(struct super_block *sb, u32 loc, u32 *content);
s32 FAT_write(struct super_block *sb, u32 loc, u32 content);
u8 *FAT_getblk(struct super_block *sb, u32 sec);
void FAT_modify(struct super_block *sb, u32 sec);
u8 *FAT_getblk(struct super_block *sb, sector_t sec);
void FAT_modify(struct super_block *sb, sector_t sec);
void FAT_release_all(struct super_block *sb);
void FAT_sync(struct super_block *sb);
u8 *buf_getblk(struct super_block *sb, u32 sec);
void buf_modify(struct super_block *sb, u32 sec);
void buf_lock(struct super_block *sb, u32 sec);
void buf_unlock(struct super_block *sb, u32 sec);
void buf_release(struct super_block *sb, u32 sec);
u8 *buf_getblk(struct super_block *sb, sector_t sec);
void buf_modify(struct super_block *sb, sector_t sec);
void buf_lock(struct super_block *sb, sector_t sec);
void buf_unlock(struct super_block *sb, sector_t sec);
void buf_release(struct super_block *sb, sector_t sec);
void buf_release_all(struct super_block *sb);
void buf_sync(struct super_block *sb);

Expand Down
Loading

0 comments on commit 557527e

Please sign in to comment.