vfs: simply the code logic
PATCH 1/1 vfs: simply the code logic
From: Zhi Yong Wu <[email protected]>
Signed-off-by Zhi Yong Wu <[email protected]>
--- fs/block_dev.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
fs/block_dev.c +1 -4
@@ -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
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
-4if (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."