Unverified Commit ff773a40 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!6042 nilfs2: fix data corruption in dsync block recovery for small block sizes

parents 02b054ea 85553d8c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -472,9 +472,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,

static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
				     struct nilfs_recovery_block *rb,
				     struct page *page)
				     loff_t pos, struct page *page)
{
	struct buffer_head *bh_org;
	size_t from = pos & ~PAGE_MASK;
	void *kaddr;

	bh_org = __bread(nilfs->ns_bdev, rb->blocknr, nilfs->ns_blocksize);
@@ -482,7 +483,7 @@ static int nilfs_recovery_copy_block(struct the_nilfs *nilfs,
		return -EIO;

	kaddr = kmap_atomic(page);
	memcpy(kaddr + bh_offset(bh_org), bh_org->b_data, bh_org->b_size);
	memcpy(kaddr + from, bh_org->b_data, bh_org->b_size);
	kunmap_atomic(kaddr);
	brelse(bh_org);
	return 0;
@@ -521,7 +522,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
			goto failed_inode;
		}

		err = nilfs_recovery_copy_block(nilfs, rb, page);
		err = nilfs_recovery_copy_block(nilfs, rb, pos, page);
		if (unlikely(err))
			goto failed_page;