LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 2/6] f2fs: declare nested quota_sem and remove unnecessary sems
Date: Mon,  9 Dec 2019 14:23:41 -0800	[thread overview]
Message-ID: <20191209222345.1078-2-jaegeuk@kernel.org> (raw)
In-Reply-To: <20191209222345.1078-1-jaegeuk@kernel.org>

1.
f2fs_quota_sync
 -> down_read(&sbi->quota_sem)
 -> dquot_writeback_dquots
  -> f2fs_dquot_commit
   -> down_read(&sbi->quota_sem)

2.
f2fs_quota_sync
 -> down_read(&sbi->quota_sem)
  -> f2fs_write_data_pages
   -> f2fs_write_single_data_page
    -> down_write(&F2FS_I(inode)->i_sem)

f2fs_mkdir
 -> f2fs_do_add_link
   -> down_write(&F2FS_I(inode)->i_sem)
   -> f2fs_init_inode_metadata
    -> f2fs_new_node_page
     -> dquot_alloc_inode
      -> f2fs_dquot_mark_dquot_dirty
       -> down_read(&sbi->quota_sem)

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5111e1ffe58a..15888ca02e7f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2156,39 +2156,30 @@ static void f2fs_truncate_quota_inode_pages(struct super_block *sb)
 static int f2fs_dquot_commit(struct dquot *dquot)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
-	int ret;
+	int ret = dquot_commit(dquot);
 
-	down_read(&sbi->quota_sem);
-	ret = dquot_commit(dquot);
 	if (ret < 0)
 		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
-	up_read(&sbi->quota_sem);
 	return ret;
 }
 
 static int f2fs_dquot_acquire(struct dquot *dquot)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
-	int ret;
+	int ret = dquot_acquire(dquot);
 
-	down_read(&sbi->quota_sem);
-	ret = dquot_acquire(dquot);
 	if (ret < 0)
 		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
-	up_read(&sbi->quota_sem);
 	return ret;
 }
 
 static int f2fs_dquot_release(struct dquot *dquot)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
-	int ret;
+	int ret = dquot_release(dquot);
 
-	down_read(&sbi->quota_sem);
-	ret = dquot_release(dquot);
 	if (ret < 0)
 		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
-	up_read(&sbi->quota_sem);
 	return ret;
 }
 
@@ -2198,7 +2189,7 @@ static int f2fs_dquot_mark_dquot_dirty(struct dquot *dquot)
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
 	int ret;
 
-	down_read(&sbi->quota_sem);
+	down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING);
 	ret = dquot_mark_dquot_dirty(dquot);
 
 	/* if we are using journalled quota */
@@ -2212,13 +2203,10 @@ static int f2fs_dquot_mark_dquot_dirty(struct dquot *dquot)
 static int f2fs_dquot_commit_info(struct super_block *sb, int type)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
-	int ret;
+	int ret = dquot_commit_info(sb, type);
 
-	down_read(&sbi->quota_sem);
-	ret = dquot_commit_info(sb, type);
 	if (ret < 0)
 		set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
-	up_read(&sbi->quota_sem);
 	return ret;
 }
 
-- 
2.19.0.605.g01d371f741-goog


  reply	other threads:[~2019-12-09 22:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 22:23 [PATCH 1/6] f2fs: call f2fs_balance_fs outside of locked page Jaegeuk Kim
2019-12-09 22:23 ` Jaegeuk Kim [this message]
2019-12-10  6:20   ` [f2fs-dev] [PATCH 2/6] f2fs: declare nested quota_sem and remove unnecessary sems Chao Yu
2019-12-09 22:23 ` [PATCH 3/6] f2fs: keep quota data on write_begin failure Jaegeuk Kim
2019-12-10  6:22   ` [f2fs-dev] " Chao Yu
2019-12-09 22:23 ` [PATCH 4/6] f2fs: should avoid recursive filesystem ops Jaegeuk Kim
2019-12-10  6:22   ` [f2fs-dev] " Chao Yu
2019-12-09 22:23 ` [PATCH 5/6] f2fs: set GFP_NOFS when moving inline dentries Jaegeuk Kim
2019-12-10  6:22   ` [f2fs-dev] " Chao Yu
2019-12-09 22:23 ` [PATCH 6/6] f2fs: set I_LINKABLE early to avoid wrong access by vfs Jaegeuk Kim
2019-12-10  6:37   ` [f2fs-dev] " Chao Yu
2019-12-11  1:21     ` Jaegeuk Kim
2019-12-11  1:23       ` Chao Yu
2019-12-11  1:31         ` Jaegeuk Kim
2019-12-11  1:42           ` Chao Yu
2019-12-12 16:55             ` Jaegeuk Kim
2019-12-10  2:09 ` [f2fs-dev] [PATCH 1/6] f2fs: call f2fs_balance_fs outside of locked page Chao Yu
2020-02-22  4:46 ` Ondřej Jirman
2020-02-22 18:17   ` Writes stoped working on f2fs after the compression support was added Ondřej Jirman
2020-02-24 10:37     ` Chao Yu
2020-02-24 10:41       ` [f2fs-dev] " Chao Yu
2020-02-24 13:58         ` Ondřej Jirman
2020-02-24 14:03           ` Ondřej Jirman
2020-02-24 14:31             ` Ondřej Jirman
2020-02-25 11:24               ` Chao Yu
2020-02-25 11:32                 ` Chao Yu
2020-02-25 12:08                 ` Ondřej Jirman
2020-02-25 12:27                   ` Ondřej Jirman
2020-02-26  1:58                     ` Chao Yu
2020-02-26 12:11                       ` Ondřej Jirman
2020-02-26 18:05                         ` Ondřej Jirman
2020-02-27  2:01                           ` Chao Yu
2020-03-06 12:02                             ` Ondřej Jirman
2020-03-06 12:43                               ` Ondřej Jirman
2020-03-11  9:02                               ` Chao Yu
2020-03-11 10:33                                 ` Ondřej Jirman
2020-03-11 10:51                                   ` Chao Yu
2020-03-11 11:01                                     ` Ondřej Jirman
2020-03-11 17:01                               ` Jaegeuk Kim
2020-03-22 10:15                                 ` Chao Yu
2020-02-24 14:20         ` Ondřej Jirman

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=20191209222345.1078-2-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 2/6] f2fs: declare nested quota_sem and remove unnecessary sems' \
    /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

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).