Commit a4f89b24 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Liu Shixin
Browse files

shmem: set a_ops earlier in shmem_symlink

mainline inclusion
from mainline-v6.9-rc1
commit e11381d83d72198565f4545d9988b4720288eb64
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAIHPC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e11381d83d72198565f4545d9988b4720288eb64



--------------------------------

Set the a_ops in shmem_symlink before reading a folio from the mapping
to prepare for asserting that shmem_get_folio is only called on shmem
mappings.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Matthew Wilcox (Oracle)" <willy@infradead.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
[ Dep-of: 1f63177ea89cf28bb7b2093e03769da9c9bca89a ]
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 9ea3e167
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3508,10 +3508,10 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
		inode->i_op = &shmem_short_symlink_operations;
	} else {
		inode_nohighmem(inode);
		inode->i_mapping->a_ops = &shmem_aops;
		error = shmem_get_folio(inode, 0, &folio, SGP_WRITE);
		if (error)
			goto out_remove_offset;
		inode->i_mapping->a_ops = &shmem_aops;
		inode->i_op = &shmem_symlink_inode_operations;
		memcpy(folio_address(folio), symname, len);
		folio_mark_uptodate(folio);