linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Nicholas Krause <xerofoify@gmail.com>
To: jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH] f2fs:Fix concurrent access issue in the function recover_dentry
Date: Wed, 16 Sep 2015 19:10:04 -0400	[thread overview]
Message-ID: <1442445004-25986-1-git-send-email-xerofoify@gmail.com> (raw)

This fixes a concurrent access in the function recover_dentry by
locking the superblock representation in memory with f2fs_lock_op
before calling the function __f2fs_add_link and unlocking the
superblock afterwards with f2fs_unlock_op in order to avoid
concurrent access here as neither recover_dentry nor its callers

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 fs/f2fs/recovery.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index faec2ca..6bb03f8 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -70,6 +70,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,
 static int recover_dentry(struct inode *inode, struct page *ipage)
 {
 	struct f2fs_inode *raw_inode = F2FS_INODE(ipage);
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	nid_t pino = le32_to_cpu(raw_inode->i_pino);
 	struct f2fs_dir_entry *de;
 	struct qstr name;
@@ -119,9 +120,15 @@ retry:
 		iput(einode);
 		goto retry;
 	}
+
+
+	f2fs_lock_op(sbi);
 	err = __f2fs_add_link(dir, &name, inode, inode->i_ino, inode->i_mode);
-	if (err)
+	if (err) {
+		f2fs_unlock_op(sbi);
 		goto out_err;
+	}
+	f2fs_unlock_op(sbi);
 
 	if (is_inode_flag_set(F2FS_I(dir), FI_DELAY_IPUT)) {
 		iput(dir);
-- 
2.1.4


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140

                 reply	other threads:[~2015-09-16 23:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1442445004-25986-1-git-send-email-xerofoify@gmail.com \
    --to=xerofoify@gmail.com \
    --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 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).