linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] exfat: minor cleanup changes
@ 2021-11-02 21:23 Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 1/4] exfat: simplify is_valid_cluster() Christophe Vu-Brugier
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christophe Vu-Brugier @ 2021-11-02 21:23 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Namjae Jeon, Sungjong Seo

From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Hi,

These patches contain a few minor changes I wrote while studying the
exFAT file system driver.

With best regards,

Christophe Vu-Brugier (4):
  exfat: simplify is_valid_cluster()
  exfat: fix typos in comments
  exfat: make exfat_find_location() static
  exfat: reuse exfat_inode_info variable instead of calling EXFAT_I()

 fs/exfat/dir.c      |  6 +++---
 fs/exfat/exfat_fs.h |  2 --
 fs/exfat/fatent.c   |  4 +---
 fs/exfat/file.c     | 14 +++++++-------
 fs/exfat/inode.c    | 11 +++++------
 fs/exfat/namei.c    |  6 +++---
 fs/exfat/super.c    |  6 +++---
 7 files changed, 22 insertions(+), 27 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] exfat: simplify is_valid_cluster()
  2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
@ 2021-11-02 21:23 ` Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 2/4] exfat: fix typos in comments Christophe Vu-Brugier
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christophe Vu-Brugier @ 2021-11-02 21:23 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Namjae Jeon, Sungjong Seo, Christophe Vu-Brugier

From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
---
 fs/exfat/fatent.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index e949e563443c..81f5fc4a9e60 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -84,9 +84,7 @@ int exfat_ent_set(struct super_block *sb, unsigned int loc,
 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;
+	return EXFAT_FIRST_CLUSTER <= clus && clus < sbi->num_clusters;
 }
 
 int exfat_ent_get(struct super_block *sb, unsigned int loc,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] exfat: fix typos in comments
  2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 1/4] exfat: simplify is_valid_cluster() Christophe Vu-Brugier
@ 2021-11-02 21:23 ` Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 3/4] exfat: make exfat_find_location() static Christophe Vu-Brugier
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Christophe Vu-Brugier @ 2021-11-02 21:23 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Namjae Jeon, Sungjong Seo, Christophe Vu-Brugier

From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
---
 fs/exfat/dir.c   | 2 +-
 fs/exfat/inode.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index cb1c0d8c1714..ac14055bf38a 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -892,7 +892,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
 		es->bh[es->num_bh++] = bh;
 	}
 
-	/* validiate cached dentries */
+	/* validate cached dentries */
 	for (i = 1; i < num_entries; i++) {
 		ep = exfat_get_dentry_cached(es, i);
 		if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode))
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 1c7aa1ea4724..98292b38c6e2 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -31,7 +31,7 @@ static int __exfat_write_inode(struct inode *inode, int sync)
 		return 0;
 
 	/*
-	 * If the indode is already unlinked, there is no need for updating it.
+	 * If the inode is already unlinked, there is no need for updating it.
 	 */
 	if (ei->dir.dir == DIR_DELETED)
 		return 0;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] exfat: make exfat_find_location() static
  2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 1/4] exfat: simplify is_valid_cluster() Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 2/4] exfat: fix typos in comments Christophe Vu-Brugier
