From: Christian Brauner <brauner@kernel.org>
To: Max Kellermann <max.kellermann@ionos.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] pipe_fs_i.h: add pipe_buf_init()
Date: Tue, 19 Sep 2023 15:45:16 +0200 [thread overview]
Message-ID: <20230919-fachkenntnis-seenotrettung-3f873c1ec8da@brauner> (raw)
In-Reply-To: <20230919080707.1077426-1-max.kellermann@ionos.com>
> 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?
next prev parent reply other threads:[~2023-09-19 13:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 8:07 Max Kellermann
2023-09-19 13:45 ` Christian Brauner [this message]
2023-09-19 13:55 ` Max Kellermann
2023-09-19 14:16 ` Christian Brauner
2023-09-19 22:39 ` Max Kellermann
2023-09-19 21:40 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230919-fachkenntnis-seenotrettung-3f873c1ec8da@brauner \
--to=brauner@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=max.kellermann@ionos.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox