All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 7/8] f2fs: fix to update largest extent under lock
Date: Tue, 11 Oct 2016 22:57:05 +0800	[thread overview]
Message-ID: <20161011145706.5028-7-chao@kernel.org> (raw)
In-Reply-To: <20161011145706.5028-1-chao@kernel.org>

From: Chao Yu <yuchao0@huawei.com>

In order to avoid racing problem, make largest extent cache being updated
under lock.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/inode.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 34ae03c..d9cd458 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -252,6 +252,7 @@ retry:
 int update_inode(struct inode *inode, struct page *node_page)
 {
 	struct f2fs_inode *ri;
+	struct extent_tree *et = F2FS_I(inode)->extent_tree;
 
 	f2fs_inode_synced(inode);
 
@@ -267,11 +268,13 @@ int update_inode(struct inode *inode, struct page *node_page)
 	ri->i_size = cpu_to_le64(i_size_read(inode));
 	ri->i_blocks = cpu_to_le64(inode->i_blocks);
 
-	if (F2FS_I(inode)->extent_tree)
-		set_raw_extent(&F2FS_I(inode)->extent_tree->largest,
-							&ri->i_ext);
-	else
+	if (et) {
+		read_lock(&et->lock);
+		set_raw_extent(&et->largest, &ri->i_ext);
+		read_unlock(&et->lock);
+	} else {
 		memset(&ri->i_ext, 0, sizeof(ri->i_ext));
+	}
 	set_raw_inline(inode, ri);
 
 	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
Subject: [PATCH 7/8] f2fs: fix to update largest extent under lock
Date: Tue, 11 Oct 2016 22:57:05 +0800	[thread overview]
Message-ID: <20161011145706.5028-7-chao@kernel.org> (raw)
In-Reply-To: <20161011145706.5028-1-chao@kernel.org>

From: Chao Yu <yuchao0@huawei.com>

In order to avoid racing problem, make largest extent cache being updated
under lock.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/inode.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 34ae03c..d9cd458 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -252,6 +252,7 @@ retry:
 int update_inode(struct inode *inode, struct page *node_page)
 {
 	struct f2fs_inode *ri;
+	struct extent_tree *et = F2FS_I(inode)->extent_tree;
 
 	f2fs_inode_synced(inode);
 
@@ -267,11 +268,13 @@ int update_inode(struct inode *inode, struct page *node_page)
 	ri->i_size = cpu_to_le64(i_size_read(inode));
 	ri->i_blocks = cpu_to_le64(inode->i_blocks);
 
-	if (F2FS_I(inode)->extent_tree)
-		set_raw_extent(&F2FS_I(inode)->extent_tree->largest,
-							&ri->i_ext);
-	else
+	if (et) {
+		read_lock(&et->lock);
+		set_raw_extent(&et->largest, &ri->i_ext);
+		read_unlock(&et->lock);
+	} else {
 		memset(&ri->i_ext, 0, sizeof(ri->i_ext));
+	}
 	set_raw_inline(inode, ri);
 
 	ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
-- 
2.10.1

  parent reply	other threads:[~2016-10-11 14:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-11 14:56 [PATCH 1/8] f2fs: clear nlink if fail to add_link Chao Yu
2016-10-11 14:56 ` Chao Yu
2016-10-11 14:57 ` [PATCH 2/8] f2fs: fix to release discard entries during checkpoint Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 14:57 ` [PATCH 3/8] f2fs: give a chance to detach from dirty list Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 14:57 ` [PATCH 4/8] f2fs: add missing f2fs_balance_fs in f2fs_zero_range Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 14:57 ` [PATCH 5/8] f2fs: don't miss any f2fs_balance_fs cases Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 14:57 ` [PATCH 6/8] f2fs: be aware of extent beyond EOF in fiemap Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 14:57 ` Chao Yu [this message]
2016-10-11 14:57   ` [PATCH 7/8] f2fs: fix to update largest extent under lock Chao Yu
2016-10-11 14:57 ` [PATCH 8/8] f2fs: fix error handling in fsync_node_pages Chao Yu
2016-10-11 14:57   ` Chao Yu
2016-10-11 22:19 ` [PATCH 1/8] f2fs: clear nlink if fail to add_link Jaegeuk Kim
2016-10-11 22:19   ` Jaegeuk Kim
2016-10-12 15:24   ` Chao Yu
2016-10-12 15:24     ` Chao Yu
2016-10-12 17:22     ` Jaegeuk Kim
2016-10-12 17:22       ` Jaegeuk Kim
2016-10-13 10:29       ` Chao Yu
2016-10-13 10:29         ` Chao Yu

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=20161011145706.5028-7-chao@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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.