mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: fix misleading comments in read_write.c
@ 2026-09-14  7:53 Yingchao Deng
  2026-09-14 10:05 ` Jan Kara
  2026-09-17 10:33 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Yingchao Deng @ 2026-09-14  7:53 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jan Kara
  Cc: linux-fsdevel, linux-kernel, qinyungao, Yingchao Deng

generic_write_checks() returns the number of bytes that may be written
(possibly truncated by generic_write_check_limits()), not zero.  The
comment was likely copied from generic_copy_file_checks(), which is the
analogous function for copy_file_range() and does return 0 on success.

Also, no_seek_end_llseek() and no_seek_end_llseek_size() are helpers for
files that do not support SEEK_END (they only handle SEEK_SET and
SEEK_CUR), not for "fixed-sized devices"; that description was copied
from fixed_size_llseek().

Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>
---
 fs/read_write.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index e8c14e2760b2..4da846a2bf17 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -274,7 +274,7 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si
 EXPORT_SYMBOL(fixed_size_llseek);
 
 /**
- * no_seek_end_llseek - llseek implementation for fixed-sized devices
+ * no_seek_end_llseek - llseek implementation for files without SEEK_END
  * @file:	file structure to seek on
  * @offset:	file offset to seek to
  * @whence:	type of seek
@@ -293,7 +293,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
 EXPORT_SYMBOL(no_seek_end_llseek);
 
 /**
- * no_seek_end_llseek_size - llseek implementation for fixed-sized devices
+ * no_seek_end_llseek_size - llseek implementation for files without SEEK_END
  * @file:	file structure to seek on
  * @offset:	file offset to seek to
  * @whence:	type of seek
@@ -1761,8 +1761,8 @@ EXPORT_SYMBOL(generic_write_checks_count);
  * Performs necessary checks before doing a write
  *
  * Can adjust writing position or amount of bytes to write.
- * Returns appropriate error code that caller should return or
- * zero in case that write should be allowed.
+ * Returns the number of bytes that may be written on success (which
+ * may be less than requested if truncated), or a negative error code.
  */
 ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
 {
-- 
2.33.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: fix misleading comments in read_write.c
  2026-09-14  7:53 [PATCH] fs: fix misleading comments in read_write.c Yingchao Deng
@ 2026-09-14 10:05 ` Jan Kara
  2026-09-17 10:33 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-09-14 10:05 UTC (permalink / raw)
  To: Yingchao Deng
  Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel,
	linux-kernel, qinyungao

On Mon 14-09-26 15:53:37, Yingchao Deng wrote:
> generic_write_checks() returns the number of bytes that may be written
> (possibly truncated by generic_write_check_limits()), not zero.  The
> comment was likely copied from generic_copy_file_checks(), which is the
> analogous function for copy_file_range() and does return 0 on success.
> 
> Also, no_seek_end_llseek() and no_seek_end_llseek_size() are helpers for
> files that do not support SEEK_END (they only handle SEEK_SET and
> SEEK_CUR), not for "fixed-sized devices"; that description was copied
> from fixed_size_llseek().
> 
> Signed-off-by: Yingchao Deng <dengyingchao@kylinsec.com.cn>

Nice, thanks. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/read_write.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/read_write.c b/fs/read_write.c
> index e8c14e2760b2..4da846a2bf17 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -274,7 +274,7 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si
>  EXPORT_SYMBOL(fixed_size_llseek);
>  
>  /**
> - * no_seek_end_llseek - llseek implementation for fixed-sized devices
> + * no_seek_end_llseek - llseek implementation for files without SEEK_END
>   * @file:	file structure to seek on
>   * @offset:	file offset to seek to
>   * @whence:	type of seek
> @@ -293,7 +293,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
>  EXPORT_SYMBOL(no_seek_end_llseek);
>  
>  /**
> - * no_seek_end_llseek_size - llseek implementation for fixed-sized devices
> + * no_seek_end_llseek_size - llseek implementation for files without SEEK_END
>   * @file:	file structure to seek on
>   * @offset:	file offset to seek to
>   * @whence:	type of seek
> @@ -1761,8 +1761,8 @@ EXPORT_SYMBOL(generic_write_checks_count);
>   * Performs necessary checks before doing a write
>   *
>   * Can adjust writing position or amount of bytes to write.
> - * Returns appropriate error code that caller should return or
> - * zero in case that write should be allowed.
> + * Returns the number of bytes that may be written on success (which
> + * may be less than requested if truncated), or a negative error code.
>   */
>  ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from)
>  {
> -- 
> 2.33.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: fix misleading comments in read_write.c
  2026-09-14  7:53 [PATCH] fs: fix misleading comments in read_write.c Yingchao Deng
  2026-09-14 10:05 ` Jan Kara
@ 2026-09-17 10:33 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-09-17 10:33 UTC (permalink / raw)
  To: Alexander Viro, Jan Kara, Yingchao Deng
  Cc: Christian Brauner, linux-fsdevel, linux-kernel, qinyungao

On Mon, 14 Sep 2026 15:53:37 +0800, Yingchao Deng wrote:
> generic_write_checks() returns the number of bytes that may be written
> (possibly truncated by generic_write_check_limits()), not zero.  The
> comment was likely copied from generic_copy_file_checks(), which is the
> analogous function for copy_file_range() and does return 0 on success.
> 
> Also, no_seek_end_llseek() and no_seek_end_llseek_size() are helpers for
> files that do not support SEEK_END (they only handle SEEK_SET and
> SEEK_CUR), not for "fixed-sized devices"; that description was copied
> from fixed_size_llseek().
> 
> [...]

Applied to the vfs-7.4.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.4.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.4.misc

[1/1] fs: fix misleading comments in read_write.c
      https://git.kernel.org/vfs/vfs/c/73a1ab6d7e14

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17 10:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14  7:53 [PATCH] fs: fix misleading comments in read_write.c Yingchao Deng
2026-09-14 10:05 ` Jan Kara
2026-09-17 10:33 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®