Re: [PATCH] pipe_fs_i.h: add pipe_buf_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> diff --git a/mm/filemap.c b/mm/filemap.c
> index 582f5317ff71..74532e0cb8d7 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2850,12 +2850,8 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
>  		struct pipe_buffer *buf = pipe_head_buf(pipe);
>  		size_t part = min_t(size_t, PAGE_SIZE - offset, size - spliced);
>  
> -		*buf = (struct pipe_buffer) {
> -			.ops	= &page_cache_pipe_buf_ops,
> -			.page	= page,
> -			.offset	= offset,
> -			.len	= part,
> -		};
> +		pipe_buf_init(buf, page, offset, part,
> +			      &page_cache_pipe_buf_ops, 0);
>  		folio_get(folio);
>  		pipe->head++;
>  		page++;
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 02e62fccc80d..75d39653b028 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2901,12 +2901,9 @@ static size_t splice_zeropage_into_pipe(struct pipe_inode_info *pipe,
>  	if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage)) {
>  		struct pipe_buffer *buf = pipe_head_buf(pipe);
>  
> -		*buf = (struct pipe_buffer) {
> -			.ops	= &zero_pipe_buf_ops,
> -			.page	= ZERO_PAGE(0),
> -			.offset	= offset,
> -			.len	= size,
> -		};
> +		pipe_buf_init(buf, ZERO_PAGE(0),
> +			      offset, size,
> +			      &zero_pipe_buf_ops, 0);
>  		pipe->head++;
>  	}

So this may cause issues because the compound literal will cause all non
explicitly initialized fields to be initialized to zero values whereas
your new helper wouldn't. So pipe_buf->private may now contain garbage.
Not ideal imho. Does the helper buy us that much overall?



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux