Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccaaca25 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: fix writing incorrect orphan blocks



Previously, there was a erroneous scenario like below.
thread 1:                       thread 2:
 f2fs_unlink
  - acquire_orphan_inode
    : sbi->n_orphans++           write_checkpoint
                                 - block_operations
                                  : f2fs_lock_all
                                 - do_checkpoint
                                  : write orphan blocks with sbi->n_orphans
                                 - unblock_operations
  - f2fs_lock_op
  - release_orphan_inode
  - f2fs_unlock_op

During the checkpoint by thread 2, f2fs stores a wrong orphan block according
to the wrong sbi->n_orphans.
To avoid this, simply we should make cover acquire_orphan_inode too with
f2fs_lock_op.

Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent 5887d291
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -228,14 +228,14 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
	if (!de)
	if (!de)
		goto fail;
		goto fail;


	f2fs_lock_op(sbi);
	err = acquire_orphan_inode(sbi);
	err = acquire_orphan_inode(sbi);
	if (err) {
	if (err) {
		f2fs_unlock_op(sbi);
		kunmap(page);
		kunmap(page);
		f2fs_put_page(page, 0);
		f2fs_put_page(page, 0);
		goto fail;
		goto fail;
	}
	}

	f2fs_lock_op(sbi);
	f2fs_delete_entry(de, page, inode);
	f2fs_delete_entry(de, page, inode);
	f2fs_unlock_op(sbi);
	f2fs_unlock_op(sbi);