Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbdGGQR7 (ORCPT ); Fri, 7 Jul 2017 12:17:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:39638 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752314AbdGGQQ3 (ORCPT ); Fri, 7 Jul 2017 12:16:29 -0400 Date: Fri, 7 Jul 2017 18:15:10 +0200 From: David Sterba To: Goldwyn Rodrigues Cc: linux-btrfs@vger.kernel.org, linux-block@vger.kernel.org, markus@trippelsdorf.de, linux-kernel@vger.kernel.org, axboe@kernel.dk, dsterba@suse.com, marc.c.dionne@gmail.com, Goldwyn Rodrigues Subject: Re: [PATCH v2] btrfs: Correct assignment of pos Message-ID: <20170707161510.GJ2866@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Goldwyn Rodrigues , linux-btrfs@vger.kernel.org, linux-block@vger.kernel.org, markus@trippelsdorf.de, linux-kernel@vger.kernel.org, axboe@kernel.dk, dsterba@suse.com, marc.c.dionne@gmail.com, Goldwyn Rodrigues References: <20170705033307.8213-1-rgoldwyn@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170705033307.8213-1-rgoldwyn@suse.de> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 816 Lines: 21 On Tue, Jul 04, 2017 at 10:33:07PM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > > Assigning pos for usage early messes up in append mode, where > the pos is re-assigned in generic_write_checks(). Assign > pos later to get the correct position to write from iocb->ki_pos. > > Since check_can_nocow also uses the value of pos, we shift > generic_write_checks() before check_can_nocow(). Checks with > IOCB_DIRECT are present in generic_write_checks(), so checking > for IOCB_NOWAIT is enough. > > Also, put locking sequence in the fast path. > > Changes since v1: > - Moved pos higher up to encompass check_can_nocow() call. > > Fixes: edf064e7c6fe ("btrfs: nowait aio support") > Signed-off-by: Goldwyn Rodrigues Acked-by: David Sterba