linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "zhangyi (F)" <yi.zhang@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <jack@suse.cz>, <adilger.kernel@dilger.ca>,
	<yi.zhang@huawei.com>, <miaoxie@huawei.com>
Subject: [PATCH v4 4/4] ext4: convert ext4_split_extent() to return requested length
Date: Wed, 30 Jan 2019 14:49:40 +0800	[thread overview]
Message-ID: <1548830980-29482-5-git-send-email-yi.zhang@huawei.com> (raw)
In-Reply-To: <1548830980-29482-1-git-send-email-yi.zhang@huawei.com>

After we remove clean_bdev_aliases() calls which used to unmap extra
blocks in ext4_ext_handle_unwritten_extents(), return extra initialized
region in ext4_ext_convert_to_initialized() is no longer needed, so
in order to simplify logic, this patch convert to return the requested
size instead.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/extents.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ffb72d8..ffe9671 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3456,9 +3456,8 @@ static int ext4_split_extent(handle_t *handle,
  *    of the logical span [map->m_lblk, map->m_lblk + map->m_len).
  *
  * Post-conditions on success:
- *  - the returned value is the number of blocks beyond map->l_lblk
- *    that are allocated and initialized.
- *    It is guaranteed to be >= map->m_len.
+ *  - The returned value is the minimum number of requested blocks or
+ *    initialized blocks. It is guaranteed to be <= map->m_len.
  */
 static int ext4_ext_convert_to_initialized(handle_t *handle,
 					   struct inode *inode,
@@ -3700,7 +3699,6 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 
 			split_map.m_len += split_map.m_lblk - ee_block;
 			split_map.m_lblk = ee_block;
-			allocated = map->m_len;
 		}
 	}
 
@@ -3709,6 +3707,9 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 	if (err > 0)
 		err = 0;
 out:
+	if (allocated > map->m_len)
+		allocated = map->m_len;
+
 	/* If we have gotten a failure, don't zero out status tree */
 	if (!err) {
 		err = ext4_zeroout_es(inode, &zero_ex1);
@@ -4065,11 +4066,10 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
 	if (ret <= 0) {
 		err = ret;
 		goto out2;
-	} else
-		allocated = ret;
+	}
+
+	allocated = ret;
 	map->m_flags |= EXT4_MAP_NEW;
-	if (allocated > map->m_len)
-		allocated = map->m_len;
 	map->m_len = allocated;
 
 map_out:
-- 
2.7.4


  parent reply	other threads:[~2019-01-30  6:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  6:49 [PATCH v4 0/4] ext4: fix a data corruption problem zhangyi (F)
2019-01-30  6:49 ` [PATCH v4 1/4] jbd2: make sure dirty flag is cleared while revorking a buffer which belongs to older transaction zhangyi (F)
2019-02-11  4:24   ` Theodore Y. Ts'o
2019-02-12 12:20     ` zhangyi (F)
2019-01-30  6:49 ` [PATCH v4 2/4] jbd2: discard dirty data when forgetting an un-journalled buffer zhangyi (F)
2019-02-11  4:31   ` Theodore Y. Ts'o
2019-01-30  6:49 ` [PATCH v4 3/4] ext4: cleanup clean_bdev_aliases() calls zhangyi (F)
2019-02-11  4:38   ` Theodore Y. Ts'o
2019-01-30  6:49 ` zhangyi (F) [this message]
2019-02-11  4:49   ` [PATCH v4 4/4] ext4: convert ext4_split_extent() to return requested length Theodore Y. Ts'o

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=1548830980-29482-5-git-send-email-yi.zhang@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --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).