linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
To: "Theodore Ts'o" <tytso@mit.edu>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH, RFC 2/2] ext4: Convert callers of ext4_get_blocks() to use ext4_map_blocks()
Date: Tue, 04 May 2010 15:34:59 +0530	[thread overview]
Message-ID: <878w80htis.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1272927081-12694-2-git-send-email-tytso@mit.edu>

On Mon,  3 May 2010 18:51:21 -0400, "Theodore Ts'o" <tytso@mit.edu> wrote:
> @@ -2560,45 +2522,50 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
>  		invalid_block = ~0;
> 
>  	BUG_ON(create == 0);
> -	BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);
> +	BUG_ON(bh->b_size != inode->i_sb->s_blocksize);
> +
> +	map.m_lblk = iblock;
> +	map.m_len = 1;
> 
>  	/*
>  	 * first, we need to know whether the block is allocated already
>  	 * preallocated blocks are unmapped but should treated
>  	 * the same as allocated blocks.
>  	 */
> -	ret = ext4_get_blocks(NULL, inode, iblock, 1,  bh_result, 0);
> -	if ((ret == 0) && !buffer_delay(bh_result)) {
> -		/* the block isn't (pre)allocated yet, let's reserve space */
> -		/*
> -		 * XXX: __block_prepare_write() unmaps passed block,
> -		 * is it OK?
> -		 */
> -		ret = ext4_da_reserve_space(inode, iblock);
> -		if (ret)
> -			/* not enough space to reserve */
> -			return ret;
> -
> -		map_bh(bh_result, inode->i_sb, invalid_block);
> -		set_buffer_new(bh_result);
> -		set_buffer_delay(bh_result);
> -	} else if (ret > 0) {
> -		bh_result->b_size = (ret << inode->i_blkbits);
> -		if (buffer_unwritten(bh_result)) {
> -			/* A delayed write to unwritten bh should
> -			 * be marked new and mapped.  Mapped ensures
> -			 * that we don't do get_block multiple times
> -			 * when we write to the same offset and new
> -			 * ensures that we do proper zero out for
> -			 * partial write.
> +	ret = ext4_map_blocks(NULL, inode, &map, 0);
> +	if (ret < 0)
> +		return ret;
> +	if (ret == 0) {
> +		if (!buffer_delay(bh)) {


bh flags are not set here. This check should be based on map.m_flags.




> +			/*
> +			 * XXX: __block_prepare_write() unmaps passed
> +			 * block, is it OK?
>  			 */
> -			set_buffer_new(bh_result);
> -			set_buffer_mapped(bh_result);
> +			ret = ext4_da_reserve_space(inode, iblock);
> +			if (ret)
> +				return ret; /* not enough space to reserve */
> +
> +			map_bh(bh, inode->i_sb, invalid_block);
> +			set_buffer_new(bh);
> +			set_buffer_delay(bh);
>  		}
> -		ret = 0;
> +		return 0;
>  	}
> 

Only thing i am worried about is we were modifying bh_flags in all
possible confusing ways. We may want to make sure we get the update
correct. I am still going through the patch after applying it to the
tree. So may take more time to look at the full changeset.

-aneesh

  reply	other threads:[~2010-05-04 10:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 22:51 [PATCH, RFC 1/2] ext4: Add new abstraction ext4_map_blocks() underneath ext4_get_blocks() Theodore Ts'o
2010-05-03 22:51 ` [PATCH, RFC 2/2] ext4: Convert callers of ext4_get_blocks() to use ext4_map_blocks() Theodore Ts'o
2010-05-04 10:04   ` Aneesh Kumar K. V [this message]
2010-05-04 15:42     ` tytso
2010-05-05 18:38     ` tytso

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=878w80htis.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).