From patchwork Tue Apr 12 07:07:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 560066 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 2E17AC433F5 for ; Tue, 12 Apr 2022 09:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351684AbiDLJwo (ORCPT ); Tue, 12 Apr 2022 05:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351230AbiDLH2A (ORCPT ); Tue, 12 Apr 2022 03:28:00 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 797C94EF5F for ; Tue, 12 Apr 2022 00:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649747279; 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=IRF6LVwJSHJOWFm7I1F+YrA+lOMpLLhwycut1OVWExo=; b=eAFR3iuBPcRl+TmQ/4lSNwjhh/25VexeKDNpe3teqaTeboqHIDZ4ZqnsQ4VQ5AqJSjwOzo 0IgyHTBYJQZD0ohSV6gu7emg6bahGRZXzkHNKJBmwCP5RNy77Utn3gHzGB2/Dw6U+HIUph Re4/l1Da0Tq9/d4kYoKwH9BeSpEIQX4= 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-460-ZDLDB1h0PJa-m8ZfoBguNg-1; Tue, 12 Apr 2022 03:07:55 -0400 X-MC-Unique: ZDLDB1h0PJa-m8ZfoBguNg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45451185A7B2; Tue, 12 Apr 2022 07:07:55 +0000 (UTC) Received: from localhost (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FDE140CF91A; Tue, 12 Apr 2022 07:07:54 +0000 (UTC) From: Xiubo Li To: jlayton@kernel.org Cc: idryomov@gmail.com, vshankar@redhat.com, lhenriques@suse.de, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH v3 1/3] ceph: flush small range instead of the whole map for truncate Date: Tue, 12 Apr 2022 15:07:43 +0800 Message-Id: <20220412070745.22795-2-xiubli@redhat.com> In-Reply-To: <20220412070745.22795-1-xiubli@redhat.com> References: <20220412070745.22795-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 fa0d3018d981..a5145a2b7228 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2274,8 +2274,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) {