Re: [patch 3/5] fuse: fix race in llseek

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 Apr 2008 19:55:23 +0200 Miklos Szeredi <miklos@xxxxxxxxxx> wrote:

> +static loff_t fuse_file_llseek(struct file *file, loff_t offset, int origin)
> +{
> +	long long retval;

I switched this to have a type of loff_t.

> +	struct inode *inode = file->f_path.dentry->d_inode;
> +
> +	mutex_lock(&inode->i_mutex);
> +	switch (origin) {
> +	case SEEK_END:
> +		offset += i_size_read(inode);

As we hold i_mutex we could directly read inode->i_size here, save a few
cycles.

> +		break;
> +	case SEEK_CUR:
> +		offset += file->f_pos;
> +	}
> +	retval = -EINVAL;
> +	if (offset >= 0 && offset <= inode->i_sb->s_maxbytes) {
> +		if (offset != file->f_pos) {
> +			file->f_pos = offset;
> +			file->f_version = 0;
> +		}
> +		retval = offset;
> +	}
> +	mutex_unlock(&inode->i_mutex);
> +	return retval;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux