Permalink
Browse files

Support exfat capacity more than 2TB

- 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 <peterh@synology.com>
Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com>
  • Loading branch information...
Ethan Wu authored and cccheng committed Dec 17, 2016
1 parent a877c79 commit 557527eea7a7e57a7fd092c003abc72e15ca9256
Showing with 112 additions and 95 deletions.
  1. +2 −2 exfat_blkdev.c
  2. +2 −2 exfat_blkdev.h
  3. +26 −22 exfat_cache.c
  4. +8 −8 exfat_cache.h
  5. +63 −50 exfat_core.c
  6. +11 −11 exfat_core.h
View
@@ -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);
@@ -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;
View
@@ -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 */
View
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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);
View
@@ -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;
@@ -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);
Oops, something went wrong.

1 comment on commit 557527e

@jcadduono

This comment has been minimized.

Show comment
Hide comment
@jcadduono

jcadduono Jan 22, 2017

"Change the size of num_sectors in memory to 64 bits as it is in on-disk structure."

where did you find this? i am seeing it stored in partition entry as uint8_t num_sectors[4]

jcadduono commented on 557527e Jan 22, 2017

"Change the size of num_sectors in memory to 64 bits as it is in on-disk structure."

where did you find this? i am seeing it stored in partition entry as uint8_t num_sectors[4]

Please sign in to comment.