diff options
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r-- | fs/fuse/file.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 0c84100acd44..4a199fd93fbd 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 | } | ||
1598 | exit: | ||
1599 | mutex_unlock(&inode->i_mutex); | 1566 | mutex_unlock(&inode->i_mutex); |
1567 | |||
1600 | return retval; | 1568 | return retval; |
1601 | } | 1569 | } |
1602 | 1570 | ||
@@ -1808,7 +1776,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, | |||
1808 | BUILD_BUG_ON(sizeof(struct fuse_ioctl_iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE); | 1776 | BUILD_BUG_ON(sizeof(struct fuse_ioctl_iovec) * FUSE_IOCTL_MAX_IOV > PAGE_SIZE); |
1809 | 1777 | ||
1810 | err = -ENOMEM; | 1778 | err = -ENOMEM; |
1811 | pages = kzalloc(sizeof(pages[0]) * FUSE_MAX_PAGES_PER_REQ, GFP_KERNEL); | 1779 | pages = kcalloc(FUSE_MAX_PAGES_PER_REQ, sizeof(pages[0]), GFP_KERNEL); |
1812 | iov_page = (struct iovec *) __get_free_page(GFP_KERNEL); | 1780 | iov_page = (struct iovec *) __get_free_page(GFP_KERNEL); |
1813 | if (!pages || !iov_page) | 1781 | if (!pages || !iov_page) |
1814 | goto out; | 1782 | goto out; |
@@ -1958,8 +1926,8 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, | |||
1958 | } | 1926 | } |
1959 | EXPORT_SYMBOL_GPL(fuse_do_ioctl); | 1927 | EXPORT_SYMBOL_GPL(fuse_do_ioctl); |
1960 | 1928 | ||
1961 | static long fuse_file_ioctl_common(struct file *file, unsigned int cmd, | 1929 | long fuse_ioctl_common(struct file *file, unsigned int cmd, |
1962 | unsigned long arg, unsigned int flags) | 1930 | unsigned long arg, unsigned int flags) |
1963 | { | 1931 | { |
1964 | struct inode *inode = file->f_dentry->d_inode; | 1932 | struct inode *inode = file->f_dentry->d_inode; |
1965 | struct fuse_conn *fc = get_fuse_conn(inode); | 1933 | struct fuse_conn *fc = get_fuse_conn(inode); |
@@ -1976,13 +1944,13 @@ static long fuse_file_ioctl_common(struct file *file, unsigned int cmd, | |||
1976 | static long fuse_file_ioctl(struct file *file, unsigned int cmd, | 1944 | static long fuse_file_ioctl(struct file *file, unsigned int cmd, |
1977 | unsigned long arg) | 1945 | unsigned long arg) |
1978 | { | 1946 | { |
1979 | return fuse_file_ioctl_common(file, cmd, arg, 0); | 1947 | return fuse_ioctl_common(file, cmd, arg, 0); |
1980 | } | 1948 | } |
1981 | 1949 | ||
1982 | static long fuse_file_compat_ioctl(struct file *file, unsigned int cmd, | 1950 | static long fuse_file_compat_ioctl(struct file *file, unsigned int cmd, |
1983 | unsigned long arg) | 1951 | unsigned long arg) |
1984 | { | 1952 | { |
1985 | return fuse_file_ioctl_common(file, cmd, arg, FUSE_IOCTL_COMPAT); | 1953 | return fuse_ioctl_common(file, cmd, arg, FUSE_IOCTL_COMPAT); |
1986 | } | 1954 | } |
1987 | 1955 | ||
1988 | /* | 1956 | /* |