[Devel] [PATCH RH7] pfcache: do not drop pfcache checksum during mmap(SHARED) of ro-files

Vasily Averin vvs at virtuozzo.com
Sat Feb 22 08:02:40 MSK 2020


I still have some doubts,
careful review is required here.

On 2/20/20 1:04 PM, Vasily Averin wrote:
> Currently any mmap(SHARED) removes pfcache mark, even for
> read_only-opened files. It is required to guarantee that
> shared mappings will see changes if mapped file will be
> write-opened and modified.
> 
> On the other hand we do not want to drop pfcache mark without
> necessary. At present ldconfig calls mmap(SHARED) before adding of
> any new files into library cache. It removes pfcache mark and
> do not allow to add libraries into pfcache.
> 
> This patch help to avoid the problem: during mmap(SHARED) for read-only
> files kernel do not drop pfcache mark from inode but close file in
> pfcache area and use its local copy.
> 
> In fact such mappings can be linked back to pfcache file,
> via ext4_relink_pfcache() called during fs remount, however I believe it
> is extremely rare situation and even if this happen it's unlikely
> lead to troubles.
> 
> https://jira.sw.ru/browse/PSBM-64045
> Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
> ---
>  fs/ext4/file.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 5acd8ae38db2..ed31192cdaa8 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -363,7 +363,10 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
>  	if (!vma) {
>  		if (ext4_test_inode_state(inode, EXT4_STATE_PFCACHE_CSUM)) {
>  			mutex_lock(&inode->i_mutex);
> -			ext4_truncate_data_csum(inode, -1);
> +			if (file->f_mode & FMODE_WRITE)
> +				ext4_truncate_data_csum(inode, -1);
> +			else
> +				ext4_close_pfcache(inode);
>  			mutex_unlock(&inode->i_mutex);
>  		}
>  		return 0;
> 


More information about the Devel mailing list