All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Correct assignment of pos
@ 2017-07-05  0:02 Goldwyn Rodrigues
  2017-07-05  0:44 ` Marc Dionne
  0 siblings, 1 reply; 2+ messages in thread
From: Goldwyn Rodrigues @ 2017-07-05  0:02 UTC (permalink / raw)
  To: linux-btrfs
  Cc: linux-block, markus, linux-kernel, axboe, dsterba, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Assigning pos for usage early messes up in append mode, where
the pos is re-assigned in generic_write_checks(). Re-assign
pos to get the correct position to write from iocb->ki_pos.

Fixes: edf064e7c6fe ("btrfs: nowait aio support")
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
---
 fs/btrfs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 59e2dccdf75b..7947781229e5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1931,6 +1931,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	 */
 	update_time_for_write(inode);
 
+	pos = iocb->ki_pos;
 	start_pos = round_down(pos, fs_info->sectorsize);
 	oldsize = i_size_read(inode);
 	if (start_pos > oldsize) {
-- 
2.12.0

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

* Re: [PATCH] btrfs: Correct assignment of pos
  2017-07-05  0:02 [PATCH] btrfs: Correct assignment of pos Goldwyn Rodrigues
@ 2017-07-05  0:44 ` Marc Dionne
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Dionne @ 2017-07-05  0:44 UTC (permalink / raw)
  To: Goldwyn Rodrigues
  Cc: linux-btrfs, linux-block, markus, Linux Kernel Mailing List,
	axboe, dsterba, Goldwyn Rodrigues

On Tue, Jul 4, 2017 at 9:02 PM, Goldwyn Rodrigues <rgoldwyn@suse.de> wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Assigning pos for usage early messes up in append mode, where
> the pos is re-assigned in generic_write_checks(). Re-assign
> pos to get the correct position to write from iocb->ki_pos.
>
> Fixes: edf064e7c6fe ("btrfs: nowait aio support")
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
> ---
>  fs/btrfs/file.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 59e2dccdf75b..7947781229e5 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1931,6 +1931,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
>          */
>         update_time_for_write(inode);
>
> +       pos = iocb->ki_pos;
>         start_pos = round_down(pos, fs_info->sectorsize);
>         oldsize = i_size_read(inode);
>         if (start_pos > oldsize) {
> --
> 2.12.0

For an append, shouldn't you also be using this updated pos from
generic_write_checks when calling check_can_nocow at the top of the
function?

Marc

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

end of thread, other threads:[~2017-07-05  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-05  0:02 [PATCH] btrfs: Correct assignment of pos Goldwyn Rodrigues
2017-07-05  0:44 ` Marc Dionne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.