All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ionut Nicu <ioan.nicu.ext@nsn.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ext4fs: Add ext4 extent cache for read operations
Date: Fri, 24 Jan 2014 09:59:42 +0100	[thread overview]
Message-ID: <52E22B7E.7090601@nsn.com> (raw)
In-Reply-To: <52DE44CF.9090700@nsn.com>

Hi,

On 21.01.2014 10:58, Ionut Nicu wrote:
> 
> +static int __ext4fs_build_extent_cache(struct ext2_data *data,
> +		struct ext4_extent_header *ext_block)
>  {
> +	int blksz = EXT2_BLOCK_SIZE(data);
> +	int log2_blksz = LOG2_BLOCK_SIZE(data)
> +		- get_fs()->dev_desc->log2blksz;
> +	struct ext4_extent_node *node;
>  	struct ext4_extent_idx *index;
> +	struct ext4_extent *extent;
>  	unsigned long long block;
> -	int blksz = EXT2_BLOCK_SIZE(data);
> -	int i;
> +	char *buf;
> +	int i, err;
>  
> -	while (1) {
> -		index = (struct ext4_extent_idx *)(ext_block + 1);
> +	if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
> +		return -EINVAL;
>  
> -		if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
> -			return 0;
> -
> -		if (ext_block->eh_depth == 0)
> -			return ext_block;
> -		i = -1;
> -		do {
> -			i++;
> -			if (i >= le16_to_cpu(ext_block->eh_entries))
> -				break;
> -		} while (fileblock >= le32_to_cpu(index[i].ei_block));
> +	if (ext_block->eh_depth == 0) {
> +		extent = (struct ext4_extent *)(ext_block + 1);
> +		for (i = 0; i < le16_to_cpu(ext_block->eh_entries); i++) {
> +			node = malloc(sizeof(*node));
> +			if (!node)
> +				return -ENOMEM;
> +			node->block = le32_to_cpu(extent[i].ee_block);
> +			node->len = le16_to_cpu(extent[i].ee_len);
> +			node->start = (le16_to_cpu(extent[i].ee_start_hi) << 16)
> +				+ le32_to_cpu(extent[i].ee_start_lo);

Should be (le16_to_cpu(extent[i].ee_start_hi) << 32)

> diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
> index 735b256..7963f1d 100644
> --- a/fs/ext4/ext4fs.c
> +++ b/fs/ext4/ext4fs.c
> @@ -176,10 +176,25 @@ int ext4fs_ls(const char *dirname)
>  
>  int ext4fs_read(char *buf, unsigned len)
>  {
> +	int ret;
> +
>  	if (ext4fs_root == NULL || ext4fs_file == NULL)
>  		return 0;
>  
> -	return ext4fs_read_file(ext4fs_file, 0, len, buf);
> +	if (le32_to_cpu(ext4fs_file->inode.flags) & EXT4_EXTENTS_FL) {
> +		if (ext4fs_build_extent_cache(&(ext4fs_file->inode))) {
> +			printf("Error building extent cache!\n");
> +			ret = -1;
> +			goto out_exit;
> +		}
> +	}
> +
> +	ret = ext4fs_read_file(ext4fs_file, 0, len, buf);
> +
> +out_exit:
> +	ext4fs_free_extent_cache();
> +
> +	return ret;
>  }
>  

ext4fs_read_file is also called by ext4fs_iterate_dir and ext4fs_read_symlink
so the place where we build the extent cache should be ext4fs_read_file instead
of extfs_read.

Please ignore this version of the patch for now, I will send a revised version.

Regards,
Ionut

      reply	other threads:[~2014-01-24  8:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21  9:58 [U-Boot] [PATCH] ext4fs: Add ext4 extent cache for read operations Ionut Nicu
2014-01-24  8:59 ` Ionut Nicu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52E22B7E.7090601@nsn.com \
    --to=ioan.nicu.ext@nsn.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.