From patchwork Wed Jul 5 00:02:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 9825725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 790C860361 for ; Wed, 5 Jul 2017 00:02:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65EEF262FF for ; Wed, 5 Jul 2017 00:02:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 577EA2656B; Wed, 5 Jul 2017 00:02:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEFD4262FF for ; Wed, 5 Jul 2017 00:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbdGEACl (ORCPT ); Tue, 4 Jul 2017 20:02:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:35035 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752257AbdGEACl (ORCPT ); Tue, 4 Jul 2017 20:02:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7E6CFAB09; Wed, 5 Jul 2017 00:02:39 +0000 (UTC) From: Goldwyn Rodrigues To: linux-btrfs@vger.kernel.org Cc: linux-block@vger.kernel.org, markus@trippelsdorf.de, linux-kernel@vger.kernel.org, axboe@kernel.dk, dsterba@suse.com, Goldwyn Rodrigues Subject: [PATCH] btrfs: Correct assignment of pos Date: Tue, 4 Jul 2017 19:02:09 -0500 Message-Id: <20170705000209.11391-1-rgoldwyn@suse.de> X-Mailer: git-send-email 2.12.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Goldwyn Rodrigues 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 Tested-by: Markus Trippelsdorf --- 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) {