lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Aug 2010 02:35:57 -0400
From:	Andreas Dilger <andreas.dilger@...cle.com>
To:	Toshiyuki Okajima <toshi.okajima@...fujitsu.com>
Cc:	"Ted Ts'o" <tytso@....edu>,
	linux-ext4 development <linux-ext4@...r.kernel.org>
Subject: Re: [Q] ext


On 2010-08-10, at 10:23, Toshiyuki Okajima wrote:
> Table. the max file size which we can write or seek
>       at each filesystem feature tuning and file flag setting
> +===============================+===============================+
> |                               |                               |
> |     !EXT4_EXTENTS_FL          |        EXT4_EXTETNS_FL        |
> |                               |                               |
> +-------------------------------+-------------------------------+
> |   write:      2194719883264   | write:       --------------   |
> |   seek:       2199023251456   | seek:        --------------   |
> +-------------------------------+-------------------------------+
> |   write:      4402345721856   | write:       17592186044415   |
> |   seek:      17592186044415   | seek:        17592186044415   |
> +-------------------------------+-------------------------------+

Interesting.  The 2TB vs. 4TB difference for block-mapped files is due to the removal of the 2^32 sectors limit imposed by i_blocks, and is not strictly related to extents.

> +loff_t ext4_llseek(struct file *file, loff_t offset, int origin)
> +{
> +	struct inode *inode = file->f_mapping->host;
> +	loff_t maxbytes;
> +
> +	mutex_lock(&inode->i_mutex);
> +	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
> +		maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
> +	else
> +		maxbytes = inode->i_sb->s_maxbytes;

This part doesn't really have to be under i_mutex.  Otherwise, the patch looks reasonable.

> +	switch (origin) {
> +	case SEEK_END:
> +		offset += inode->i_size;
> +		break;
> +	case SEEK_CUR:
> +		if (offset == 0) {
> +			mutex_unlock(&inode->i_mutex);
> +			return file->f_pos;
> +		}
> +		offset += file->f_pos;
> +		break;
> +       	}
> +
> +	if (offset < 0 || offset > maxbytes) {
> +		mutex_unlock(&inode->i_mutex);
> +		return -EINVAL;
> +	}
> +
> +	if (offset != file->f_pos) {
> +		file->f_pos = offset;
> +		file->f_version = 0;
> +	}
> +	mutex_unlock(&inode->i_mutex);
> + 
> +	return offset;
> +}

It's too bad that we have to duplicate the whole generic_file_llseek() code here, but I don't think there is a better solution.  However, it is worthwhile to add a comment to this function like:

/* copied from generic_file_llseek() to handle both block-mapped and
 * extent-mapped maxbytes values.  Should otherwise be identical. */

Cheers, Andreas
--
Andreas Dilger
Lustre Technical Lead
Oracle Corporation Canada Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