From patchwork Thu Apr 7 14:41:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 12805307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44201C433EF for ; Thu, 7 Apr 2022 14:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239126AbiDGOng (ORCPT ); Thu, 7 Apr 2022 10:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiDGOng (ORCPT ); Thu, 7 Apr 2022 10:43:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0463054BEF for ; Thu, 7 Apr 2022 07:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649342495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SDugp1WBSMptX4svFmhmWUwSo8QzNCtx0JtBllquiA=; b=Sso3OPnrhTsm/rSnLZLejBk8yBuENfiojVceMhUEueq7q8UshxDEUcoJtXO1rSgjInoEhb GYy/KC2sTjD358t6M8DIMegiibnqK2vTO/6FH3Ir/7pVBkX+OcsPExxebJkdjbvHnYYTVc b7op+Ciwf4kEG/FM99bJFnMNB/amPLo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-CyhjVEWBNtqYeXrGs8xCTQ-1; Thu, 07 Apr 2022 10:41:33 -0400 X-MC-Unique: CyhjVEWBNtqYeXrGs8xCTQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44CF53811F32; Thu, 7 Apr 2022 14:41:33 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2EE5403153; Thu, 7 Apr 2022 14:41:30 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, vshankar@redhat.com, lhenriques@suse.de, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH 1/2] ceph: flush small range instead of the whole map for truncate Date: Thu, 7 Apr 2022 22:41:11 +0800 Message-Id: <20220407144112.8455-2-xiubli@redhat.com> In-Reply-To: <20220407144112.8455-1-xiubli@redhat.com> References: <20220407144112.8455-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li Signed-off-by: Xiubo Li --- fs/ceph/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 45ca4e598ef0..f4059d73edd5 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2275,8 +2275,12 @@ static int fill_fscrypt_truncate(struct inode *inode, ceph_cap_string(issued)); /* Try to writeback the dirty pagecaches */ - if (issued & (CEPH_CAP_FILE_BUFFER)) - filemap_write_and_wait(inode->i_mapping); + if (issued & (CEPH_CAP_FILE_BUFFER)) { + ret = filemap_write_and_wait_range(inode->i_mapping, + orig_pos, LLONG_MAX); + if (ret < 0) + goto out; + } page = __page_cache_alloc(GFP_KERNEL); if (page == NULL) {