From patchwork Mon Apr 11 00:14:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 12808346 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 1E534C433EF for ; Mon, 11 Apr 2022 00:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235125AbiDKAQx (ORCPT ); Sun, 10 Apr 2022 20:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234919AbiDKAQw (ORCPT ); Sun, 10 Apr 2022 20:16:52 -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 49611286 for ; Sun, 10 Apr 2022 17:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649636077; 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=gF+3+vkcNdiXC89p6z2L3dQ8GpSBFXEc5RUA98Bv5bU=; b=dlOgd9ItGkK6iTrkw8WR1Z67bZ/mphFmbjHiq5A4fbDJPwbCSm3XB8gqC3CYQI35T6MXow y/rzsaEeYvKlFWNFyhlYA5NRKwVVz4mav7M1oiOQpbN6Hey8DQyHq1Vsw9iSfFGwwhy0eC t5NLUyxBidVHQma+hSEny60xobofAKA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-131-s65neMrrO2is70M9fHMFNg-1; Sun, 10 Apr 2022 20:14:34 -0400 X-MC-Unique: s65neMrrO2is70M9fHMFNg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF018185A79C; Mon, 11 Apr 2022 00:14:33 +0000 (UTC) Received: from lxbceph1.gsslab.pek2.redhat.com (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id D28ED145B96F; Mon, 11 Apr 2022 00:14:31 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org Cc: idryomov@gmail.com, vshankar@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH v2 1/2] ceph: flush small range instead of the whole map for truncate Date: Mon, 11 Apr 2022 08:14:25 +0800 Message-Id: <20220411001426.251679-2-xiubli@redhat.com> In-Reply-To: <20220411001426.251679-1-xiubli@redhat.com> References: <20220411001426.251679-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li Signed-off-by: Xiubo Li --- fs/ceph/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 45ca4e598ef0..a2ff964e332b 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2275,8 +2275,13 @@ 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)) { + loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SHIFT - 1; + ret = filemap_write_and_wait_range(inode->i_mapping, + orig_pos, lend); + if (ret < 0) + goto out; + } page = __page_cache_alloc(GFP_KERNEL); if (page == NULL) {