-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exfat next misc #18
Open
mat-c
wants to merge
5
commits into
namjaejeon:exfat-next
Choose a base branch
from
mat-c:exfat-next-misc
base: exfat-next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Exfat next misc #18
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e87a9e9
exfat: introduce bitmap_lock for cluster bitmap access
hyeongseok-kim901 89965a9
exfat: add support ioctl and FITRIM function
hyeongseok-kim901 1e8bd20
exfat: add FITRIM ioctl tests
namjaejeon f92ec6d
Check validity of FAT in exfat_ent_set
8576ad7
Add missing () in FAT_ENT_OFFSET_x macro
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,13 +62,28 @@ static int __exfat_ent_get(struct super_block *sb, unsigned int loc, | |
return 0; | ||
} | ||
|
||
static inline bool is_valid_cluster(struct exfat_sb_info *sbi, | ||
unsigned int clus) | ||
{ | ||
if (clus < EXFAT_FIRST_CLUSTER || sbi->num_clusters <= clus) | ||
return false; | ||
return true; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add patch description why this patch is needed. and if you think this patch is needed from exfat in kernel mainline, Can you send the patch to LKML ? |
||
int exfat_ent_set(struct super_block *sb, unsigned int loc, | ||
unsigned int content) | ||
{ | ||
unsigned int off; | ||
sector_t sec; | ||
__le32 *fat_entry; | ||
struct buffer_head *bh; | ||
struct exfat_sb_info *sbi = EXFAT_SB(sb); | ||
|
||
if (!is_valid_cluster(sbi, loc)) { | ||
exfat_fs_error(sb, "invalid write to FAT (entry 0x%08x)", | ||
loc); | ||
return -EIO; | ||
} | ||
|
||
sec = FAT_ENT_OFFSET_SECTOR(sb, loc); | ||
off = FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc); | ||
|
@@ -89,14 +104,6 @@ int exfat_ent_set(struct super_block *sb, unsigned int loc, | |
return 0; | ||
} | ||
|
||
static inline bool is_valid_cluster(struct exfat_sb_info *sbi, | ||
unsigned int clus) | ||
{ | ||
if (clus < EXFAT_FIRST_CLUSTER || sbi->num_clusters <= clus) | ||
return false; | ||
return true; | ||
} | ||
|
||
int exfat_ent_get(struct super_block *sb, unsigned int loc, | ||
unsigned int *content) | ||
{ | ||
|
@@ -159,13 +166,14 @@ int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain, | |
return 0; | ||
} | ||
|
||
int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) | ||
/* This function must be called with bitmap_lock held */ | ||
static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) | ||
{ | ||
unsigned int num_clusters = 0; | ||
unsigned int clu; | ||
struct super_block *sb = inode->i_sb; | ||
struct exfat_sb_info *sbi = EXFAT_SB(sb); | ||
int cur_cmap_i, next_cmap_i; | ||
unsigned int num_clusters = 0; | ||
unsigned int clu; | ||
|
||
/* invalid cluster number */ | ||
if (p_chain->dir == EXFAT_FREE_CLUSTER || | ||
|
@@ -238,6 +246,17 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) | |
return 0; | ||
} | ||
|
||
int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) | ||
{ | ||
int ret = 0; | ||
|
||
mutex_lock(&EXFAT_SB(inode->i_sb)->bitmap_lock); | ||
ret = __exfat_free_cluster(inode, p_chain); | ||
mutex_unlock(&EXFAT_SB(inode->i_sb)->bitmap_lock); | ||
|
||
return ret; | ||
} | ||
|
||
int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain, | ||
unsigned int *ret_clu) | ||
{ | ||
|
@@ -336,6 +355,8 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, | |
if (num_alloc > total_cnt - sbi->used_clusters) | ||
return -ENOSPC; | ||
|
||
mutex_lock(&sbi->bitmap_lock); | ||
|
||
hint_clu = p_chain->dir; | ||
/* find new cluster */ | ||
if (hint_clu == EXFAT_EOF_CLUSTER) { | ||
|
@@ -346,8 +367,10 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, | |
} | ||
|
||
hint_clu = exfat_find_free_bitmap(sb, sbi->clu_srch_ptr); | ||
if (hint_clu == EXFAT_EOF_CLUSTER) | ||
return -ENOSPC; | ||
if (hint_clu == EXFAT_EOF_CLUSTER) { | ||
ret = -ENOSPC; | ||
goto unlock; | ||
} | ||
} | ||
|
||
/* check cluster validation */ | ||
|
@@ -357,8 +380,10 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, | |
hint_clu = EXFAT_FIRST_CLUSTER; | ||
if (p_chain->flags == ALLOC_NO_FAT_CHAIN) { | ||
if (exfat_chain_cont_cluster(sb, p_chain->dir, | ||
num_clusters)) | ||
return -EIO; | ||
num_clusters)) { | ||
ret = -EIO; | ||
goto unlock; | ||
} | ||
p_chain->flags = ALLOC_FAT_CHAIN; | ||
} | ||
} | ||
|
@@ -408,6 +433,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, | |
sbi->used_clusters += num_clusters; | ||
|
||
p_chain->size += num_clusters; | ||
mutex_unlock(&sbi->bitmap_lock); | ||
return 0; | ||
} | ||
|
||
|
@@ -427,7 +453,9 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, | |
} | ||
free_cluster: | ||
if (num_clusters) | ||
exfat_free_cluster(inode, p_chain); | ||
__exfat_free_cluster(inode, p_chain); | ||
unlock: | ||
mutex_unlock(&sbi->bitmap_lock); | ||
return ret; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no description in patch why you add () in macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am doing some patches, to do some optimization.
If I use FAT_ENT_OFFSET_BYTE_IN_SECTOR with an expression, it fails.
I will update the patch.