Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5727C48BE5 for ; Fri, 11 Jun 2021 22:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9135C613D3 for ; Fri, 11 Jun 2021 22:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbhFKWW6 (ORCPT ); Fri, 11 Jun 2021 18:22:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhFKWW5 (ORCPT ); Fri, 11 Jun 2021 18:22:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D94E5613CF; Fri, 11 Jun 2021 22:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623450059; bh=Yafo506JqOKnjsaULTOPOr2BWRI/1R51DD5cfo8K+HA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=fJPq4SEiwWvkQrh7LCDVIFQIxtXAzZu3ooEcSq+G95WxgvpuP1C7ufURv1vyu8lOB EmsHqG3sevsVQYKRFKzFBQJZHjFiPWgLV5d2AJHDCq6/YucaeLwdwl7duPpJAbm6m1 5UUR2pYlOS9zAlott15+baeXd8bxou83F8kNvesfnsYHHcpVDgN5dUOb/Fo/rtQ9Ob 4P4/tgT6pTWVO6Lp+b8abBKNO6TxR2TtMPkhSdyl5LO4QUKJazwewYo7k2WED00QoY SFn2mV64YHy1xShTc3JzvhHPi2Q2npRSEyopgpMvVvk0t+NAZ9fbISLRGEVWasByyU Uxv15r+MQajxA== Message-ID: <74f391de84d957a3d726b0bbb00ab81d0d90d521.camel@kernel.org> Subject: Re: [PATCH] ceph: fix write_begin optimization when write is beyond EOF From: Jeff Layton To: Matthew Wilcox Cc: ceph-devel@vger.kernel.org, linux-cachefs@redhat.com, pfmeec@rit.edu, dhowells@redhat.com, idryomov@gmail.com, stable@vger.kernel.org, Andrew W Elble Date: Fri, 11 Jun 2021 18:20:57 -0400 In-Reply-To: References: <20210611195904.160416-1-jlayton@kernel.org> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.40.1 (3.40.1-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org On Fri, 2021-06-11 at 21:48 +0100, Matthew Wilcox wrote: > On Fri, Jun 11, 2021 at 03:59:04PM -0400, Jeff Layton wrote: > > if ((pos_in_page == 0 && len == PAGE_SIZE) || > > - (pos >= i_size_read(inode)) || > > + (index > (i_size_read(inode) / PAGE_SIZE)) || > > I think that wants to be ((i_size_read(inode) - 1) / PAGE_SIZE) > > If your file is 4096 bytes long, that means bytes 0-4095 contain data. > Except that i_size can be 0, so ... > > if ((offset == 0 && len == PAGE_SIZE) || i_size == 0 || > (index > (i_size - 1) / PAGE_SIZE) || > (offset == 0 && pos + len >= i_size)) > zero_user_segments(page, 0, pos_in_page, > pos_in_page + len, PAGE_SIZE); > Oh, right -- I'll fix that and send a v2. Sorry for the noise! -- Jeff Layton