@ 2021-11-02 21:23 ` Christophe Vu-Brugier
  2021-11-02 21:23 ` [PATCH 4/4] exfat: reuse exfat_inode_info variable instead of calling EXFAT_I() Christophe Vu-Brugier
  2021-11-03  2:41 ` [PATCH 0/4] exfat: minor cleanup changes Namjae Jeon
  4 siblings, 0 replies; 6+ messages in thread
From: Christophe Vu-Brugier @ 2021-11-02 21:23 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Namjae Jeon, Sungjong Seo, Christophe Vu-Brugier

From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
---
 fs/exfat/dir.c      | 4 ++--
 fs/exfat/exfat_fs.h | 2 --
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index ac14055bf38a..68ad54113d8b 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -656,8 +656,8 @@ static int exfat_walk_fat_chain(struct super_block *sb,
 	return 0;
 }
 
-int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir,
-		int entry, sector_t *sector, int *offset)
+static int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir,
+			       int entry, sector_t *sector, int *offset)
 {
 	int ret;
 	unsigned int off, clu = 0;
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 1d6da61157c9..a8f5bc536dcf 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -459,8 +459,6 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
 		struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname,
 		int num_entries, unsigned int type, struct exfat_hint *hint_opt);
 int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu);
-int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir,
-		int entry, sector_t *sector, int *offset);
 struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
 		struct exfat_chain *p_dir, int entry, struct buffer_head **bh,
 		sector_t *sector);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] exfat: reuse exfat_inode_info variable instead of calling EXFAT_I()
  2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
                   ` (2 preceding siblings ...)
  2021-11-02 21:23 ` [PATCH 3/4] exfat: make exfat_find_location() static Christophe Vu-Brugier
@ 2021-11-02 21:23 ` Christophe Vu-Brugier
  2021-11-03  2:41 ` [PATCH 0/4] exfat: minor cleanup changes Namjae Jeon
  4 siblings, 0 replies; 6+ messages in thread
From: Christophe Vu-Brugier @ 2021-11-02 21:23 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Namjae Jeon, Sungjong Seo, Christophe Vu-Brugier

From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Also add a local "struct exfat_inode_info *ei" variable to
exfat_truncate() to simplify the code.

Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
---
 fs/exfat/file.c  | 14 +++++++-------
 fs/exfat/inode.c |  9 ++++-----
 fs/exfat/namei.c |  6 +++---
 fs/exfat/super.c |  6 +++---
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 6af0191b648f..848166d6d5e9 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -110,8 +110,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
 	exfat_set_volume_dirty(sb);
 
 	num_clusters_new = EXFAT_B_TO_CLU_ROUND_UP(i_size_read(inode), sbi);
-	num_clusters_phys =
-		EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk, sbi);
+	num_clusters_phys = EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi);
 
 	exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags);
 
@@ -228,12 +227,13 @@ void exfat_truncate(struct inode *inode, loff_t size)
 {
 	struct super_block *sb = inode->i_sb;
 	struct exfat_sb_info *sbi = EXFAT_SB(sb);
+	struct exfat_inode_info *ei = EXFAT_I(inode);
 	unsigned int blocksize = i_blocksize(inode);
 	loff_t aligned_size;
 	int err;
 
 	mutex_lock(&sbi->s_lock);
-	if (EXFAT_I(inode)->start_clu == 0) {
+	if (ei->start_clu == 0) {
 		/*
 		 * Empty start_clu != ~0 (not allocated)
 		 */
@@ -260,11 +260,11 @@ void exfat_truncate(struct inode *inode, loff_t size)
 		aligned_size++;
 	}
 
-	if (EXFAT_I(inode)->i_size_ondisk > i_size_read(inode))
-		EXFAT_I(inode)->i_size_ondisk = aligned_size;
+	if (ei->i_size_ondisk > i_size_read(inode))
+		ei->i_size_ondisk = aligned_size;
 
-	if (EXFAT_I(inode)->i_size_aligned > i_size_read(inode))
-		EXFAT_I(inode)->i_size_aligned = aligned_size;
+	if (ei->i_size_aligned > i_size_read(inode))
+		ei->i_size_aligned = aligned_size;
 	mutex_unlock(&sbi->s_lock);
 }
 
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 98292b38c6e2..5c442182f516 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -114,10 +114,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
 	unsigned int local_clu_offset = clu_offset;
 	unsigned int num_to_be_allocated = 0, num_clusters = 0;
 
-	if (EXFAT_I(inode)->i_size_ondisk > 0)
+	if (ei->i_size_ondisk > 0)
 		num_clusters =
-			EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
-			sbi);
+			EXFAT_B_TO_CLU_ROUND_UP(ei->i_size_ondisk, sbi);
 
 	if (clu_offset >= num_clusters)
 		num_to_be_allocated = clu_offset - num_clusters + 1;
@@ -416,10 +415,10 @@ static int exfat_write_end(struct file *file, struct address_space *mapping,
 
 	err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata);
 
-	if (EXFAT_I(inode)->i_size_aligned < i_size_read(inode)) {
+	if (ei->i_size_aligned < i_size_read(inode)) {
 		exfat_fs_error(inode->i_sb,
 			"invalid size(size(%llu) > aligned(%llu)\n",
-			i_size_read(inode), EXFAT_I(inode)->i_size_aligned);
+			i_size_read(inode), ei->i_size_aligned);
 		return -EIO;
 	}
 
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 24b41103d1cc..9d8ada781250 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -395,9 +395,9 @@ static int exfat_find_empty_entry(struct inode *inode,
 
 		/* directory inode should be updated in here */
 		i_size_write(inode, size);
-		EXFAT_I(inode)->i_size_ondisk += sbi->cluster_size;
-		EXFAT_I(inode)->i_size_aligned += sbi->cluster_size;
-		EXFAT_I(inode)->flags = p_dir->flags;
+		ei->i_size_ondisk += sbi->cluster_size;
+		ei->i_size_aligned += sbi->cluster_size;
+		ei->flags = p_dir->flags;
 		inode->i_blocks += 1 << sbi->sect_per_clus_bits;
 	}
 
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 5539ffc20d16..1a2115d73a48 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -366,9 +366,9 @@ static int exfat_read_root(struct inode *inode)
 
 	inode->i_blocks = ((i_size_read(inode) + (sbi->cluster_size - 1))
 			& ~(sbi->cluster_size - 1)) >> inode->i_blkbits;
-	EXFAT_I(inode)->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff;
-	EXFAT_I(inode)->i_size_aligned = i_size_read(inode);
-	EXFAT_I(inode)->i_size_ondisk = i_size_read(inode);
+	ei->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff;
+	ei->i_size_aligned = i_size_read(inode);
+	ei->i_size_ondisk = i_size_read(inode);
 
 	exfat_save_attr(inode, ATTR_SUBDIR);
 	inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] exfat: minor cleanup changes
  2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
                   ` (3 preceding siblings ...)
  2021-11-02 21:23 ` [PATCH 4/4] exfat: reuse exfat_inode_info variable instead of calling EXFAT_I() Christophe Vu-Brugier
@ 2021-11-03  2:41 ` Namjae Jeon
  4 siblings, 0 replies; 6+ messages in thread
From: Namjae Jeon @ 2021-11-03  2:41 UTC (permalink / raw)
  To: Christophe Vu-Brugier; +Cc: linux-fsdevel, Sungjong Seo

2021-11-03 6:23 GMT+09:00, Christophe Vu-Brugier <cvubrugier@fastmail.fm>:
> From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
>
> Hi,
Hi Christophe,
>
> These patches contain a few minor changes I wrote while studying the
> exFAT file system driver.
There is a warning from checkpatch.pl. Please run it before sending
patch to list next time.

WARNING: Comparisons should place the constant on the right side of the test
#105: FILE: fs/exfat/fatent.c:87:
+	return EXFAT_FIRST_CLUSTER <= clus && clus < sbi->num_clusters;

I fixed directly this warning and applied to #dev branch.

Thanks for your patch!
>
> With best regards,
>
> Christophe Vu-Brugier (4):
>   exfat: simplify is_valid_cluster()
>   exfat: fix typos in comments
>   exfat: make exfat_find_location() static
>   exfat: reuse exfat_inode_info variable instead of calling EXFAT_I()
>
>  fs/exfat/dir.c      |  6 +++---
>  fs/exfat/exfat_fs.h |  2 --
>  fs/exfat/fatent.c   |  4 +---
>  fs/exfat/file.c     | 14 +++++++-------
>  fs/exfat/inode.c    | 11 +++++------
>  fs/exfat/namei.c    |  6 +++---
>  fs/exfat/super.c    |  6 +++---
>  7 files changed, 22 insertions(+), 27 deletions(-)
>
> --
> 2.20.1
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-03  2:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 21:23 [PATCH 0/4] exfat: minor cleanup changes Christophe Vu-Brugier
2021-11-02 21:23 ` [PATCH 1/4] exfat: simplify is_valid_cluster() Christophe Vu-Brugier
2021-11-02 21:23 ` [PATCH 2/4] exfat: fix typos in comments Christophe Vu-Brugier
2021-11-02 21:23 ` [PATCH 3/4] exfat: make exfat_find_location() static Christophe Vu-Brugier
2021-11-02 21:23 ` [PATCH 4/4] exfat: reuse exfat_inode_info variable instead of calling EXFAT_I() Christophe Vu-Brugier
2021-11-03  2:41 ` [PATCH 0/4] exfat: minor cleanup changes Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).