[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230919-fachkenntnis-seenotrettung-3f873c1ec8da@brauner>
Date: Tue, 19 Sep 2023 15:45:16 +0200
From: Christian Brauner <brauner@...nel.org>
To: Max Kellermann <max.kellermann@...os.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] pipe_fs_i.h: add pipe_buf_init()
> 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?
Powered by blists - more mailing lists