From: Bodo Stroesser <bostroesser@gmail.com>
To: Bart Van Assche <bvanassche@acm.org>, Christoph Hellwig <hch@lst.de>
Cc: Joel Becker <jlbec@evilplan.org>,
linux-kernel@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Yanko Kaneti <yaneti@declera.com>,
Brendan Higgins <brendanhiggins@google.com>
Subject: Re: [PATCH 2/4] configfs: Fix writing at a non-zero offset
Date: Wed, 28 Jul 2021 19:14:58 +0200 [thread overview]
Message-ID: <b33a5330-472b-9961-c590-5c07420cf9de@gmail.com> (raw)
In-Reply-To: <a3ba73e5-ffd1-887e-acd9-11f537db27e0@acm.org>
Hi Bart,
I reviewed and tested the new patch. For me it works fine.
Just one warning to fix:
fs/configfs/file.c: In function ‘fill_write_buffer’:
fs/configfs/file.c:184:6: warning: unused variable ‘to_copy’
[-Wunused-variable]
int to_copy, copied;
^~~~~~~
Apart from that you can add my tested-by or reviewed-by if you want.
Thank you,
Bodo
On 27.07.21 18:47, Bart Van Assche wrote:
> Hi Bodo,
>
> How about replacing patches 1 and 2 from this series with the patch below?
> Do you agree that this patch is sufficient to restore the behavior from
> kernel v5.13 and before?
>
> Thanks,
>
> Bart.
>
> Subject: [PATCH 1/3] configfs: Restore the kernel v5.13 text attribute
> write behavior
>
> Instead of writing at the offset specified by the write() system call,
> always write at offset zero.
>
> Cc: Bodo Stroesser <bostroesser@gmail.com>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: Yanko Kaneti <yaneti@declera.com>
> Cc: Brendan Higgins <brendanhiggins@google.com>
> Reported-by: Bodo Stroesser <bostroesser@gmail.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> fs/configfs/file.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/fs/configfs/file.c b/fs/configfs/file.c
> index 5a0be9985bae..8adf6250b207 100644
> --- a/fs/configfs/file.c
> +++ b/fs/configfs/file.c
> @@ -177,12 +177,11 @@ static ssize_t configfs_bin_read_iter(struct kiocb
> *iocb, struct iov_iter *to)
> return retval;
> }
>
> -/* Fill [buffer, buffer + pos) with data coming from @from. */
> -static int fill_write_buffer(struct configfs_buffer *buffer, loff_t pos,
> +/* Fill @buffer with data coming from @from. */
> +static int fill_write_buffer(struct configfs_buffer *buffer,
> struct iov_iter *from)
> {
> - loff_t to_copy;
> - int copied;
> + int to_copy, copied;
> u8 *to;
>
> if (!buffer->page)
> @@ -190,11 +189,8 @@ static int fill_write_buffer(struct configfs_buffer
> *buffer, loff_t pos,
> if (!buffer->page)
> return -ENOMEM;
>
> - to_copy = SIMPLE_ATTR_SIZE - 1 - pos;
> - if (to_copy <= 0)
> - return 0;
> - to = buffer->page + pos;
> - copied = copy_from_iter(to, to_copy, from);
> + to = buffer->page;
> + copied = copy_from_iter(to, SIMPLE_ATTR_SIZE - 1, from);
> buffer->needs_read_fill = 1;
> /* if buf is assumed to contain a string, terminate it by \0,
> * so e.g. sscanf() can scan the string easily */
> @@ -227,14 +223,14 @@ static ssize_t configfs_write_iter(struct kiocb
> *iocb, struct iov_iter *from)
> {
> struct file *file = iocb->ki_filp;
> struct configfs_buffer *buffer = file->private_data;
> - ssize_t len;
> + int len;
>
> mutex_lock(&buffer->mutex);
> - len = fill_write_buffer(buffer, iocb->ki_pos, from);
> + len = fill_write_buffer(buffer, from);
> if (len > 0)
> len = flush_write_buffer(file, buffer, len);
> if (len > 0)
> - iocb->ki_pos += len;
> + iocb->ki_pos = len;
> mutex_unlock(&buffer->mutex);
> return len;
> }
next prev parent reply other threads:[~2021-07-28 17:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-23 21:23 [PATCH 0/4] Improve the configfs read and write iterators further Bart Van Assche
2021-07-23 21:23 ` [PATCH 1/4] configfs: Rework the overflow check in fill_write_buffer() Bart Van Assche
2021-07-23 21:23 ` [PATCH 2/4] configfs: Fix writing at a non-zero offset Bart Van Assche
2021-07-26 14:58 ` Bodo Stroesser
2021-07-26 16:26 ` Bart Van Assche
2021-07-26 21:13 ` Bodo Stroesser
2021-07-26 21:52 ` Bart Van Assche
2021-07-27 0:54 ` Bodo Stroesser
2021-07-27 3:17 ` Bart Van Assche
2021-07-27 7:27 ` Bodo Stroesser
2021-07-27 16:47 ` Bart Van Assche
2021-07-28 17:14 ` Bodo Stroesser [this message]
2021-07-28 17:55 ` Bart Van Assche
2021-07-23 21:23 ` [PATCH 3/4] kunit: Add support for suite initialization and cleanup Bart Van Assche
2021-07-27 21:26 ` Brendan Higgins
2021-07-29 3:33 ` Bart Van Assche
2021-07-23 21:23 ` [PATCH 4/4] configfs: Add unit tests Bart Van Assche
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=b33a5330-472b-9961-c590-5c07420cf9de@gmail.com \
--to=bostroesser@gmail.com \
--cc=brendanhiggins@google.com \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=yaneti@declera.com \
/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;
as well as URLs for NNTP newsgroup(s).