Skip to content

Commit

Permalink
Revert "f2fs: Fix deadlock between f2fs_quota_sync and block_operation"
Browse files Browse the repository at this point in the history
This reverts commit 26233c1a7e343e010a33310313e6b6067c4249e3.

Signed-off-by: engstk <eng.stk@sapo.pt>
  • Loading branch information
engstk committed Mar 12, 2021
1 parent 2587f9b commit 4e42569
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
3 changes: 0 additions & 3 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,6 @@ struct f2fs_sb_info {
struct inode *meta_inode; /* cache meta blocks */
struct mutex cp_mutex; /* checkpoint procedure lock */
struct rw_semaphore cp_rwsem; /* blocking FS operations */
struct rw_semaphore cp_quota_rwsem; /* blocking quota sync operations */
struct rw_semaphore node_write; /* locking node writes */
struct rw_semaphore node_change; /* locking node change */
wait_queue_head_t cp_wait;
Expand Down Expand Up @@ -1883,14 +1882,12 @@ static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi)

static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
{
down_write(&sbi->cp_quota_rwsem);
down_write(&sbi->cp_rwsem);
}

static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
{
up_write(&sbi->cp_rwsem);
up_write(&sbi->cp_quota_rwsem);
}

static inline int __get_cp_reason(struct f2fs_sb_info *sbi)
Expand Down
13 changes: 2 additions & 11 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2281,16 +2281,8 @@ int f2fs_quota_sync(struct super_block *sb, int type)
* f2fs_dquot_commit
* block_operation
* down_read(quota_sem)
*
* However, we cannot use the cp_rwsem to prevent this
* deadlock, as the cp_rwsem is taken for read inside the
* f2fs_dquot_commit code, and rwsem is not recursive.
*
* We therefore use a special lock to synchronize
* f2fs_quota_sync with block_operations, as this is the only
* place where such recursion occurs.
*/
down_read(&sbi->cp_quota_rwsem);
f2fs_lock_op(sbi);

down_read(&sbi->quota_sem);
ret = dquot_writeback_dquots(sb, type);
Expand Down Expand Up @@ -2331,7 +2323,7 @@ int f2fs_quota_sync(struct super_block *sb, int type)
if (ret)
set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
up_read(&sbi->quota_sem);
up_read(&sbi->cp_quota_rwsem);
f2fs_unlock_op(sbi);
return ret;
}

Expand Down Expand Up @@ -3711,7 +3703,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)

init_rwsem(&sbi->cp_rwsem);
init_rwsem(&sbi->quota_sem);
init_rwsem(&sbi->cp_quota_rwsem);
init_waitqueue_head(&sbi->cp_wait);
init_sb_info(sbi);

Expand Down

0 comments on commit 4e42569

Please sign in to comment.