Skip to contentSkip to conversation

vfs: simply the code logic

PATCH In review [email protected] 2 participants 2 messages Jul 21, 2012 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfs: simply the code logic

From: Zhi Yong Wu <[email protected]>

---
 fs/block_dev.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
fs/block_dev.c +1 -4
index c2bbe1f..0f268d3 100644
@@ -396,10 +396,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
 			goto out;
 	}
 	if (offset >= 0 && offset <= size) {
-		if (offset != file->f_pos) {
-			file->f_pos = offset;
-		}
-		retval = offset;
+		retval = file->f_pos = offset;
 	}
 out:
 	mutex_unlock(&bd_inode->i_mutex);
Signature · 1 line
1.7.6
#1 lore raw

fs/block_dev.c static loff_t block_llseek(struct file *file, loff_t offset, int origin) · line 400

Quoted 7 lines · On Sat, Jul 21, 2012 at 11:38:19PM +0800, [email protected] wrote:
fs/block_dev.c +1 -4
 	if (offset >= 0 && offset <= size) {
-		if (offset != file->f_pos) {
-			file->f_pos = offset;
-		}
-		retval = offset;
+		retval = file->f_pos = offset;
 	}

But now you're writing to f_pos unconditionally. That may cause cacheline bouncing. NAK.

Plus, you're now using a less-well-known feature of C, so while it's fewer lines of code, it's not necessarily a simplification.

Signature · 4 lines
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."