Skip to contentSkip to conversation

fs: clarify the rerurn value check for inode_needs_update_time

PATCH In review Joseph Qi 2 participants 2 messages Oct 11, 2022 VFS

lore
Share & tools
lore

Joseph Qi

author
#0 lore raw

PATCH 1/1 fs: clarify the rerurn value check for inode_needs_update_time

inode_needs_update_time() can only returns >0 or 0, which means inode needs sync or not.
So cleanup the callers return value check, and also cleanup redundant check in the function before return.

---
 fs/inode.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/inode.c +2 -5
index b608528efd3a..d8f4ba98549a 100644
@@ -2071,9 +2071,6 @@ static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
 	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
 		sync_it |= S_VERSION;
 
-	if (!sync_it)
-		return 0;
-
 	return sync_it;
 }
 
@@ -2113,7 +2110,7 @@ int file_update_time(struct file *file)
 	struct timespec64 now = current_time(inode);
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 
 	return __file_update_time(file, &now, ret);
@@ -2153,7 +2150,7 @@ static int file_modified_flags(struct file *file, int flags)
 		return 0;
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 	if (flags & IOCB_NOWAIT)
 		return -EAGAIN;
Signature · 1 line
2.24.4
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Joseph Qi

inode_needs_update_time() can only returns >0 or 0, which means inode needs sync or not.
So cleanup the callers return value check, and also cleanup redundant check in the function before return.

OK, makes sense. Feel free to add:

Honza

Quoted 39 lines
---
 fs/inode.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/inode.c +2 -5
index b608528efd3a..d8f4ba98549a 100644
@@ -2071,9 +2071,6 @@ static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
 	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
 		sync_it |= S_VERSION;
 
-	if (!sync_it)
-		return 0;
-
 	return sync_it;
 }
 
@@ -2113,7 +2110,7 @@ int file_update_time(struct file *file)
 	struct timespec64 now = current_time(inode);
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 
 	return __file_update_time(file, &now, ret);
@@ -2153,7 +2150,7 @@ static int file_modified_flags(struct file *file, int flags)
 		return 0;
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 	if (flags & IOCB_NOWAIT)
 		return -EAGAIN;
Signature · 1 line
2.24.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR