aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2011-12-13 05:58:48 -0500
committerMiklos Szeredi <mszeredi@suse.cz>2011-12-13 05:58:48 -0500
commitc07c3d193412bbf4e9f405e75dc84e35e77fac28 (patch)
tree79991f1fed4184e7bea8fa98f7de4faf9853bb02
parent73104b6e37f75f822e3dcf016147c322d1f6dad9 (diff)
fuse: llseek optimize SEEK_CUR and SEEK_SET
Use generic_file_llseek() instead of open coding the seek function. i_mutex protection is only necessary for SEEK_END (and SEEK_HOLE, SEEK_DATA), so move SEEK_CUR and SEEK_SET out from under i_mutex. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
-rw-r--r--fs/fuse/file.c48
1 files changed, 8 insertions, 40 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 0c84100acd44..e0b60acfe726 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1555,48 +1555,16 @@ static loff_t fuse_file_llseek(struct file *file, loff_t offset, int origin)
1555 loff_t retval; 1555 loff_t retval;
1556 struct inode *inode = file->f_path.dentry->d_inode; 1556 struct inode *inode = file->f_path.dentry->d_inode;
1557 1557
1558 mutex_lock(&inode->i_mutex); 1558 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */
1559 if (origin != SEEK_CUR && origin != SEEK_SET) { 1559 if (origin == SEEK_CUR || origin == SEEK_SET)
1560 retval = fuse_update_attributes(inode, NULL, file, NULL); 1560 return generic_file_llseek(file, offset, origin);
1561 if (retval)
1562 goto exit;
1563 }
1564 1561
1565 switch (origin) { 1562 mutex_lock(&inode->i_mutex);
1566 case SEEK_END: 1563 retval = fuse_update_attributes(inode, NULL, file, NULL);
1567 offset += i_size_read(inode); 1564 if (!retval)
1568 break; 1565 retval = generic_file_llseek(file, offset, origin);
1569 case SEEK_CUR:
1570 if (offset == 0) {
1571 retval = file->f_pos;
1572 goto exit;
1573 }
1574 offset += file->f_pos;
1575 break;
1576 case SEEK_DATA:
1577 if (offset >= i_size_read(inode)) {
1578 retval = -ENXIO;
1579 goto exit;
1580 }
1581 break;
1582 case SEEK_HOLE:
1583 if (offset >= i_size_read(inode)) {
1584 retval = -ENXIO;
1585 goto exit;
1586 }
1587 offset = i_size_read(inode);
1588 break;
1589 }
1590 retval = -EINVAL;
1591 if (offset >= 0 && offset <= inode->i_sb->s_maxbytes) {
1592 if (offset != file->f_pos) {
1593 file->f_pos = offset;
1594 file->f_version = 0;
1595 }
1596 retval = offset;
1597 }
1598exit:
1599 mutex_unlock(&inode->i_mutex); 1566 mutex_unlock(&inode->i_mutex);
1567
1600 return retval; 1568 return retval;
1601} 1569}
1602 1570